You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Han (Jira)" <ji...@apache.org> on 2024/01/03 02:59:00 UTC
[jira] [Commented] (FLINK-32958) Support VIEW as a source table in CREATE TABLE ... Like statement
[ https://issues.apache.org/jira/browse/FLINK-32958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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<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)