hive创建无压缩表data_file和压缩表( SNAPPY、GZIP压缩)data_snappy、data_gzip
hive>
> CREATE TABLE `data_file`(
> `gtime` timestamp,
> `p1` double,
> `p2` double,
> `p3` double)
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY '|';
OK
Time taken: 0.093 seconds
hive>
> CREATE TABLE `data_snappy`(
> `gtime` timestamp,
> `p1` double,
> `p2` double,
> `p3` double)
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY '|'
> STORED AS PARQUET TBLPROPERTIES('parquet.compression'='SNAPPY');
OK
Time taken: 0.158 seconds
hive>
> CREATE TABLE `data_gzip`(
> `gtime` timestamp,
> `p1` double,
> `p2` double,
> `p3` double)
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY '|'
> STORED AS PARQUET TBLPROPERTIES('parquet.compression'='GZIP');
OK
Time taken: 0.083 seconds
hive>
hive>
> insert into data_file values('2020-01-01 12:12:12',12,34,56);
Automatically selecting local only mode for query
Query ID = trafodion_20201223104040_97cd1067-8d24-4d8f-a216-b11b7e3528ee
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Job running in-process (local Hadoop)
2020-12-23 10:40:37,287 Stage-1 map = 100%, reduce = 0%
Ended Job = job_local890267496_0001
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://test01:8020/user/hive/warehouse/data_file/.hive-staging_hive_2020-12-23_10-40-35_073_5079876264378177505-1/-ext-10000
Loading data to table default.data_file
Table default.data_file stats: [numFiles=1, numRows=1, totalSize=35, rawDataSize=34]
MapReduce Jobs Launched:
Stage-Stage-1: HDFS Read: 11846723 HDFS Write: 67480141 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 2.463 seconds
hive> insert into data_snappy values('2020-01-01 12:12:12',12,34,56);
Automatically selecting local only mode for query
Query ID = trafodion_20201223104040_85d2fc2c-a444-414f-b5f1-29e5044399e0
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Job running in-process (local Hadoop)
2020-12-23 10:40:39,231 Stage-1 map = 100%, reduce = 0%
Ended Job = job_local1712514213_0002
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://test01:8020/user/hive/warehouse/data_snappy/.hive-staging_hive_2020-12-23_10-40-37_549_7344523322943058956-1/-ext-10000
Loading data to table default.data_snappy
Table default.data_snappy stats: [numFiles=1, numRows=1, totalSize=623, rawDataSize=4]
MapReduce Jobs Launched:
Stage-Stage-1: HDFS Read: 11846825 HDFS Write: 67480868 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 1.925 seconds
hive> insert into data_gzip values('2020-01-01 12:12:12',12,34,56);
Automatically selecting local only mode for query
Query ID = trafodion_20201223104040_2c0929ed-186b-40cb-8ad8-3789b0bec999
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Job running in-process (local Hadoop)
2020-12-23 10:40:41,028 Stage-1 map = 100%, reduce = 0%
Ended Job = job_local260338895_0003
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://test01:8020/user/hive/warehouse/data_gzip/.hive-staging_hive_2020-12-23_10-40-39_487_3807754108283956395-1/-ext-10000
Loading data to table default.data_gzip
Table default.data_gzip stats: [numFiles=1, numRows=1, totalSize=704, rawDataSize=4]
MapReduce Jobs Launched:
Stage-Stage-1: HDFS Read: 11846929 HDFS Write: 67481674 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 1.781 seconds
hive>
hive> > select * from data_file; OK 2020-01-01 12:12:12 12.0 34.0 56.0 Time taken: 0.129 seconds, Fetched: 1 row(s) hive> select * from data_snappy; OK 2020-01-01 12:12:12 12.0 34.0 56.0 Time taken: 0.127 seconds, Fetched: 1 row(s) hive> select * from data_gzip; OK 2020-01-01 12:12:12 12.0 34.0 56.0 Time taken: 0.107 seconds, Fetched: 1 row(s) hive>
SQL>select * from hive.hive.data_file; GTIME P1 P2 P3 ----------------------------- ------------------------ ------------------------ ------------------------ 2020-01-01 12:12:12.000000000 12.0 34.0 56.0 --- 1 row(s) selected. SQL>select * from hive.hive.data_snappy; GTIME P1 P2 P3 ----------------------------- ------------------------ ------------------------ ------------------------ 2020-01-01 12:12:12.000000000 12.0 34.0 56.0 --- 1 row(s) selected. SQL>select * from hive.hive.data_gzip; GTIME P1 P2 P3 ----------------------------- ------------------------ ------------------------ ------------------------ 2020-01-01 12:12:12.000000000 12.0 34.0 56.0 --- 1 row(s) selected. SQL>
[trafodion@test02 ~]$ hdfs dfs -ls /user/hive/warehouse/data_file Found 1 items -rwxrwxrwx 3 trafodion hive 35 2020-12-23 10:40 /user/hive/warehouse/data_file/000000_0 [trafodion@test02 ~]$ hdfs dfs -ls /user/hive/warehouse/data_gzip Found 1 items -rwxrwxrwx 3 trafodion hive 704 2020-12-23 10:40 /user/hive/warehouse/data_gzip/000000_0 [trafodion@test02 ~]$ hdfs dfs -ls /user/hive/warehouse/data_snappy Found 1 items -rwxrwxrwx 3 trafodion hive 623 2020-12-23 10:40 /user/hive/warehouse/data_snappy/000000_0
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69985104/viewspace-2744668/ ,如需转载,请注明出处,否则将追究法律责任。