Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive macro bug?

Highlighted

Hive macro bug?

Explorer

I already searched everywhere and could never find a reference to some weird behavior, that I find it hard to believe is a bug.

I've been able to reproduce with example below, not on Hive 1.1 , CDH 5.4:

 

create temporary macro date_to_timestamp(dt string)
     concat(substring(dt,7,4),'-',substring(dt,4,2),'-',substring(dt,1,2));

 

create table source(
   a string,
    b string
)
row format delimited fields terminated by '\t'
stored as textfile;

insert into table source
    values ('01.01.2014','02.02.2015');

select
   date_to_timestamp(a),
   date_to_timestamp(b)
   from source;

 

Aren't you surprised to have return:

 

  _c0 _c1

02015-02-022015-02-02

 

?

 

By contrast

 

select
    concat(substring(a,7,4),'-',substring(a,4,2),'-',substring(a,1,2)),
    concat(substring(b,7,4),'-',substring(b,4,2),'-',substring(b,1,2))
    from source;

 

returns the expected

 

2014-01-012015-02-02

 

What am I doing wrong here ?

 

(Can't set label to CDH 5.4 in the post, but that is the version I'm using)

1 REPLY 1

Re: Hive macro bug?

New Contributor

https://issues.apache.org/jira/browse/HIVE-11432

 

Fixed in Hive 1.3

Back-ported by Cloudera in Hive V1.1-CDH5.7.3 / CDH5.8.3 / CDH5.9.0 and above