[
https://issues.apache.org/jira/browse/IMPALA-1652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17177971#comment-17177971
]
Tim Armstrong commented on IMPALA-1652:
---------------------------------------
The behaviour is still slightly different from hive in some cases -
https://github.com/apache/hive/blob/master/ql/src/test/queries/clientpositive/in_typecheck_char.q#L14
for example.
In Impala it never strips trailing spaces from the string literal (since it's
interpreted as STRING and does not need to be converted as input to the
comparison function).
I think Hive is doing something like interpreting the string literal as a CHAR,
since it's not doing any stripping when it's explicitly cast to a varchar or
string.
{noformat}
0: jdbc:hive2://localhost:11050> select 'expected 2',count(*) from ax where t =
cast('a ' as varchar(10))
;
INFO : Compiling
command(queryId=tarmstrong_20200814105655_6a67df2b-8e85-4a2b-bf4e-4c930a505571):
select 'expect
ed 2',count(*) from ax where t = cast('a ' as varchar(10))
INFO : No Stats for default@ax, Columns: t
INFO : Semantic Analysis Completed (retrial = false)
INFO : Created Hive schema: Schema(fieldSchemas:[FieldSchema(name:_c0,
type:string, comment:null), FieldSchema(n
ame:_c1, type:bigint, comment:null)], properties:null)
INFO : Completed compiling
command(queryId=tarmstrong_20200814105655_6a67df2b-8e85-4a2b-bf4e-4c930a505571);
Time
taken: 0.052 seconds
INFO : Executing
command(queryId=tarmstrong_20200814105655_6a67df2b-8e85-4a2b-bf4e-4c930a505571):
select 'expect
ed 2',count(*) from ax where t = cast('a ' as varchar(10))
INFO : Query ID =
tarmstrong_20200814105655_6a67df2b-8e85-4a2b-bf4e-4c930a505571
INFO : Total jobs = 1
INFO : Launching Job 1 out of 1
INFO : Starting task [Stage-1:MAPRED] in serial mode
INFO : Subscribed to counters: [] for queryId:
tarmstrong_20200814105655_6a67df2b-8e85-4a2b-bf4e-4c930a505571
INFO : Session is already open
INFO : Dag name: select 'expected 2',count(*) ...varchar(10)) (Stage-1)
INFO : Status: Running (Executing on YARN cluster with App id
application_1596124995977_0922)
----------------------------------------------------------------------------------------------
VERTICES MODE STATUS TOTAL COMPLETED RUNNING PENDING
FAILED KILLED
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
VERTICES MODE STATUS TOTAL COMPLETED RUNNING PENDING
FAILED KILLED
----------------------------------------------------------------------------------------------
Map 1 .......... container SUCCEEDED 1 1 0 0
0 0
Reducer 2 ...... container SUCCEEDED 1 1 0 0
0 0
----------------------------------------------------------------------------------------------
VERTICES: 02/02 [==========================>>] 100% ELAPSED TIME: 4.66 s
----------------------------------------------------------------------------------------------
+-------------+------+
| _c0 | _c1 |
+-------------+------+
| expected 2 | 0 |
+-------------+------+
{noformat}
> Fix CHAR datatype: Incorrect results with basic predicate on CHAR typed
> column.
> -------------------------------------------------------------------------------
>
> Key: IMPALA-1652
> URL: https://issues.apache.org/jira/browse/IMPALA-1652
> Project: IMPALA
> Issue Type: Bug
> Components: Backend
> Affects Versions: Impala 2.1, Impala 2.3.0
> Reporter: Alexander Behm
> Priority: Major
> Labels: correctness, downgraded, usability
> Attachments: 8be18d4.diff
>
>
> Repro:
> {code}
> create table foo(col1 char(10));
> insert into foo values (cast('test1' as char(10)));
> select * from foo where col1 = 'test1'; <-- returns an empty result set
> select * from foo where col1 = cast('test1' as char(10)); <-- correctly
> returns 1 row
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]