[ https://issues.apache.org/jira/browse/IMPALA-2268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Armstrong reassigned IMPALA-2268: ------------------------------------- Assignee: (was: Tim Armstrong) > implicit casting of string to timestamp for functions > ----------------------------------------------------- > > Key: IMPALA-2268 > URL: https://issues.apache.org/jira/browse/IMPALA-2268 > Project: IMPALA > Issue Type: Improvement > Components: Frontend > Affects Versions: Impala 2.2 > Reporter: Bharath Vissapragada > Priority: Minor > Labels: newbie, usability > > Consider date_add() builtin. string is automatically cast to a timestamp. > {code} > select date_add( "1900-01-01", 1 ) ; > Query: select date_add( "1900-01-01", 1 ) > +---------------------------+ > | date_add('1900-01-01', 1) | > +---------------------------+ > | 1900-01-02 00:00:00 | > +---------------------------+ > Fetched 1 row(s) in 0.12s > {code} > However with an "interval" > {code} > select date_add( '1900-01-01', interval 72 days ) ; > Query: select date_add( '1900-01-01', interval 72 days ) > ERROR: AnalysisException: Operand ''1900-01-01'' of timestamp arithmetic > expression 'DATE_ADD('1900-01-01', INTERVAL 72 days)' returns type 'STRING'. > Expected type 'TIMESTAMP'. > {code} > We need to manually cast it to a timestamp, something like, > {code} > select date_add(cast("1900-01-01" as TIMESTAMP), interval 10 days ) ; > Query: select date_add(cast("1900-01-01" as TIMESTAMP), interval 10 days ) > +-------------------------------------------------------------+ > | date_add(cast('1900-01-01' as timestamp), interval 10 days) | > +-------------------------------------------------------------+ > | 1900-01-11 00:00:00 | > +-------------------------------------------------------------+ > Fetched 1 row(s) in 0.02s > {code} > Its convenient to make this behavior consistent across all builtins. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org For additional commands, e-mail: issues-all-h...@impala.apache.org