wuchong commented on a change in pull request #12335:
URL: https://github.com/apache/flink/pull/12335#discussion_r435963387



##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
##########
@@ -490,8 +490,11 @@ private void insertIntoInternal(UnresolvedIdentifier 
unresolvedIdentifier, Table
        private Optional<CatalogQueryOperation> 
scanInternal(UnresolvedIdentifier identifier) {
                ObjectIdentifier tableIdentifier = 
catalogManager.qualifyIdentifier(identifier);
 
-               return catalogManager.getTable(tableIdentifier)
-                       .map(t -> new CatalogQueryOperation(tableIdentifier, 
t.getTable().getSchema()));
+               return catalogManager.getTable(tableIdentifier).map(t -> {
+                       CatalogTableSchemaResolver resolver = new 
CatalogTableSchemaResolver(parser);

Review comment:
       We had a long discussion in FLINK-17189 and had a conclusion that the 
TimestampType#kind shoudn't be stored in catalog. IMO, there are several 
reasons: 
   
   1) the metadata stored in catalog should simply store the information of 
DDL. In other words, we should only store the pure DDL into catalog. 
   2) the result datatype of computed column is not trusted, they may changed 
across versions, including `PROCTIME()` and user-defined functions. There are 
some users reported that the result type of `PROCTIME()` should be `TIMESTAMP 
WITH LOCAL TIME ZONE`, not `TIMESTAMP WITHOUT TIME ZONE`.  Users may also 
change their UDF implementation. If we just use the result type stored in 
catalog, there of course will be an exception during code generation or 
runtime, because of type mismatch. 
   3) I don't want to treat proctime attribute and rowtime attribute specially 
when storing them in catalog. They are not different than other computed 
columns and regular columns. 
   
   Thus, we **have to** resolve the result type of computed columns again, when 
we get the `CatalogTable` from catalog. Actually, the initial `CatalogTable` 
get from catalog is a unresovled table (like UnresolvedExpression). That's why 
we need a `CatalogTableShemaResolver` to resolve `CatalogTableSchema`. 
   
   




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