[
https://issues.apache.org/jira/browse/CALCITE-4590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17894896#comment-17894896
]
Mihai Budiu commented on CALCITE-4590:
--------------------------------------
The converted query is fine, the bug is somewhere in the conversion to
Enumerables.
In particular, the enumerable implementation has this piece of generated code:
{code:java}
if (org.apache.calcite.runtime.SqlFunctions.toBoolean(!input_isNull &&
org.apache.calcite.runtime.SqlFunctions.eq(input_value, "a") || !input_isNull
&& org.apache.calcite.runtime.SqlFunctions.eq(input_value, "abc"))) {
return true;
}
{code}
At this point the string "a " with two spaces has been converted incorrectly
to the string "a".
> Incorrect query result with fixed-length string
> -----------------------------------------------
>
> Key: CALCITE-4590
> URL: https://issues.apache.org/jira/browse/CALCITE-4590
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.26.0
> Reporter: Roman Kondakov
> Assignee: xiong duan
> Priority: Major
>
> Query may return wrong result when fixed-length strings (CHAR(N)) are used in
> OR/IN clause
> {code:java}
> @Test void test() {
> // Passed.
> CalciteAssert.that()
> .query("select * from (values (1, 'a'), (2, 'abc')) where EXPR$1 =
> 'a'")
> .returns("EXPR$0=1; EXPR$1=a \n");
> // Failed. Only "EXPR$0=2; EXPR$1=abc\n" is returned
> CalciteAssert.that()
> .query("select * from (values (1, 'a'), (2, 'abc')) where EXPR$1 =
> 'a' or EXPR$1 = 'abc'")
> .returns("EXPR$0=1; EXPR$1=a \n"
> + "EXPR$0=2; EXPR$1=abc\n");
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)