danny0405 commented on a change in pull request #8859: 
[FLINK-12905][table-planner] Enable querying CatalogViews in legacy planner
URL: https://github.com/apache/flink/pull/8859#discussion_r350516323
 
 

 ##########
 File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/calcite/FlinkPlannerImpl.scala
 ##########
 @@ -86,34 +84,43 @@ class FlinkPlannerImpl(
   def getOrCreateSqlValidator(): FlinkCalciteSqlValidator = {
     if (validator == null) {
       val catalogReader = catalogReaderSupplier.apply(false)
-      validator = new FlinkCalciteSqlValidator(
-        operatorTable,
-        catalogReader,
-        typeFactory)
-      validator.setIdentifierExpansion(true)
-      // Disable implicit type coercion for now.
-      validator.setEnableTypeCoercion(false)
+      validator = createSqlValidator(catalogReader)
     }
     validator
   }
 
+  private def createSqlValidator(catalogReader: CatalogReader) = {
+    val validator = new FlinkCalciteSqlValidator(
+      operatorTable,
+      catalogReader,
+      typeFactory)
+    validator.setIdentifierExpansion(true)
+    // Disable implicit type coercion for now.
+    validator.setEnableTypeCoercion(false)
+    validator
+  }
+
   def validate(sqlNode: SqlNode): SqlNode = {
-    val catalogReader = catalogReaderSupplier.apply(false)
-    // do pre-validate rewrite.
-    sqlNode.accept(new PreValidateReWriter(catalogReader, typeFactory))
-    // do extended validation.
-    sqlNode match {
-      case node: ExtendedSqlNode =>
-        node.validate()
-      case _ =>
-    }
-    // no need to validate row type for DDL and insert nodes.
-    if (sqlNode.getKind.belongsTo(SqlKind.DDL)
-      || sqlNode.getKind == SqlKind.INSERT) {
-      return sqlNode
-    }
+    val validator = getOrCreateSqlValidator()
+    validateInternal(sqlNode, validator)
+  }
+
+  private def validateInternal(sqlNode: SqlNode, validator: 
FlinkCalciteSqlValidator): SqlNode = {
     try {
 
 Review comment:
   Still name it `validate` ? Just like the 2 `rel` methods.

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

Reply via email to