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

Quanlong Huang commented on IMPALA-7784:
----------------------------------------

The mismatch happens in partition pruning in 
[HdfsPartitionPruner#evalBinaryPredicate()|https://github.com/apache/impala/blob/2c54dbe22507661664b39cb76849f794cf4743d6/fe/src/main/java/org/apache/impala/planner/HdfsPartitionPruner.java#L285]:
{code:java}
    if (op == Operator.EQ) {
      // Case: SlotRef = Literal
      Set<Long> ids = partitionValueMap.get(literal);
      if (ids != null) matchingIds.addAll(ids);
      return matchingIds;
    }
{code}
Here literal is StringLiteral(value_=\", needsUnescaping_=true),
while the map key is StringLiteral(value=", needsUnescaping_=true).
partitionValueMap is a TreeMap which uses Object#compareTo to detect equals. To 
fix this, we can modify StringLiteral#compareTo to consider the unescaped value.

> Partition pruning handles escaped strings incorrectly
> -----------------------------------------------------
>
>                 Key: IMPALA-7784
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7784
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 3.0
>            Reporter: Csaba Ringhofer
>            Assignee: Quanlong Huang
>            Priority: Critical
>              Labels: correctness
>
> Repro:
> {code}
> create table tpart (i int) partitioned by (p string)
> insert into tpart partition (p="\"") values (1);
> select  * from tpart where p = "\"";
> Result;
> Fetched 0 row(s)
> select  * from tpart where p = '"';
> Result:
> 1,""""
> {code}
> Hive returns the row for both queries.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to