Sergey Nuyanzin created CALCITE-7578:
----------------------------------------

             Summary: LIKE with empty ESCAPE might fail with 
StringIndexOutOfBoundsException
                 Key: CALCITE-7578
                 URL: https://issues.apache.org/jira/browse/CALCITE-7578
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Sergey Nuyanzin
            Assignee: Sergey Nuyanzin


If pattern under {{LIKE}} is not {{%}} and {{ESCAPE}} is empty for instance
{code:sql}
'str' LIKE 'a' ESCAPE ''
{code}
Then it fails as 
{noformat}
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:658)
        at org.apache.calcite.rex.RexLiteral.getValueAs(RexLiteral.java:1094)
        at org.apache.calcite.rex.RexSimplify.simplifyLike(RexSimplify.java:532)
        at org.apache.calcite.rex.RexSimplify.simplify(RexSimplify.java:322)
        at 
org.apache.calcite.rex.RexSimplify.simplifyUnknownAs(RexSimplify.java:256)
{noformat}

it should not fail while {{RegSimplify}}, and message should be more human 
friendly



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

Reply via email to