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-3217) Allow text quoted by single quotes be treated as a literal value of char/varchar

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

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

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 text quoted by single quotes be treated as a literal value of char/varchar
> --------------------------------------------------------------------------------
>
>                 Key: IMPALA-3217
>                 URL: https://issues.apache.org/jira/browse/IMPALA-3217
>             Project: IMPALA
>          Issue Type: New Feature
>          Components: Frontend
>    Affects Versions: Impala 2.4.0
>            Reporter: Yibing Shi
>            Priority: Minor
>
> Currently, in Impala, a string quoted with single quotes (such as 'abcd') is treated as a literal value of String type. To use it with char/varchar type, an explicit conversion is needed.
> For example, blow query doesn't work:
> {code:sql}
> insert into table tbl (char_col) values ('abcd')
> {code}
> Only below query works:
> {code:sql}
> insert into table tbl (char_col) values ( cast ('abcd' as char(20)))
> {code}
> It does make sense to allow the first query.



--
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