Search in sources :

Example 76 with SqlNodeList

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

the class SqlCreateHiveTable method extractPartColIdentifiers.

// Extract the identifiers from partition col list -- that's what SqlCreateTable expects for
// partition keys
private static SqlNodeList extractPartColIdentifiers(SqlNodeList partCols) {
    if (partCols == null) {
        return null;
    }
    SqlNodeList res = new SqlNodeList(partCols.getParserPosition());
    for (SqlNode node : partCols) {
        SqlTableColumn partCol = (SqlTableColumn) node;
        res.add(partCol.getName());
    }
    return res;
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList) SqlNode(org.apache.calcite.sql.SqlNode) SqlTableColumn(org.apache.flink.sql.parser.ddl.SqlTableColumn)

Example 77 with SqlNodeList

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

the class SqlAlterHiveTableChangeColumn 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());
    }
    writer.keyword("CHANGE COLUMN");
    getOldName().unparse(writer, leftPrec, rightPrec);
    origNewColumn.unparse(writer, leftPrec, rightPrec);
    if (isFirst()) {
        writer.keyword("FIRST");
    }
    if (getAfter() != null) {
        writer.keyword("AFTER");
        getAfter().unparse(writer, leftPrec, rightPrec);
    }
    if (cascade) {
        writer.keyword("CASCADE");
    } else {
        writer.keyword("RESTRICT");
    }
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Example 78 with SqlNodeList

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

the class SqlAlterHiveTableLocation method createPropList.

private static SqlNodeList createPropList(SqlCharStringLiteral location) {
    SqlNodeList res = new SqlNodeList(location.getParserPosition());
    res.add(HiveDDLUtils.toTableOption(SqlCreateHiveTable.TABLE_LOCATION_URI, location, location.getParserPosition()));
    return res;
}
Also used : SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Example 79 with SqlNodeList

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

the class SqlShowPartitions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("SHOW PARTITIONS");
    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 80 with SqlNodeList

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

the class SqlAlterTable 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)

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