exasol / exasol-virtual-schema

Virtual Schema from Exasol to Exasol
MIT License
1 stars 2 forks source link

"Failed to create transformator" when NULL literal is used with local UNION ALL #124

Open exaSR opened 1 week ago

exaSR commented 1 week ago

(Sorry if any inconsistencies show up, but I have to put this down from memory)

Background

Query

(simplified for reproduction)

select null as X from VIRTUAL_TABLE
UNION ALL
select 1 from dual;

Pushdown

IMPORT INTO ( X decimal(1) ) FROM EXA AT ...
STATEMENT 'select null as x from VIRTUAL_TABLE'

Problem

[Code: 0, SQL State: 42636]  ETL-1299: Failed to create transformator for column=0 (starting from 0 for selected columns) 
[ETL-1202: Not implemented - Transformation for this combination of column types is not possible in this version.
A solution for this problem can be perhaps the conversion in another datatype in the database.
Otherwise please contact support for additional information]

Workaround

Exclude the LITERAL_NULL capability for the virtual schema

Solution (?)

As the pushdown query clearly expects a certain data type here, it should be possible to cast the null value properly:

STATEMENT `select cact(null as decimal(1)) as X ...`

Caveat

This can only apply to null values that are direct literals in the select list...filters, subselects etc. can not be handled (filters with null work differently anyway, subselects are not implemented.)

exaSR commented 1 week ago

Marking Source as "Customer", because it showed up during a live migration project, the Customer found the issue and its workaround (and is content using that). But having an intrinsic fix sounds like a good idea...