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


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/delegation/PlannerBase.scala:
##########
@@ -169,17 +171,46 @@ abstract class PlannerBase(
   override def getParser: Parser = {
     if (parser == null || getTableConfig.getSqlDialect != currentDialect) {
       dialectFactory = getDialectFactory
-      parser =
-        dialectFactory.create(new DefaultParserContext(catalogManager, 
plannerContext, executor))
+      parser = dialectFactory.create(
+        new DefaultCalciteContext(catalogManager, getOperationTreeBuilder, 
plannerContext))
     }
     parser
   }
 
+  def getOperationTreeBuilder: OperationTreeBuilder = {
+    OperationTreeBuilderImpl.create(
+      tableConfig,
+      classLoader,
+      functionCatalog.asLookup(f => getParser.parseIdentifier(f)),
+      catalogManager.getDataTypeFactory,
+      (path: String) => getTableReferenceExpression(path),
+      (s: String, inputRowType: RowType, outputType) =>
+        getParser.parseSqlExpression(s, inputRowType, outputType),
+      isStreamingMode
+    )
+  }
+
+  def getTableReferenceExpression(path: String): 
Optional[TableReferenceExpression] = {
+    try {
+      val unresolvedIdentifier = getParser.parseIdentifier(path)
+      val tableIdentifier = 
catalogManager.qualifyIdentifier(unresolvedIdentifier)
+      val optionalTable = catalogManager.getTable(tableIdentifier)
+      if (!optionalTable.isPresent) {
+        Optional.empty()
+      } else {
+        val queryOperation = new SourceQueryOperation(optionalTable.get())
+        Optional.of(ApiExpressionUtils.tableRef(path, queryOperation))
+      }
+    } catch {
+      case _: SqlParserException => Optional.empty()

Review Comment:
   sounds good to create another followup issue to add a related test



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to