godfreyhe commented on a change in pull request #8707: [FLINK-12815]
[table-planner-blink] Supports CatalogManager in blink planner
URL: https://github.com/apache/flink/pull/8707#discussion_r295222347
##########
File path:
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/plan/QueryOperationConverter.java
##########
@@ -130,8 +138,39 @@ public RelNode visit(QueryOperation other) {
}
@Override
- public <U> RelNode visit(TableSourceQueryOperation<U>
tableSourceTable) {
- throw new UnsupportedOperationException("Unsupported
now");
+ public <U> RelNode visit(TableSourceQueryOperation<U>
tableSourceOperation) {
+ TableSource<?> tableSource =
tableSourceOperation.getTableSource();
+ boolean isBatch = tableSourceOperation.isBatch();
+ FlinkStatistic statistic;
+ List<String> names;
+ if (tableSourceOperation instanceof
RichTableSourceQueryOperation &&
+ ((RichTableSourceQueryOperation<U>)
tableSourceOperation).getQualifiedName() != null) {
+ statistic = ((RichTableSourceQueryOperation<U>)
tableSourceOperation).getStatistic();
+ names = ((RichTableSourceQueryOperation<U>)
tableSourceOperation).getQualifiedName();
+ } else {
+ statistic = FlinkStatistic.UNKNOWN();
+ // TableSourceScan requires a unique name of a
Table for computing a digest.
+ // We are using the identity hash of the
TableSource object.
+ String refId = "Unregistered_TableSource_" +
System.identityHashCode(tableSource);
+ names = Collections.singletonList(refId);
+ }
+
+ TableSourceTable<?> tableSourceTable = new
TableSourceTable<>(tableSource, !isBatch, statistic);
+ FlinkRelOptTable table = FlinkRelOptTable.create(
+ relBuilder.getRelOptSchema(),
+
tableSourceTable.getRowType(relBuilder.getTypeFactory()),
+ names,
+ tableSourceTable);
+
+ // when LogicalTableScan converts a table scan with
QueryOperationCatalogViewTable to a new table scan
+ // with TableSourceTable, both two table scans have
same digest due to both two tables have
+ // exactly the same table name. so use
EnumerableTableScan instead of LogicalTableScan to
+ // make sure two table scans have different digest.
+ if (createEnumerableTableScan) {
Review comment:
As above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services