如何使用 Qubole Hive 查询从 Amazon S3 的 gz 文件中查询数据? [英] How to query data from gz file of Amazon S3 using Qubole Hive query?
问题描述
我需要从 gz 获取特定数据.sql怎么写?我可以将 sql 作为表数据库吗?:
I need get specific data from gz. how to write the sql? can I just sql as table database?:
Select * from gz_File_Name where key = 'keyname' limit 10.
但它总是返回错误.
推荐答案
您需要在此文件位置(文件夹)上创建 Hive 外部表才能使用 Hive 进行查询.Hive 将识别 gzip 格式.像这样:
You need to create Hive external table over this file location(folder) to be able to query using Hive. Hive will recognize gzip format. Like this:
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
See the manual on Hive table here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable
确切地说,引擎盖下的 s3 不存储文件夹,s3 中包含/s 的文件名由不同的工具(如 Hive)表示,就像文件夹结构一样.请参阅此处:https://stackoverflow.com/a/42877381/2700344
To be precise s3 under the hood does not store folders, filename containing /s in s3 represented by different tools such as Hive like a folder structure. See here: https://stackoverflow.com/a/42877381/2700344
这篇关于如何使用 Qubole Hive 查询从 Amazon S3 的 gz 文件中查询数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!