如何使用Qubole Hive查询从Amazon S3的gz文件中查询数据?

How to query data from gz file of Amazon S3 using Qubole Hive query?

我需要从 gz 获取特定数据。 sql怎么写? 我可以 sql 作为 table 数据库吗?:

  Select * from gz_File_Name where key = 'keyname' limit 10.

但总是返回错误。

您需要在此文件位置(文件夹)上创建外部 Hive table 才能使用 Hive 进行查询。 Hive 将识别 gzip 格式。像这样:

create external table hive_schema.your_table (
col_one string, 
col_two string
)
stored as textfile  --specify your file type, or use serde
LOCATION
  's3://your_s3_path_to_the_folder_where_the_file_is_located'
;

在此处查看有关 Hive table 的手册:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable

准确的说s3 under hood不存储文件夹,s3中包含/s的文件名由Hive等不同工具表示,如文件夹结构。看这里: