Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Function "explode" doesn't work in Beeline

avatar
New Contributor

Creating table like this:

 

create table testexplode(name string, childs array<string>, amap map<string, string>)
row format delimited
fields terminated by '\t'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n'
stored as textfile;

 



Inserting date sets

 

zhangsan child1,child2,child3,child4 k1:v1,k2:v2
lisi child5,child6,child7,child8 k3:v3,k4:v4

 


Querying like this:

 

select explode(childs) from testexplode;

 


This query is fine in hive CLI, but in Beeline, it returns error. Why it fails in Beeline?

 

Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.

 

1 REPLY 1

avatar
Contributor

@useryy2 I have tried the same query in Hive-3.1.3000.7.1.7.0-551 and did not get any error

+----------------------------------------------------+
|                   createtab_stmt                   |
+----------------------------------------------------+
| CREATE EXTERNAL TABLE `testexplode`(               |
|   `name` string,                                   |
|   `childs` array<string>,                          |
|   `amap` map<string,string>)                       |
| ROW FORMAT SERDE                                   |
|   'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'  |
| WITH SERDEPROPERTIES (                             |
|   'collection.delim'=',',                          |
|   'field.delim'='\t',                              |
|   'line.delim'='\n',                               |
|   'mapkey.delim'=':',                              |
|   'serialization.format'='\t')                     |
| STORED AS INPUTFORMAT                              |
|   'org.apache.hadoop.mapred.TextInputFormat'       |
| OUTPUTFORMAT                                       |
|   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' |
| LOCATION                                           |
|   'hdfs://c1448-xxxx.cloudera.com:8020/warehouse/tablespace/external/hive/testexplode' |
| TBLPROPERTIES (                                    |
|   'bucketing_version'='2',                         |
|   'transient_lastDdlTime'='1646831327')            |
+----------------------------------------------------+

And the query result is 

0: jdbc:hive2://c1448-xxxx.coelab.cloudera.c> select explode(childs) from testexplode;
INFO  : Compiling command(queryId=hive_20220311124936_b4346a2e-121e-4d4c-8c8f-b05ce3cfc4c9): select explode(childs) from testexplode
INFO  : No Stats for default@testexplode, Columns: amap, name, childs
INFO  : Semantic Analysis Completed (retrial = false)
INFO  : Created Hive schema: Schema(fieldSchemas:[FieldSchema(name:col, type:string, comment:null)], properties:null)
INFO  : Completed compiling command(queryId=hive_20220311124936_b4346a2e-121e-4d4c-8c8f-b05ce3cfc4c9); Time taken: 2.262 seconds
INFO  : Executing command(queryId=hive_20220311124936_b4346a2e-121e-4d4c-8c8f-b05ce3cfc4c9): select explode(childs) from testexplode
INFO  : Completed executing command(queryId=hive_20220311124936_b4346a2e-121e-4d4c-8c8f-b05ce3cfc4c9); Time taken: 0.062 seconds
INFO  : OK
+---------+
|   col   |
+---------+
| child1  |
| child2  |
| child3  |
| child4  |
| child5  |
| child6  |
| child7  |
| child8  |
+---------+
8 rows selected (2.626 seconds)

 Could you please try connect beeline with --verbose=true flag and share the complete stack trace to see the exact cause of the problem, also share hive version being used