[ 
https://issues.apache.org/jira/browse/CALCITE-6780?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ZheHu updated CALCITE-6780:
---------------------------
    Description: 
When running the following test in SqlOperatorTest,
{code:java}
f.checkString("trim(' aAa ')", "aAa", "VARCHAR(5) NOT NULL");
{code}

it throws "java.lang.StringIndexOutOfBoundsException: begin 8, end 21, length 
17".

The expression "trim(' aAa ')" will be parsed into "trim(both ' ' from ' aAa 
')" (call it TrimFuncCall).
However, when building the above query that extracts all literals as columns in 
an underlying select(in AbstractSqlTester.buildQuery2()), the space literal in 
TrimFuncCall will be extracted, which doesn't exist in the original expression 
"trim(' aAa ')". We just need to extract "' aAa '" in this case, and get
{code:java}
select trim(p0) from (values (' aAa ')) as t(p0)
{code}

  was:
When running the following test in SqlOperatorTest,
{code:java}
f.checkString("trim(' aAa ')", "aAa", "VARCHAR(5) NOT NULL");
{code}

it throws "java.lang.StringIndexOutOfBoundsException: begin 8, end 21, length 
17", which comes from buildQuery2() in AbstractSqlTester.


> CheckerFramework failed to build query for expression TRIM(string)
> ------------------------------------------------------------------
>
>                 Key: CALCITE-6780
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6780
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.38.0
>            Reporter: ZheHu
>            Assignee: ZheHu
>            Priority: Minor
>
> When running the following test in SqlOperatorTest,
> {code:java}
> f.checkString("trim(' aAa ')", "aAa", "VARCHAR(5) NOT NULL");
> {code}
> it throws "java.lang.StringIndexOutOfBoundsException: begin 8, end 21, length 
> 17".
> The expression "trim(' aAa ')" will be parsed into "trim(both ' ' from ' aAa 
> ')" (call it TrimFuncCall).
> However, when building the above query that extracts all literals as columns 
> in an underlying select(in AbstractSqlTester.buildQuery2()), the space 
> literal in TrimFuncCall will be extracted, which doesn't exist in the 
> original expression "trim(' aAa ')". We just need to extract "' aAa '" in 
> this case, and get
> {code:java}
> select trim(p0) from (values (' aAa ')) as t(p0)
> {code}



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

Reply via email to