Search in sources :

Example 21 with UnresolvedIdentifier

use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.

the class SqlToOperationConverter method convertDropTable.

// ~ Tools ------------------------------------------------------------------
/**
 * Convert DROP TABLE statement.
 */
private Operation convertDropTable(SqlDropTable sqlDropTable) {
    UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlDropTable.fullTableName());
    ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
    return new DropTableOperation(identifier, sqlDropTable.getIfExists(), sqlDropTable.isTemporary());
}
Also used : UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) DropTableOperation(org.apache.flink.table.operations.ddl.DropTableOperation) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Example 22 with UnresolvedIdentifier

use of org.apache.flink.table.catalog.UnresolvedIdentifier 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)

Example 23 with UnresolvedIdentifier

use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.

the class SqlToOperationConverter method convertShowPartitions.

/**
 * Convert SHOW PARTITIONS statement.
 */
private Operation convertShowPartitions(SqlShowPartitions sqlShowPartitions) {
    UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlShowPartitions.fullTableName());
    ObjectIdentifier tableIdentifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
    LinkedHashMap<String, String> partitionKVs = sqlShowPartitions.getPartitionKVs();
    if (partitionKVs != null) {
        CatalogPartitionSpec partitionSpec = new CatalogPartitionSpec(partitionKVs);
        return new ShowPartitionsOperation(tableIdentifier, partitionSpec);
    }
    return new ShowPartitionsOperation(tableIdentifier, null);
}
Also used : UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) ShowPartitionsOperation(org.apache.flink.table.operations.ShowPartitionsOperation) CatalogPartitionSpec(org.apache.flink.table.catalog.CatalogPartitionSpec) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Example 24 with UnresolvedIdentifier

use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.

the class SqlCreateTableConverter method lookupLikeSourceTable.

private CatalogTable lookupLikeSourceTable(SqlTableLike sqlTableLike) {
    UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlTableLike.getSourceTable().names);
    ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
    ContextResolvedTable lookupResult = catalogManager.getTable(identifier).orElseThrow(() -> new ValidationException(String.format("Source table '%s' of the LIKE clause not found in the catalog, at %s", identifier, sqlTableLike.getSourceTable().getParserPosition())));
    if (!(lookupResult.getTable() instanceof CatalogTable)) {
        throw new ValidationException(String.format("Source table '%s' of the LIKE clause can not be a VIEW, at %s", identifier, sqlTableLike.getSourceTable().getParserPosition()));
    }
    return lookupResult.getTable();
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) ContextResolvedTable(org.apache.flink.table.catalog.ContextResolvedTable) CatalogTable(org.apache.flink.table.catalog.CatalogTable) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier)

Example 25 with UnresolvedIdentifier

use of org.apache.flink.table.catalog.UnresolvedIdentifier in project flink by apache.

the class FunctionCatalogOperatorTable method lookupOperatorOverloads.

@Override
public void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList, SqlNameMatcher nameMatcher) {
    if (opName.isStar()) {
        return;
    }
    final UnresolvedIdentifier identifier = UnresolvedIdentifier.of(opName.names);
    functionCatalog.lookupFunction(identifier).flatMap(resolvedFunction -> convertToSqlFunction(category, resolvedFunction)).ifPresent(operatorList::add);
}
Also used : DataTypeFactory(org.apache.flink.table.catalog.DataTypeFactory) TypeInference(org.apache.flink.table.types.inference.TypeInference) SqlSyntax(org.apache.calcite.sql.SqlSyntax) DeferredTypeFlinkTableFunction(org.apache.flink.table.planner.plan.schema.DeferredTypeFlinkTableFunction) DataType(org.apache.flink.table.types.DataType) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) BuiltInFunctionDefinition(org.apache.flink.table.functions.BuiltInFunctionDefinition) AggregateFunctionDefinition(org.apache.flink.table.functions.AggregateFunctionDefinition) FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) FlinkTypeFactory(org.apache.flink.table.planner.calcite.FlinkTypeFactory) SqlNameMatcher(org.apache.calcite.sql.validate.SqlNameMatcher) SqlIdentifier(org.apache.calcite.sql.SqlIdentifier) TypeConversions.fromLegacyInfoToDataType(org.apache.flink.table.types.utils.TypeConversions.fromLegacyInfoToDataType) SqlOperator(org.apache.calcite.sql.SqlOperator) FunctionKind(org.apache.flink.table.functions.FunctionKind) Nullable(javax.annotation.Nullable) TypeStrategies(org.apache.flink.table.types.inference.TypeStrategies) SqlKind(org.apache.calcite.sql.SqlKind) TableFunctionDefinition(org.apache.flink.table.functions.TableFunctionDefinition) ScalarFunctionDefinition(org.apache.flink.table.functions.ScalarFunctionDefinition) GenericTypeInfo(org.apache.flink.api.java.typeutils.GenericTypeInfo) FunctionDefinition(org.apache.flink.table.functions.FunctionDefinition) SqlOperatorTable(org.apache.calcite.sql.SqlOperatorTable) SqlFunctionCategory(org.apache.calcite.sql.SqlFunctionCategory) ContextResolvedFunction(org.apache.flink.table.catalog.ContextResolvedFunction) HiveAggSqlFunction(org.apache.flink.table.planner.functions.utils.HiveAggSqlFunction) List(java.util.List) SqlFunction(org.apache.calcite.sql.SqlFunction) BridgingSqlAggFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlAggFunction) BridgingSqlFunction(org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction) ValidationException(org.apache.flink.table.api.ValidationException) Optional(java.util.Optional) HiveFunctionUtils.isHiveFunc(org.apache.flink.table.planner.functions.utils.HiveFunctionUtils.isHiveFunc) Internal(org.apache.flink.annotation.Internal) HiveTableSqlFunction(org.apache.flink.table.planner.functions.utils.HiveTableSqlFunction) UserDefinedFunctionUtils(org.apache.flink.table.planner.functions.utils.UserDefinedFunctionUtils) FunctionIdentifier(org.apache.flink.table.functions.FunctionIdentifier) TypeConversions(org.apache.flink.table.types.utils.TypeConversions) Row(org.apache.flink.types.Row) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier)

Aggregations

UnresolvedIdentifier (org.apache.flink.table.catalog.UnresolvedIdentifier)25 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)20 ValidationException (org.apache.flink.table.api.ValidationException)9 ContextResolvedTable (org.apache.flink.table.catalog.ContextResolvedTable)7 CatalogTable (org.apache.flink.table.catalog.CatalogTable)5 LinkedHashMap (java.util.LinkedHashMap)4 ResolvedCatalogTable (org.apache.flink.table.catalog.ResolvedCatalogTable)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 CatalogBaseTable (org.apache.flink.table.catalog.CatalogBaseTable)3 CatalogFunction (org.apache.flink.table.catalog.CatalogFunction)3 CatalogFunctionImpl (org.apache.flink.table.catalog.CatalogFunctionImpl)3 FunctionLanguage (org.apache.flink.table.catalog.FunctionLanguage)3 Optional (java.util.Optional)2 RelHint (org.apache.calcite.rel.hint.RelHint)2 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)2 SqlNode (org.apache.calcite.sql.SqlNode)2 SqlAlterViewAs (org.apache.flink.sql.parser.ddl.SqlAlterViewAs)2