lincoln-lil commented on code in PR #20359:
URL: https://github.com/apache/flink/pull/20359#discussion_r938582541


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/hint/FlinkHints.java:
##########
@@ -75,4 +85,77 @@ public static Map<String, String> mergeTableOptions(
         newProps.putAll(hints);
         return Collections.unmodifiableMap(newProps);
     }
+
+    public static Optional<String> getTableAlias(RelNode node) {
+        if (node instanceof Hintable) {
+            Hintable aliasNode = (Hintable) node;
+            List<String> aliasNames =
+                    aliasNode.getHints().stream()
+                            .filter(h -> 
h.hintName.equalsIgnoreCase(FlinkHints.HINT_ALIAS))
+                            .flatMap(h -> h.listOptions.stream())
+                            .collect(Collectors.toList());
+            if (aliasNames.size() > 0) {
+                return Optional.of(aliasNames.get(0));
+            } else {
+                if (canTransposeToTableScan(node)) {
+                    return getTableAlias(node.getInput(0));
+                }
+            }
+        }
+        return Optional.empty();
+    }
+
+    public static boolean canTransposeToTableScan(RelNode node) {
+        // TODO support look up join
+        return node instanceof LogicalProject // computed column on table
+                || node instanceof LogicalFilter;
+    }
+
+    /** Returns the qualified name of a table scan, otherwise returns empty. */
+    public static Optional<String> getTableName(RelOptTable table) {
+        if (table == null) {
+            return Optional.empty();
+        }
+        List<String> qualifiedNames = table.getQualifiedName();

Review Comment:
   should use table identifier instead?
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to