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

Timo Walther commented on FLINK-18726:
--------------------------------------

Right now, we only support `INSERT INTO t SELECT`. But it would be create to 
select the target columns and just fill the remaining ones with NULL. Esp. 
users with table of 100+ columns would benefit from this. First we need to 
check if the parser is able to support this already. In order to insert the 
NULLs we will need to insert a final projection. I think we are doing this 
already for implicit casts.

In general the stack looks like:

Flink's Calcite parser extensions if we need them: 
flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl

At some point we create a: 
org.apache.flink.table.operations.CatalogSinkModifyOperation

Finally, we go through: org.apache.flink.table.planner.sinks.TableSinkUtils

I would recommend to use a debugger for an INSERT INTO statement and check 
which components we traverse. 

We also need to watch out to not clash with the partitioning syntax explained 
in: org.apache.flink.table.connector.sink.abilities.SupportsPartitioning

At some point we will also need a similar syntax for the Table API (aka 
`Table.executeInsert`), but for now we can focus on SQL.

Thanks for working on this [~atri]. Let me know if you have further questions.



> Support INSERT INTO specific columns
> ------------------------------------
>
>                 Key: FLINK-18726
>                 URL: https://issues.apache.org/jira/browse/FLINK-18726
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Planner
>            Reporter: Caizhi Weng
>            Assignee: Atri Sharma
>            Priority: Major
>
> Currently Flink only supports insert into a table without specifying columns, 
> but most database systems support insert into specific columns by
> {code:sql}
> INSERT INTO table_name(column1, column2, ...) ...
> {code}
> The columns not specified will be filled with default values or {{NULL}} if 
> no default value is given when creating the table.
> As Flink currently does not support default values when creating tables, we 
> can fill the unspecified columns with {{NULL}} and throw exceptions if there 
> are columns with {{NOT NULL}} constraints.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to