LadyForest commented on a change in pull request #13011:
URL: https://github.com/apache/flink/pull/13011#discussion_r613949192



##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/catalog/CatalogTableITCase.scala
##########
@@ -985,6 +985,80 @@ class CatalogTableITCase(isStreamingMode: Boolean) extends 
AbstractTestBase {
     assertEquals(false, tableSchema2.getPrimaryKey.isPresent)
   }
 
+  @Test

Review comment:
       That's a good point. I went through 
`TableEnvironmentImpl#createTemporaryView` and found that view is transformed 
to `QueryOperationCatalogView`, and in its constructor, the 
`QueryOperation#asSummaryString` is passed to `originalQuery` and 
`expandedQuery`, which causes this problem. And meanwhile, not all tables 
created by Table API encountered this problem, take 
`org.apache.flink.table.planner.utils.TestTableSourceSinks#createPersonCsvTemporaryTable`
 for example
   
   ```sacla
   def createPersonCsvTemporaryTable(tEnv: TableEnvironment, tableName: 
String): Unit = {
       tEnv.connect(new FileSystem().path(getPersonCsvPath))
         .withFormat(
           new OldCsv()
             .fieldDelimiter("#")
             .lineDelimiter("$")
             .ignoreFirstLine()
             .commentPrefix("%"))
         .withSchema(
           new Schema()
             .field("first", DataTypes.STRING)
             .field("id", DataTypes.INT)
             .field("score", DataTypes.DOUBLE)
             .field("last", DataTypes.STRING))
         .createTemporaryTable(tableName)
     }
   ```
   will generate
   ```sql
   CREATE TEMPORARY TABLE `default_catalog`.`default_database`.`MyTable` (
     `first` STRING,
     `id` INT,
     `score` DOUBLE,
     `last` STRING
   ) WITH (
     'connector.path' = 
'/var/folders/xd/9dp1y4vd3h56kjkvdk426l500000gn/T/csv-test3761923201962233845tmp',
     'connector.property-version' = '1',
     'format.type' = 'csv',
     'format.line-delimiter' = '$',
     'format.ignore-first-line' = 'true',
     'format.property-version' = '1',
     'connector.type' = 'filesystem',
     'format.field-delimiter' = '#',
     'format.comment-prefix' = '%'
   )
   ```
   The reason is that the table created via `ConnectTableDescriptor` is a type 
of `CatalogTableImpl`, which is the same as the one that is created via 
SQL(please correct me if I'm wrong). 
   
   Shall we revisit the decision that throwing an exception for the table which 
is created by Table API? 
   




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


Reply via email to