我的hive中的ods层表是这样存储的:
drop table if exists ods_ipqc_online_tmp;
create external table ods_ipqc_online_tmp
(
`MACH_ID` string COMMENT '机台id',
`MACH_IP` decimal(16, 2) COMMENT '机台ip',
`IPQC_ONLINEID` string COMMENT 'IPQC在线ID',
`CREATE_TIME` string COMMENT '创建时间',
`PROD_SN` string COMMENT '产品sn',
`DOT_ID` string COMMENT '点位id',
`DOT_VALUE` string COMMENT '检测值',
`dt` string COMMENT '时间分区'
) COMMENT 'ipqc临时表'
row format delimited fields terminated by '\t' -- 指定分割符为\t
STORED AS -- 指定存储方式,读数据采用LzoTextInputFormat;输出数据采用TextOutputFormat
INPUTFORMAT 'com.hadoop.mapred.DeprecatedLzoTextInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
location '/warehouse/cut/ods/ods_ipqc_online_tmp/' -- 指定数据在hdfs上的存储位置
;
使用presto连接查询会报错:
Query failed (#20210605_060112_00015_smuct) in hadoop-presto: Unable to create input format com.hadoop.mapred.DeprecatedLzoTextInputFormat
不能直接读取ods的lzo,但是如果你把hadoop-3.1.3/share/hadoop/common/hadoop-lzo-0.4.20.jar复制到presto/plugin/hive-hadoop2里,其他层的 parquet + lzo 是支持查询的。
建表语句如:
drop table if exists dwd_dim_coupon_info;
create external table dwd_dim_coupon_info(
`id` string COMMENT '购物券编号',
`coupon_name` string COMMENT '购物券名称',
`coupon_type` string COMMENT '购物券类型 1 现金券 2 折扣券 3 满减券 4 满件打折券',
`condition_amount` decimal(16,2) COMMENT '满额数',
`condition_num` bigint COMMENT '满件数',
`activity_id` string COMMENT '活动编号',
`benefit_amount` decimal(16,2) COMMENT '减金额',
`benefit_discount` decimal(16,2) COMMENT '折扣',
`create_time` string COMMENT '创建时间',
`range_type` string COMMENT '范围类型 1、商品 2、品类 3、品牌',
`spu_id` string COMMENT '商品id',
`tm_id` string COMMENT '品牌id',
`category3_id` string COMMENT '品类id',
`limit_num` bigint COMMENT '最多领用次数',
`operate_time` string COMMENT '修改时间',
`expire_time` string COMMENT '过期时间'
) COMMENT '优惠券维度表'
PARTITIONED BY (`dt` string)
stored as parquet
location '/warehouse/gmall/dwd/dwd_dim_coupon_info/'
tblproperties ("parquet.compression"="lzo");
解决方案:
新建一张 parquet + lzo 表,将lzo表中数据抽取到新表,即可查询