JingsongLi opened a new pull request #10989: [FLINK-15840][table-planner-blink] ClassCastException is thrown when use tEnv.from for temp/catalog table URL: https://github.com/apache/flink/pull/10989 ## What is the purpose of the change `TableEnvironment.from/scan(string path)` cannot be used for all temporaryTable and CatalogTable (not DataStreamTable and ConnectorCatalogTable). Of course, it can be bypassed by `TableEnvironment.sqlQuery("select * from t")`, but `from/scan` are very important api of TableEnvironment and pure TableApi can't be used seriously. ## Brief change log The problem is that CatalogSourceTable.toRel wants to get the translator of the compute column. At present, CatalogSourceTable.toRe has two places to call: 1. The parser stage, which passes the correct compute column translator. 2. In the rule optimization stage, the correct compute column translator is not passed in the TableScanRule, so an error is reported. There are two solutions: 1. Don't use ToRelContext to transfer the translators of compute column. Use FlinkContext to transfer so that we can get the correct translators of compute columns at any stage. 2. In CatalogSourceTable.toRel, when there is a compute column and the compute column translator cannot be obtained, an error is reported, and other cases pass normally. The disadvantage of this is that it is currently unable to support compute columns on TableApi. Considering: - No plan to support compute column on TableApi. - Solution #1 changed too much - Solution #1 is also an intermediate version. In the next version, it is considered to separate the compute column translation and complete translation in the parser stage. We consider using solution #2. Another bug is CatalogSourceTable need override explainSourceAsString. Otherwise hep rule optimizer can not distinguish CatalogSourceTable and TableSourceTable. ## Verifying this change `TableScanTest` ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): (yes / **no**) - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**) - The serializers: (yes / **no** / don't know) - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know) - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / **no** / don't know) - The S3 file system connector: (yes / **no** / don't know) ## Documentation - Does this pull request introduce a new feature? (yes / **no**)
---------------------------------------------------------------- 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
