Corvin Kuebler created CALCITE-6583:
---------------------------------------
Summary: Case Statement reformulation in JdbcAdapter
Key: CALCITE-6583
URL: https://issues.apache.org/jira/browse/CALCITE-6583
Project: Calcite
Issue Type: Bug
Components: core, jdbc-adapter
Affects Versions: 1.37.0
Reporter: Corvin Kuebler
Hey @all!
We encountered some strange behavior when working with the JdbcAdapter.
The following test in JdbcAdapterTests shows the issue:
{code:java}
@Test void testReformulatesCaseStatements() throws Exception {
CalciteAssert.model(JdbcTest.SCOTT_MODEL)
.query("SELECT\n" +
" \"EMPNO\"\n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" \"EMPNO\",\n" +
" (\n" +
" CASE\n" +
" WHEN \"EMPNO\" = CAST(? AS INT)\n" +
" THEN CAST(? AS INT)\n" +
" ELSE NULL\n" +
" END\n" +
" ) AS \"test-case\"\n" +
" FROM\n" +
" \"EMP\"\n" +
" WHERE\n" +
" \"DEPTNO\" IN (CAST(? AS INT))\n" +
" )\n" +
"WHERE\n" +
" \"test-case\" IN (?)")
.planContains("ELSE NULL");
}
{code}
The case statement contains an else branch that sets the output of the branch
to `null`.
However we encountered the issue that the `ELSE null` is rewritten to `ELSE
FALSE` by calcite.
This only happens for this specific query "configuration" (same filters/etc.)
Could some1 please take a look and tell me if the reformulation is a bug (which
it is imho).
BR,
Corvin
--
This message was sent by Atlassian Jira
(v8.20.10#820010)