twalthr commented on a change in pull request #6791: [FLINK-8865][sql-client] 
Add CLI query code completion in SQL Client
URL: https://github.com/apache/flink/pull/6791#discussion_r223035081
 
 

 ##########
 File path: 
flink-libraries/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
 ##########
 @@ -233,6 +238,36 @@ public String explainStatement(SessionContext session, 
String statement) throws
                }
        }
 
+       public org.apache.calcite.schema.Table getTable(SessionContext session, 
String name) throws SqlExecutionException {
+               final TableEnvironment tableEnv = 
getOrCreateExecutionContext(session)
+                       .createEnvironmentInstance()
+                       .getTableEnvironment();
+
+               Class<?> clazz = Object.class;
+               if (tableEnv instanceof StreamTableEnvironment) {
+                       StreamTableEnvironment tmpTableEnv = 
(StreamTableEnvironment) tableEnv;
+                       clazz = tmpTableEnv.getClass();
+               } else if (tableEnv instanceof BatchTableEnvironment) {
+                       BatchTableEnvironment tmpTableEnv = 
(BatchTableEnvironment) tableEnv;
+                       clazz = tmpTableEnv.getClass();
+               }
+
+               for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
+                       try {
+                               Method[] methods = clazz.getDeclaredMethods();
+
+                               Method mt = clazz.getDeclaredMethod("getTable", 
String.class);
 
 Review comment:
   Instead of ugly reflection, we should implement a proper solution in the 
table environment.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to