zengxl created SPARK-46192:
------------------------------

             Summary: failed to insert the table using the default value of 
union
                 Key: SPARK-46192
                 URL: https://issues.apache.org/jira/browse/SPARK-46192
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.4.1, 3.4.0
            Reporter: zengxl


 

Obtain the following tables and data
{code:java}
create table test_spark(k string default null,v int default null) stored as orc;
create table test_spark_1(k string default null,v int default null) stored as 
orc;
insert into table test_spark_1 values('k1',1),('k2',2),('k3',3);
create table test_spark_2(k string default null,v int default null) stored as 
orc; 
insert into table test_spark_2 values('k3',3),('k4',4),('k5',5);

{code}
Execute the following SQL
{code:java}
insert into table test_spark (k) 
select k from test_spark_1
union
select k from test_spark_2 

{code}
exception:
{code:java}
23/12/01 10:44:25 INFO HiveSessionStateBuilder$$anon$1: here is 
CatalogAndIdentifier23/12/01 10:44:25 INFO HiveSessionStateBuilder$$anon$1: 
here is CatalogAndIdentifier23/12/01 10:44:25 INFO 
HiveSessionStateBuilder$$anon$1: here is CatalogAndIdentifier23/12/01 10:44:26 
INFO Analyzer$ResolveUserSpecifiedColumns: i.userSpecifiedCols.size is 
123/12/01 10:44:26 INFO Analyzer$ResolveUserSpecifiedColumns: 
i.userSpecifiedCols.size is 123/12/01 10:44:26 INFO 
Analyzer$ResolveUserSpecifiedColumns: i.table.output 2 ,resolved :1 , i.query 
123/12/01 10:44:26 INFO Analyzer$ResolveUserSpecifiedColumns: here is 
ResolveUserSpecifiedColumns tableOutoyt: 2---nameToQueryExpr : 1Error in query: 
`default`.`test_spark` requires that the data to be inserted have the same 
number of columns as the target table: target table has 2 column(s) but the 
inserted data has 1 column(s), including 0 partition column(s) having constant 
value(s). {code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to