Search in sources :

Example 36 with SqlNodeList

use of org.apache.calcite.sql.SqlNodeList in project drill by apache.

the class AnalyzeTableHandler method getColumnList.

/* Generates the column list specified in the ANALYZE statement */
private SqlNodeList getColumnList(final SqlAnalyzeTable sqlAnalyzeTable) {
    SqlNodeList columnList = sqlAnalyzeTable.getFieldList();
    if (columnList == null || columnList.size() <= 0) {
        columnList = new SqlNodeList(SqlParserPos.ZERO);
        columnList.add(new SqlIdentifier(SchemaPath.STAR_COLUMN.rootName(), SqlParserPos.ZERO));
    }
    /*final SqlNodeList columnList = new SqlNodeList(SqlParserPos.ZERO);
    final List<String> fields = sqlAnalyzeTable.getFieldNames();
    if (fields == null || fields.size() <= 0) {
      columnList.add(new SqlIdentifier(SchemaPath.STAR_COLUMN.rootName(), SqlParserPos.ZERO));
    } else {
      for(String field : fields) {
        columnList.add(new SqlIdentifier(field, SqlParserPos.ZERO));
      }
    }*/
    return columnList;
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier)

Example 37 with SqlNodeList

use of org.apache.calcite.sql.SqlNodeList in project flink by apache.

the class SqlAddHivePartitions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("ALTER TABLE");
    tableIdentifier.unparse(writer, leftPrec, rightPrec);
    writer.newlineAndIndent();
    writer.keyword("ADD");
    if (ifNotExists()) {
        writer.keyword("IF NOT EXISTS");
    }
    int opLeftPrec = getOperator().getLeftPrec();
    int opRightPrec = getOperator().getRightPrec();
    for (int i = 0; i < getPartSpecs().size(); i++) {
        writer.newlineAndIndent();
        SqlNodeList partSpec = getPartSpecs().get(i);
        writer.keyword("PARTITION");
        partSpec.unparse(writer, opLeftPrec, opRightPrec);
        SqlCharStringLiteral location = partLocations.get(i);
        if (location != null) {
            writer.keyword("LOCATION");
            location.unparse(writer, opLeftPrec, opRightPrec);
        }
    }
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList) SqlCharStringLiteral(org.apache.calcite.sql.SqlCharStringLiteral)

Example 38 with SqlNodeList

use of org.apache.calcite.sql.SqlNodeList in project flink by apache.

the class SqlAlterHiveTable method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("ALTER TABLE");
    tableIdentifier.unparse(writer, leftPrec, rightPrec);
    SqlNodeList partitionSpec = getPartitionSpec();
    if (partitionSpec != null && partitionSpec.size() > 0) {
        writer.keyword("PARTITION");
        partitionSpec.unparse(writer, getOperator().getLeftPrec(), getOperator().getRightPrec());
    }
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Example 39 with SqlNodeList

use of org.apache.calcite.sql.SqlNodeList in project flink by apache.

the class SqlAddPartitions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.newlineAndIndent();
    writer.keyword("ADD");
    if (ifNotExists) {
        writer.keyword("IF NOT EXISTS");
    }
    int opLeftPrec = getOperator().getLeftPrec();
    int opRightPrec = getOperator().getRightPrec();
    for (int i = 0; i < partSpecs.size(); i++) {
        writer.newlineAndIndent();
        SqlNodeList partSpec = partSpecs.get(i);
        SqlNodeList partProp = partProps.get(i);
        writer.keyword("PARTITION");
        partSpec.unparse(writer, opLeftPrec, opRightPrec);
        if (partProp != null) {
            writer.keyword("WITH");
            partProp.unparse(writer, opLeftPrec, opRightPrec);
        }
    }
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Example 40 with SqlNodeList

use of org.apache.calcite.sql.SqlNodeList in project flink by apache.

the class SqlDropPartitions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.newlineAndIndent();
    writer.keyword("DROP");
    if (ifExists) {
        writer.keyword("IF EXISTS");
    }
    int opLeftPrec = getOperator().getLeftPrec();
    int opRightPrec = getOperator().getRightPrec();
    final SqlWriter.Frame frame = writer.startList("", "");
    for (SqlNodeList partSpec : partSpecs) {
        writer.sep(",");
        writer.newlineAndIndent();
        writer.keyword("PARTITION");
        partSpec.unparse(writer, opLeftPrec, opRightPrec);
    }
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Aggregations

SqlNodeList (org.apache.calcite.sql.SqlNodeList)123 SqlNode (org.apache.calcite.sql.SqlNode)97 ArrayList (java.util.ArrayList)45 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)43 RelDataType (org.apache.calcite.rel.type.RelDataType)39 SqlCall (org.apache.calcite.sql.SqlCall)30 SqlSelect (org.apache.calcite.sql.SqlSelect)29 BitString (org.apache.calcite.util.BitString)23 RexNode (org.apache.calcite.rex.RexNode)13 SqlLiteral (org.apache.calcite.sql.SqlLiteral)11 ImmutableList (com.google.common.collect.ImmutableList)10 List (java.util.List)10 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)10 NlsString (org.apache.calcite.util.NlsString)9 RelNode (org.apache.calcite.rel.RelNode)8 SqlUpdate (org.apache.calcite.sql.SqlUpdate)8 SqlBasicCall (org.apache.calcite.sql.SqlBasicCall)7 SqlWriter (org.apache.calcite.sql.SqlWriter)7 SqlParserPos (org.apache.calcite.sql.parser.SqlParserPos)7 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)6