Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop Apache配置单元中的表定义问题_Hadoop_Hive_Mapreduce_Hiveql - Fatal编程技术网

Hadoop Apache配置单元中的表定义问题

Hadoop Apache配置单元中的表定义问题,hadoop,hive,mapreduce,hiveql,Hadoop,Hive,Mapreduce,Hiveql,以下是我在名为temp\u stat的配置单元中推送的数据集: COUNTRY CITY TEMP ---------- -------------------- ----- US Arizona 51.7 US California 56.7 US Bullhead City 51.1 India Jaisalmer

以下是我在名为temp\u stat配置单元中推送的数据集:

COUNTRY    CITY                 TEMP 
---------- -------------------- -----
US         Arizona              51.7 
US         California           56.7 
US         Bullhead City        51.1 
India      Jaisalmer            42.4 
Libya      Aziziya              57.8 
Iran       Lut Desert           70.7 
India      Banda                42.4
当我试图通过选择命令查看数据时,我得到以下数据集:

US,Arizona,51.7         NULL    NULL
US,California,56.7      NULL    NULL
US,Bullhead City,51.1   NULL    NULL
India,Jaisalmer,42.4    NULL    NULL
Libya,Aziziya,57.8      NULL    NULL
Iran,Lut Desert,70.7    NULL    NULL
India,Banda,42.4        NULL    NULL
接下来,我想根据国家对这些记录进行分组,并获取每个国家的最高温度以及城市名称,因此我运行了以下查询:

select country,city,temp
from (
select country,city,temp, 
     row_number() over (partition by country order by temp desc) as part
from temp_stat
) a 
where part = 1
order by country, city;
hiveshell中运行上述查询后,我得到以下结果:

US,Arizona,51.7         NULL    NULL
US,California,56.7      NULL    NULL
US,Bullhead City,51.1   NULL    NULL
India,Jaisalmer,42.4    NULL    NULL
Libya,Aziziya,57.8      NULL    NULL
Iran,Lut Desert,70.7    NULL    NULL
India,Banda,42.4        NULL    NULL
即使我运行内部查询来生成行号,我也会得到所有记录的类似行号。 (类似这样的内容:)

我还尝试了densite\u rank()rank()。没有新结果。表定义有问题吗


所有的帮助将不胜感激

以“,”结尾的字段


您的表定义应该如下所示:

create external table temp_stat
(
    country     string   
   ,city        string          
   ,temp        decimal(11,1)
)
    row format delimited
    fields terminated by ','
;



这就是我的查询没有给出正确输出的原因吗?是的。您的表定义不正确。整行映射到第一列,其他所有列都包含空值。谢谢!桌子确实是个问题。我遵循了你的方法,同样地加载了数据,我的查询运行得很顺利。当我运行以下查询时:从temp_stat中选择country、city、temp、rank()over(按国家划分顺序按temp desc)rank;我得到了相似的排名,虽然它们有不同的城市,但它们的温度相似。请编辑帖子,只留下表定义问题,并为查询问题打开新帖子。将所需结果添加到数据样本中非常重要
create external table temp_stat
(
    country     string   
   ,city        string          
   ,temp        decimal(11,1)
)
    row format delimited
    fields terminated by ','
;
select * from temp_stat;
+---------+---------------+------+
| country |     city      | temp |
+---------+---------------+------+
| US      | Arizona       | 51.7 |
| US      | California    | 56.7 |
| US      | Bullhead City | 51.1 |
| India   | Jaisalmer     | 42.4 |
| Libya   | Aziziya       | 57.8 |
| Iran    | Lut Desert    | 70.7 |
| India   | Banda         | 42.4 |
+---------+---------------+------+