You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/09/02 04:17:21 UTC

[jira] [Commented] (PHOENIX-2641) Implicit wildcard in LIKE predicate search pattern

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

ASF GitHub Bot commented on PHOENIX-2641:
-----------------------------------------

Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/200#discussion_r77291213
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java ---
    @@ -517,8 +518,13 @@ public Expression visitLeave(LikeParseNode node, List<Expression> children) thro
                           return new ComparisonExpression(Arrays.asList(lhs,rhs), op);
                       }
                     }
    -            } else if (index == 0 && pattern.length() == 1) {
    -                return IsNullExpression.create(lhs, true, context.getTempPtr());
    +            } else {
    +                byte[] nullExpressionString = new byte[pattern.length()];
    +                byte[] wildcard = {StringUtil.MULTI_CHAR_LIKE};
    +                StringUtil.fill(nullExpressionString, 0, pattern.length(), wildcard, 0, 1, false);
    +                if (pattern.equals(new String (nullExpressionString))) {
    --- End diff --
    
    Can we just check if pattern equals StringUtil.MULTI_CHAR_LIKE here ?


> Implicit wildcard in LIKE predicate search pattern
> --------------------------------------------------
>
>                 Key: PHOENIX-2641
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2641
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.7.0
>         Environment: Phoenix 4.7.0 on Calcite 1.5.0
>            Reporter: Kevin Liew
>            Assignee: Kevin Liew
>              Labels: newbie
>             Fix For: 4.9.0, 4.8.1
>
>
> LIKE predicates have an implicit wildcard at the end of the search pattern
> ie.
> {code:sql}select distinct at1.col2 from at1 group by at1.col2 having at1.col2 like '_'{code}
> will match every cell in col2 whereas it should only match single-character cells.
> This affects both VARCHAR and CHAR.
> Note that selecting by pattern '__' (two single-character wildcards) works properly for VARCHAR but not for CHAR (no result).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)