0

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

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

但它总是返回错误。

4

1 回答 1

1

您需要在此文件位置(文件夹)上创建 Hive 外部表才能使用 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 表手册:https ://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable

确切地说,s3 under the hood不存储文件夹,s3中包含/s的文件名由不同的工具(如Hive)表示,就像文件夹结构一样。见这里:https ://stackoverflow.com/a/42877381/2700344

于 2017-03-22T08:05:02.610 回答