chrisknoll commented on issue #24150: [SPARK-27209][SQL] Split parsing of 
SELECT and INSERT into two top-level rules in the grammar file.
URL: https://github.com/apache/spark/pull/24150#issuecomment-578461718
 
 
   Apologies on crashing the party on this closed PR, but my question relates 
directly to the parsing of INSERT statements:
   
   Related to the [ANSI SQL specification for insert 
syntax](https://en.wikipedia.org/wiki/Insert_(SQL)), could the parsing and 
underlying engine support the syntax of:
   ``` INSERT INTO <table> (<column list>) select <columns list) from 
<otherTable>```
   
   I think I read somewhere that there's some underlying technical detail where 
the columns inserted into SPARK tables must have the selected columns match the 
order of the table definition.  But, if this is the case, isn't' there a place 
in the parser-layer and execution-layer where the parser can translate 
something like:
   
   ```
   insert into someTable (col1,col2)
   select someCol1, someCol2 from otherTable
   ```
   
   Where someTable has 3 columns (col3,col2,col1) (note the order here), the 
query is rewritten and sent to the engine as:
   ```
   insert into someTable
   select null, someCol2, someCol1 from otherTable
   ```
   Note, the reordering and adding of the null column was done based on some 
table metadata on someTable so it knew which columns from the INSERT() map over 
to the columns from the select.
   
   Is this possible? The lack of specifying column values is preventing our 
project from SPARK being a supported platform.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to