Hi. 
Just FYI, I have seen some catalogs are still use deprecated TableSchema in 
flink hive, Iceberg, etc connector. But it's in Flink plan to drop the 
deprecated table schema [1]. In long term, seems use new schema api is a better 
choice. 

If it's for the case of Catalog's createTable method, from the code base [1], 
the passed CatalogBaseTable looks like should be a instance of 
ResolvedCatalogBaseTable with which you can get the resolve schema. From the 
commit history[3], since Flink 1.13, the pased CatalogBaseTable is intance of 
ResolvedCatalogBaseTable. 

I think maybe you can cast it ResolvedCatalogBaseTable and get the resolved 
schema. But please remeber, the cast will fail when the Flink version is lower 
than 1.13 since only from Flink 1.13, the passed CatalogBaseTable is intance of 
ResolvedCatalogBaseTable. 

[1] https://issues.apache.org/jira/browse/FLINK-29072 
[2] 
https://github.com/apache/flink/blob/75a92efd7b35501698e5de253e5231d680830c16/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java#L654
 
[3] [ https://issues.apache.org/jira/browse/FLINK-21396 | 
https://issues.apache.org/jira/browse/FLINK-21396 ] 

Best regards, 
Yuxia 


发件人: "Krzysztof Chmielewski" <krzysiek.chmielew...@gmail.com> 
收件人: "User" <user@flink.apache.org> 
发送时间: 星期六, 2023年 1 月 21日 上午 2:27:25 
主题: Custom catalog implementation - getting table schema for computed columns 

Hi, 
I'm implementing a custom Catalog where for "create table" I need to get tables 
schema, both column names and types from DDL. 

Now the Catalog's createTable method has "CatalogBaseTable table" argument. 
The CatalogBaseTable has a deprecated "getSchema" and suggest to use 
getUnresolvedSchema instead. 

I was able to resolve schema types for physical columns, but I'm struggling 
with computed columns [1]. To be more precise I'm struggling to get//resolve 
the type of this field. 

I see that all implementations that would be needed to resolve inderlying 
expression of UnresolvedComputedColumn are marked as @Internal. 

On the other hand the deprecated "getSchema" has a proper type for this 
ComputedColumn. 

I'm wondering now, what should I do. Should I use the deprecated API that has 
what I need already or should I use suggested API and somehow try to resolve 
the type using @Internal classes which also does not seems safe. 

I would appreciate for any hint here. 

[1] [ 
https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/table/sql/create/#:~:text=BIGINT%2C%20%60name%60%20STRING)-,Computed%20Columns,-Computed%20columns%20are
 | 
https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/table/sql/create/#:~:text=BIGINT%2C%20%60name%60%20STRING)-,Computed%20Columns,-Computed%20columns%20are
 ] 

Reply via email to