Search in sources :

Example 1 with HintStrategyTable

use of org.apache.calcite.rel.hint.HintStrategyTable in project flink by apache.

the class SqlToOperationConverter method convertSqlInsert.

/**
 * Convert insert into statement.
 */
private Operation convertSqlInsert(RichSqlInsert insert) {
    // Get sink table name.
    List<String> targetTablePath = ((SqlIdentifier) insert.getTargetTableID()).names;
    // Get sink table hints.
    HintStrategyTable hintStrategyTable = flinkPlanner.config().getSqlToRelConverterConfig().getHintStrategyTable();
    List<RelHint> tableHints = SqlUtil.getRelHint(hintStrategyTable, insert.getTableHints());
    Map<String, String> dynamicOptions = FlinkHints.getHintedOptions(tableHints);
    UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(targetTablePath);
    ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
    ContextResolvedTable contextResolvedTable = catalogManager.getTableOrError(identifier);
    PlannerQueryOperation query = (PlannerQueryOperation) convertValidatedSqlNodeOrFail(flinkPlanner, catalogManager, insert.getSource());
    return new SinkModifyOperation(contextResolvedTable, query, insert.getStaticPartitionKVs(), insert.isOverwrite(), dynamicOptions);
}
Also used : SinkModifyOperation(org.apache.flink.table.operations.SinkModifyOperation) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) ContextResolvedTable(org.apache.flink.table.catalog.ContextResolvedTable) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier) RelHint(org.apache.calcite.rel.hint.RelHint) HintStrategyTable(org.apache.calcite.rel.hint.HintStrategyTable) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Aggregations

HintStrategyTable (org.apache.calcite.rel.hint.HintStrategyTable)1 RelHint (org.apache.calcite.rel.hint.RelHint)1 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)1 ContextResolvedTable (org.apache.flink.table.catalog.ContextResolvedTable)1 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)1 UnresolvedIdentifier (org.apache.flink.table.catalog.UnresolvedIdentifier)1 SinkModifyOperation (org.apache.flink.table.operations.SinkModifyOperation)1