mn-mikke commented on issue #23745: [SPARK-26707][SQL] Insertion of a single 
struct into a table
URL: https://github.com/apache/spark/pull/23745#issuecomment-461621842
 
 
   Hi @hvanhovell,
   the problem is caused by the grammar rule for 
[```primaryExpression```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4#L590)
 and two roles of the ```CreateNamedStruct``` expression.
   
   If the inline table has more columns, the 
[```rowConstructor```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4#L601)
 branch is called and plays role of  a container for holding all value 
expressions and propagating them from a call of 
[```visitRowConstructor```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala#L1410)
 to a call of 
[```visitInlineTable```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala#L842)
 where the ```CreateNamedStruct``` expression is removed.
   
   If the inline table has only one column of structs, the  
[```struct```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4#L594)
 branch (optionally via 
[```parenthizedExpression```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4#L612))
 is called and 
[```visitInlineTable```](https://github.com/apache/spark/blob/b4e1d145135445eeed85784dab0c2c088930dd26/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala#L842)
 removes the struct as well and that is **the problem**.
   
   Yeah, maybe a change in the grammar as such will be more convenient... WDYT?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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