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 "ASF subversion and git services (Jira)" <ji...@apache.org> on 2023/06/29 21:15:00 UTC

[jira] [Commented] (IMPALA-10173) Allow implicit casts between numeric and string types when inserting into table

    [ https://issues.apache.org/jira/browse/IMPALA-10173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738788#comment-17738788 ] 

ASF subversion and git services commented on IMPALA-10173:
----------------------------------------------------------

Commit 3247cc683935f078a424a567389fa53764b300d9 in impala's branch refs/heads/master from Peter Rozsa
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=3247cc683 ]

IMPALA-10173: Allow implicit casts between numeric and string types when inserting into table

This patch adds an expiremental query option called ALLOW_UNSAFE_CASTS
which allows implicit casting between some numeric types and string
types. A new type of compatibility is introduced for this purpose, and
the compatibility rule handling is refactored also. The new approach
uses an enum to differentiate the compatibility levels, and to make it
easier to pass them through methods. The unsafe compatibility is used
only in two cases: for set operations and for insert statements. The
insert statements and set operations accept unsafe implicitly casted
expressions only when the source expressions are constant.

The following implicit type casts are enabled in unsafe mode:
  - String -> Float, Double
  - String -> Tinyint, Smallint, Int, Bigint
  - Float, Double -> String
  - Tinyint, Smallint, Int, Bigint -> String

The patch also covers IMPALA-3217, and adds two more rules to handle
implicit casting in set operations and insert statements between string
types:
  - String -> Char(n)
  - String -> Varchar(n)
The unsafe implicit casting requires that the source expression must be
constant in this case as well.

Tests:
  - tests added to AnalyzeExprsTest.java
  - new test class added to test_insert.py

Change-Id: Iee5db2301216c2e088b4b3e4f6cb5a1fd10600f7
Reviewed-on: http://gerrit.cloudera.org:8080/19881
Reviewed-by: Daniel Becker <da...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Allow implicit casts between numeric and string types when inserting into table
> -------------------------------------------------------------------------------
>
>                 Key: IMPALA-10173
>                 URL: https://issues.apache.org/jira/browse/IMPALA-10173
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Frontend
>            Reporter: Tim Armstrong
>            Assignee: Peter Rozsa
>            Priority: Minor
>              Labels: 2023Q1, ramp-up, sql-language, supportability
>
> Impala is somewhat stricter than other engines such as Hive when it comes into implicit casts. This avoids a lot of ambiguity and edge cases with complex SQL, but we could consider loosening it for simple cases like inserting into a table where the meaning/intent is pretty straightforward.
> Repro
> {code}
> CREATE TABLE iobt (   c0 FLOAT ) ;
> INSERT INTO iobt(c0) VALUES ('0'), (1562998803);
> {code}
> Error
> {code}
> AnalysisException: Incompatible return types 'STRING' and 'INT' of exprs ''0'' and '1562998803'.
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org