[
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17759420#comment-17759420
]
Han commented on FLINK-32958:
-----------------------------
[~lsy] Sure
# In the above case, we just want to print the table content. It's convenient
to use the CREATE TABLE LIKE statement to copy schema and create a print sink
table. But now if the source table is a view, we had to give up this idea in
frustration;
# Other engines, such as hive and spark, support CREATE TABLE LIKE a view. So
maybe supporting this syntax is not a strange thing.
> Support VIEW as a source table in CREATE TABLE ... Like statement
> -----------------------------------------------------------------
>
> Key: FLINK-32958
> URL: https://issues.apache.org/jira/browse/FLINK-32958
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / Planner
> Affects Versions: 1.17.1
> Reporter: Han
> Priority: Major
> Labels: pull-request-available
>
> We can't create a table from a view through CREATE TABLE LIKE statement
>
> case 1:
> {code:sql}
> create view source_view as select id,val from source;
> create table sink with ('connector' = 'print') like source_view (excluding
> all);
> insert into sink select * from source_view;{code}
> case 2
> {code:java}
> DataStreamSource<Entity> source = ...;
> tEnv.createTemporaryView("source", source);
> tEnv.executeSql("create table sink with ('connector' = 'print') like source
> (excluding all)");
> tEnv.executeSql("insert into sink select * from source");{code}
>
> The above cases will throw an exception:
> {code:java}
> Source table '`default_catalog`.`default_database`.`source`' of the LIKE
> clause can not be a VIEW{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)