繁体   English   中英

亚马逊雅典娜创建带有分区的请求

[英]amazon athena create request with partitions

我创建一个具有以下分区的表:首先按年,月和日。

问题:我希望获得12/2017和03/2018的数据,我该怎么做? 我认为:

where (year='2017' and month='12') and ( year ='2018' and month='03')

这是正确的吗? 我不会感到困惑,因此Amazon Athena可以获取以下数据:

12/2017 and 03/2018 and 03/2017 and 12/2018 

因为运算符?

PS:我无法测试,我只有免费帐户。 谢谢。

无论如何,我尝试了一组小型数据,但我发现Amazon Athena考虑了括号。

我的测试如下:表的DDl已被分级:

CREATE EXTERNAL TABLE `manyands`(
  `years` int COMMENT 'from deserializer', 
  `months` int COMMENT 'from deserializer', 
  `days` int COMMENT 'from deserializer')
PARTITIONED BY ( 
  `year` string, 
  `month` string)
ROW FORMAT SERDE 
  'org.openx.data.jsonserde.JsonSerDe' 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.mapred.TextInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION
  's3://mybucket/'

我的一组数据测试: 在此处输入图片说明

我的测试:

1- SELECT * FROM "atlasdatabase"."manyands" where month='1'; 我有CSV格式:

"years","months","days","year","month"
"2017","1","21","2017","1"
"2018","1","81","2018","1"

2- SELECT * FROM "atlasdatabase"."manyands" where month='1' and year='2017';

"years","months","days","year","month"
"2017","1","21","2017","1"

3- SELECT * FROM "atlasdatabase"."manyands" where (month='1' and year='2018') and (month='3' and year='2017') ;

empty (Zéro enregistrements renvoyés)

4- SELECT * FROM "atlasdatabase"."manyands" where (month='1' and year='2018') or (month='3' ) ;

"years","months","days","year","month"
"2018","1","81","2018","1"
"2017","3","73","2017","3"
"2018","3","73","2018","3"

结论:在分区的许多实例之间添加OR运算符。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM