May be you can try this: org.apache.calcite.rel.metadata.RelMetadataQuery#getColumnOrigins But i'm not tested yet. Pls give feedback whether it works or not.
Regards! Aron Tao Armstrong <[email protected]> 于2021年11月3日周三 下午10:09写道: > Hi guys, > Thanks for your time to read this help message. I'm new to Calcite and > reading some codes and examples from calcite Github repo. I'm wandering how > to get the column real name and type from view. > For example, I have some SQL as below. A kafka topic table left join > MySQL table, and use a View join_result_view represent the join result. I > want to get the real column name and data type from this view. > How to get result like this ? "user_id", bigint ; "log_time", bigint > I already try use SqlParse parse these sqls, and get the SqlNode, but > I can't get the real column name and type. Maybe I missed out the correct > method. Hopefully some one can identify the problem, thanks a lot. > > CREATE TABLE user_action_source ( > `user_id` STRING, > `item_id` BIGINT, > `bhv_type` STRING, > `bhv_time` INT, > `play_duration` INT, > `ts` BIGINT, > proc_time as PROCTIME() > ) WITH ( > 'connector' = 'kafka', > 'topic' = 'user_action_log', > 'parallelism' = '5', > 'properties.cluster' = 'asv_cluster', > 'properties.group.id' = 'demo-job', > 'scan.startup.mode' = 'latest-offset', > 'format' = 'json', > 'json.fail-on-missing-field' = 'false', > 'json.ignore-parse-errors' = 'true', > 'scan.manually-commit-offsets-interval' = '5000' > ); > > CREATE TABLE item_source ( > `item_id` BIGINT, > `video_name` STRING, > `video_count` INT, > `video_duration` INT, > `authors` STRING > ) WITH ( > 'connector' = 'jdbc', > 'url' = 'jdbc:mysql://localhost:3306/mydatabase', > 'table-name' = 'item_info' > ); > > create view join_result_view as > select a.user_id, a.item_id, a.bhv_type, a.ts as log_time, b.video_name, > b.video_count, b.video_duration, b.authors > from user_action_source as a left join item_source FOR SYSTEM_TIME AS OF > a.proc_time as b > on a.item_id = b.item_id; >
