Error when using CASE statement with constant expression in the WHEN clause in SELECT from virtual schema

Details

Detail name Value
Changelog Number 9470
Type Bug
Status Resolved
Affected Versions Exasol 6.2.4
Fix Versions Exasol 7.0.0, Exasol 6.2.5
Resolution Date 2020-03-11

Problem

A bug is identified that causes a crash in a query that does SELECT on a table through virtual schema if the CASE statement is used with a constant expression in the WHEN clause.

How to reproduce

The following queries can be used to reproduce the scenario.

create schema test;
create or replace table tab1 (i int);

CREATE SCHEMA adapter;
--/
CREATE JAVA ADAPTER SCRIPT adapter.jdbc_adapter AS
  %scriptclass com.exasol.adapter.RequestDispatcher;
  %jar /buckets/testing/jdbc-adapter/virtualschema-jdbc-adapter.jar;
  %jar /buckets/internal/jdbc/EXASOL/exajdbc.jar;
/

create connection sys_connection to 'jdbc:exa:localhost:12902' user 'SYS' identified by 'exasol';

create virtual schema vs using adapter.jdbc_adapter
with connection_name = 'SYS_CONNECTION' 
sql_dialect='EXASOL' schema_name = 'TEST' is_local='true'
--excluded_capabilities='JOIN,JOIN_TYPE_INNER,JOIN_TYPE_LEFT_OUTER,JOIN_TYPE_RIGHT_OUTER,JOIN_TYPE_FULL_OUTER,JOIN_CONDITION_EQUI'
;

select 
    case when true then i end 
from vs.tab1;

Work around

Using a constant expression in the WHEN clause makes the CASE statement obsolete, so user can avoid doing so. 

In case the query is generated from a tool, the customer can create a view over the virtual schema and force it to materialize. The select operation on the materialized view will not cause the error.

Example
create or replace view test.v1 as (select * from vs.tab1 order by false);

select case when true then i end from test.v1;