【发布时间】:2017-06-28 05:15:53
【问题描述】:
我想输入看起来像-
的数据"58;""management"";""married"";""tertiary"";""no"";2143;""yes"";""no"";""unknown"";5;""may"";261;1;-1;0;""unknown"";""no"""
"44;""technician"";""single"";""secondary"";""no"";29;""yes"";""no"";""unknown"";5;""may"";151;1;-1;0;""unknown"";""no"""
"33;""entrepreneur"";""married"";""secondary"";""no"";2;""yes"";""yes"";""unknown"";5;""may"";76;1;-1;0;""unknown"";""no"""
"47;""blue-collar"";""married"";""unknown"";""no"";1506;""yes"";""no"";""unknown"";5;""may"";92;1;-1;0;""unknown"";""no"""
我的创建表语句是 as-
sqlContext.sql("create table dummy11(age int, job string, marital string, education string, default string, housing string, loan string, contact string, month string, day_of_week string, duration int, campaign int, pday int, previous int, poutcome string, emp_var_rate int, cons_price_idx int, cons_conf_idx int, euribor3m int, nr_employed int, y string)row format delimited fields terminated by ';'")
当我运行语句时-
sqlContext.sql("from dummy11 select age").show()
或
sqlContext.sql("from dummy11 select y").show()
它返回 NULL 值而不是正确的值,尽管其他值是可见的
那我该如何纠正呢?
【问题讨论】:
-
你是如何读取数据的?
-
当您考虑您的第一张唱片时;它有 17 个字段(将
;视为 delim),但在您的查询中,您定义了 21 个字段,对吗!! -
sqlContext.sql("load data inpath 'hdfs://user/nikita.jaiswal25_gmail/dataset.csv' into table dummy11")
-
@RaktotpalBordoloi 是的,这是正确的......我如何正确阅读?我也必须声明这些字段,因为我的数据集很大。它只是我用来检查错误的虚拟 4 行。其余数据也可能有 21 个值。这种类型的输入在 Hive 中是否可行。
-
分隔符是必需的,即使这些记录没有任何值 - 在 hive 中。 ----->>> 因此,根据查询,前 17 个字段(来自您定义的 DDL)填充了值;其余部分填充为 NULL。
标签: scala hadoop apache-spark hive hiveql