[CARBONDATA-4211] Fix - from xx Insert into select fails if an SQL statement contains...
authorShreelekhyaG <shreelu_gampa@yahoo.com>
Mon, 14 Jun 2021 15:36:16 +0000 (21:06 +0530)
committerakashrn5 <akashnilugal@gmail.com>
Sat, 19 Jun 2021 09:57:48 +0000 (15:27 +0530)
commitd8f7df9d7bab1588583d96a7e1f1dab59b31622f
tree48aa4191ed6c3ac20246292937191f20cd7b0f3f
parentfdd00abb475a1932c07dbe797071533295d602fc
[CARBONDATA-4211] Fix - from xx Insert into select fails if an SQL statement contains multiple inserts

Why is this PR needed?
When multiple inserts with single query is used, it fails from SparkPlan with: java.lang.ClassCastException:
GenericInternalRow cannot be cast to UnsafeRow.
For every successful insert/load we return Segment ID as a row. For multiple inserts also, we are returning
a row containing Segment ID but while processing in spark ClassCastException is thrown.

What changes were proposed in this PR?
When multiple insert query is given, it has Union node in the plan. Based on its presence, made changes
to use flag isMultipleInserts to call class UnionCommandExec and implemented custom sideEffectResult which
converts GenericInternalRow to UnsafeRow and return.

Does this PR introduce any user interface change?
No

Is any new testcase added?
Yes

This closes #4151
integration/spark/src/main/scala/org/apache/spark/sql/CarbonCatalystOperators.scala
integration/spark/src/main/scala/org/apache/spark/sql/execution/strategy/DMLStrategy.scala
integration/spark/src/main/scala/org/apache/spark/sql/hive/CarbonAnalysisRules.scala
integration/spark/src/test/scala/org/apache/carbondata/integration/spark/testsuite/dataload/TestLoadDataGeneral.scala