为什么输出是这样的为什么第二行给出 NULL
第二列中的值 select stack(2,'A',10,date '2015-01-01',1,'B',date '2015-02-02',2)
:
0: jdbc:hive2://sandbox-hdp.hortonworks.com:1> select stack(2,'A',10,date '2015-01-01',1,'B',date '2015-02-02',2) as (col0,col1,col2,col3);
Error: Error while compiling statement: FAILED: UDFArgumentException Argument 2's type (int) should be equal to argument 6's type (date) (state=42000,code=40000)
0: jdbc:hive2://sandbox-hdp.hortonworks.com:1> select stack(2,'A',10,date '2015-01-01',1,'B',20,date '2015-02-02') as (col0,col1,col2,col3);
INFO : Compiling command(queryId=hive_20191225124022_380b3a4c-9870-4f5c-89c8-a696af39f985): select stack(2,'A',10,date '2015-01-01',1,'B',20,date '2015-02-02') as (col0,col1,col2,col3)
INFO : Semantic Analysis Completed (retrial = false)
INFO : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:col0, type:string, comment:null), FieldSchema(name:col1, type:int, comment:null), FieldSchema(name:col2, type:date, comment:null), FieldSchema(name:col3, type:int, comment:null)], properties:null)
INFO : Completed compiling command(queryId=hive_20191225124022_380b3a4c-9870-4f5c-89c8-a696af39f985); Time taken: 0.545 seconds
INFO : Executing command(queryId=hive_20191225124022_380b3a4c-9870-4f5c-89c8-a696af39f985): select stack(2,'A',10,date '2015-01-01',1,'B',20,date '2015-02-02') as (col0,col1,col2,col3)
INFO : Completed executing command(queryId=hive_20191225124022_380b3a4c-9870-4f5c-89c8-a696af39f985); Time taken: 0.006 seconds
INFO : OK
| col0 | col1 | col2 | col3 |
| A | 10 | 2015-01-01 | 1 |
| B | NULL | 2015-02-02 | 1 |
2 rows selected (0.594 seconds)
1条答案
按热度按时间ffvjumwh1#
在hive 1.2中,select语句引发异常:
失败:udfargumentexception参数2的类型(int)应等于参数6的类型(date)
stack(2)的第一个参数表示有两个元组。这些元组应该具有相同的模式。第一个元组:
第二元组:
在“b”之后添加一些int第二列以匹配第一个元组。它可以为null,但应该在第二个元组中。我加了20: