[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2024-01-02 Thread Martijn Visser (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17802032#comment-17802032
 ] 

Martijn Visser commented on FLINK-32958:


Thanks [~fornaix] !

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


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2024-01-02 Thread Han (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17801993#comment-17801993
 ] 

Han commented on FLINK-32958:
-

[~martijnvisser]  sure.

spark doc: 
[https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-like.html]

> The {{CREATE TABLE}} statement defines a new table using the 
> definition/metadata of an existing table or {*}view{*}.

 

hive doc: 
[https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableLike]

> Before Hive 0.8.0, CREATE TABLE LIKE view_name would make a copy of the view. 
>In Hive 0.8.0 and later releases, CREATE TABLE LIKE view_name creates a table 
>by adopting the schema of view_name (fields and partition columns) using 
>defaults for SerDe and file formats.

 

They all support "CREATE TABLE LIKE VIEW" syntax

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


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2023-10-12 Thread Martijn Visser (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17774393#comment-17774393
 ] 

Martijn Visser commented on FLINK-32958:


[~fornaix] I can't find the "CREATE TABLE LIKE VIEW" in the Hive and Spark 
documentation, can you share the details on that?

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


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2023-08-28 Thread Han (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17759534#comment-17759534
 ] 

Han commented on FLINK-32958:
-

[~yesorno] Yes, CTAS is a good alternative, thanks~

But I still insist on providing CREATE TABLE LIKE VIEW for the convenience of 
users.

Is there any other reason why this syntax cannot be provided?

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


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2023-08-28 Thread Xianxun Ye (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17759521#comment-17759521
 ] 

Xianxun Ye commented on FLINK-32958:


[~fornaix]  I think CTAS syntax may be helpful in your case. 

https://issues.apache.org/jira/browse/FLINK-24567

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


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2023-08-27 Thread Han (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 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)


[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement

2023-08-27 Thread dalongliu (Jira)


[ 
https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17759406#comment-17759406
 ] 

dalongliu commented on FLINK-32958:
---

[~fornaix] Can you explain why we need to support this syntax?

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