You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Tim Armstrong (Jira)" <ji...@apache.org> on 2021/02/01 00:40:00 UTC
[jira] [Assigned] (IMPALA-2268) implicit casting of string to
timestamp for functions
[ 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-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org