我想知道它是否可以从存储在ORC格式的hadoop文件系统(users.tbl)中的文件创建一个hive表。我读到ORC格式在优化方面比文本好。所以我想知道是否可以使用stored as orc tblproperties
和location
属性创建一个hive表来从hdfs文件创建一个表,但是采用orc格式。
有点像:
create table if not exists users
(USERID BIGINT,
NAME STRING,
EMAIL STRING,
CITY STRING)
STORED AS ORC TBLPROPERTIES ("orc.compress"="SNAPPY")
LOCATION '/tables/users/users.tbl';
而不是文字:
create table if not exists users
(USERID BIGINT,
NAME STRING,
EMAIL STRING,
CITY STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '/tables/users/users.tbl';
你不能只在一步中做到这一点。 create table语句不处理数据,只指定格式和位置。
我的建议是使用“STORED AS TEXTFILE”创建语句创建时态表,并使用ORC作为存储格式创建最终表(使用空位置)。
然后在“ORC表”中插入时间“文本表”中的所有行。
Insert [overwrite] table orcTable select col1, col2 from textTable;
Insert Overwrite将使用新数据替换表中的所有数据。如果您只想添加新数据,您将使用“插入表...”。
导入后,您可以删除临时“文本表”。
1.在蜂巢中创建一张桌子。
create table MyDB.TEST (
Col1 String,
Col2 String,
Col3 String,
Col4 String)
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat';
2.将数据加载到表中。
LOAD DATA INPATH '/hdfs/dir/folder/to/orc/files/' INTO TABLE MyDB.TEST;
只需在现有数据上创建表格,如下所示
CREATE EXTERNAL TABLE mytable
(
col1 bigint,
col2 bigint
)
STORED AS ORC
location '<ORC File location';
请参阅此链接
https://community.hortonworks.com/questions/179897/hive-table-creation-from-orc-format-file.html