@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... o) { assert functionQualifier == null; return new SqlCreateFunction(pos, (SqlIdentifier) o[0], o[1], o[2]); }
@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... o) { assert functionQualifier == null; return new SqlCreateTable(pos, (SqlIdentifier) o[0], (SqlNodeList) o[1], o[2], o[3], o[4], o[5], o[6], o[7]); }
@Override public void unparse( SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { SqlCreateFunction t = (SqlCreateFunction) call; UnparseUtil u = new UnparseUtil(writer, leftPrec, rightPrec); u.keyword("CREATE", "FUNCTION").node(t.functionName).keyword("AS").node(t.className); if (t.jarName != null) { u.keyword("USING", "JAR").node(t.jarName); } } };
ColumnConstraint constraint = null; SqlMonotonicity monotonicity = SqlMonotonicity.NOT_MONOTONIC; name = SimpleIdentifier(); pos = getPos(); type = DataType(); if (jj_2_43(2)) { jj_consume_token(PRIMARY); jj_consume_token(KEY); if (jj_2_42(2)) { if (jj_2_40(2)) { jj_consume_token(ASC); monotonicity = SqlMonotonicity.INCREASING; } else if (jj_2_41(2)) { jj_consume_token(DESC); monotonicity = SqlMonotonicity.DECREASING; } else { jj_consume_token(-1); throw new ParseException(); constraint = new ColumnConstraint.PrimaryKey(monotonicity, getPos()); } else { list.add(new ColumnDefinition(name, type, constraint, pos));
/** * CREATE FUNCTION functionname AS 'classname' */ final public SqlNode SqlCreateFunction() throws ParseException { SqlParserPos pos; SqlIdentifier functionName; SqlNode className; SqlNode jarName = null; jj_consume_token(CREATE); pos = getPos(); jj_consume_token(FUNCTION); functionName = CompoundIdentifier(); jj_consume_token(AS); className = StringLiteral(); if (jj_2_49(2)) { jj_consume_token(USING); jj_consume_token(JAR); jarName = StringLiteral(); } else { ; } {if (true) return new SqlCreateFunction(pos, functionName, className, jarName);} throw new Error("Missing return statement in function"); }
private static SqlNode parse(String sql) throws Exception { StreamlineParser parser = new StreamlineParser(sql); return parser.impl().parseSqlStmtEof(); } }
@Override public void unparse( SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) { SqlCreateTable t = (SqlCreateTable) call; UnparseUtil u = new UnparseUtil(writer, leftPrec, rightPrec); u.keyword("CREATE", "EXTERNAL", "TABLE").node(t.tblName).nodeList( t.fieldList); if (t.inputFormatClass != null && t.outputFormatClass != null) { u.keyword("STORED", "AS", "INPUTFORMAT").node( t.inputFormatClass).keyword("OUTPUTFORMAT").node( t.outputFormatClass); } u.keyword("LOCATION").node(t.location); if (t.parallelism != null) { u.keyword("PARALLELISM").node(t.parallelism); } if (t.properties != null) { u.keyword("TBLPROPERTIES").node(t.properties); } if (t.query != null) { u.keyword("AS").node(t.query); } } };
public String inputFormatClass() { return getString(inputFormatClass); }
public ColumnConstraint constraint() { return (ColumnConstraint) get(2); } }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { getOperator().unparse(writer, this, leftPrec, rightPrec); }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { getOperator().unparse(writer, this, leftPrec, rightPrec); }
public TableBuilderInfo field(String name, SqlDataTypeSpec type, ColumnConstraint constraint) { RelDataType dataType = type.deriveType(typeFactory); if (constraint instanceof ColumnConstraint.PrimaryKey) { ColumnConstraint.PrimaryKey pk = (ColumnConstraint.PrimaryKey) constraint; Preconditions.checkState(primaryKey == -1, "There are more than one primary key in the table"); primaryKey = fields.size(); primaryKeyMonotonicity = pk.monotonicity(); } fields.add(new FieldType(name, dataType)); return this; }
ColumnConstraint constraint = null; SqlMonotonicity monotonicity = SqlMonotonicity.NOT_MONOTONIC; name = SimpleIdentifier(); pos = getPos(); type = DataType(); if (jj_2_43(2)) { jj_consume_token(PRIMARY); jj_consume_token(KEY); if (jj_2_42(2)) { if (jj_2_40(2)) { jj_consume_token(ASC); monotonicity = SqlMonotonicity.INCREASING; } else if (jj_2_41(2)) { jj_consume_token(DESC); monotonicity = SqlMonotonicity.DECREASING; } else { jj_consume_token(-1); throw new ParseException(); constraint = new ColumnConstraint.PrimaryKey(monotonicity, getPos()); } else { list.add(new ColumnDefinition(name, type, constraint, pos));
/** * CREATE FUNCTION functionname AS 'classname' */ final public SqlNode SqlCreateFunction() throws ParseException { SqlParserPos pos; SqlIdentifier functionName; SqlNode className; SqlNode jarName = null; jj_consume_token(CREATE); pos = getPos(); jj_consume_token(FUNCTION); functionName = CompoundIdentifier(); jj_consume_token(AS); className = StringLiteral(); if (jj_2_49(2)) { jj_consume_token(USING); jj_consume_token(JAR); jarName = StringLiteral(); } else { ; } {if (true) return new SqlCreateFunction(pos, functionName, className, jarName);} throw new Error("Missing return statement in function"); }
public String outputFormatClass() { return getString(outputFormatClass); }
public SqlDataTypeSpec type() { return (SqlDataTypeSpec) get(1); }
public Integer parallelism() { String parallelismStr = getString(parallelism); if (parallelismStr != null) { return Integer.parseInt(parallelismStr); } else { return DEFAULT_PARALLELISM; } }
public String name() { return get(0).toString(); }
public URI location() { return URI.create(getString(location)); }
public Properties properties() { Properties props = new Properties(); if (properties != null) { try { ObjectMapper mapper = new ObjectMapper(); HashMap<String, Object> map = mapper.readValue(getString(properties), HashMap.class); props.putAll(map); } catch (IOException e) { throw new RuntimeException(e); } } return props; }