I'm using hive Hive 1.0.0-amzn-3, In this version hive creates partitions dynamically, it ignores the type of the partition field type. In my case it creates partitions with leading zero, while field type is Integer.
day_ts=16/hour_ts=05
When I've upgraded hive to Hive 2.1.1-amzn-0 the behavior changed, the new partitions aligned with the type of the field and leading zero removed.
day_ts=16/hour_ts=4
Appreciate any lead to how allow hive 2.1 to keep the leading zero. thanks.
Here is an example
CREATE EXTERNAL TABLE `partitions_hell`(
`a` string COMMENT,
`b` string COMMENT
)
PARTITIONED BY (
`day_ts` bigint,
`hour_ts` int)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
's3://xarkadiy-snbx/partitions_hell'
TBLPROPERTIES (
'orc.compress'='SNAPPY'
)
Run Following query in hive 1.0.0
INSERT INTO TABLE partitions_hell_arkadiy partition(day_ts=16, hour_ts=05)
SELECT '11',
'rwr'
FROM partitions_hell_arkadiy
Run Following query in hive 2.1.0
INSERT INTO TABLE partitions_hell_arkadiy partition(day_ts=16, hour_ts=04)
select '131', 'rw33rr'
from partitions_hell_arkadiy
Result:
hive> show partitions default.partitions_hell
> ;
OK
day_ts=16/hour_ts=05
day_ts=16/hour_ts=4
Time taken: 0.111 seconds, Fetched: 5 row(s)