Stamatis Zampetakis created CALCITE-4706:
--------------------------------------------
Summary: JDBC adapter generates casts exceeding Redshift's data
types bounds
Key: CALCITE-4706
URL: https://issues.apache.org/jira/browse/CALCITE-4706
Project: Calcite
Issue Type: Bug
Components: core, jdbc-adapter
Affects Versions: 1.27.0
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis
Fix For: 1.28.0
Every DBMS imposes different limitation on supported data types and so does
Redshift.
The Redshift
[documentation|https://docs.aws.amazon.com/redshift/latest/dg/c_Supported_data_types.html]
outlines various limitations around DECIMAL, CHAR, and VARCHAR types.
In some cases the JDBC adapter may generate type casts exceeding the bounds and
leading to runtime errors.
Below some sample queries (executed directly on Redshift) and the respective
error.
{code:sql}
select cast (col1 as varchar(65536)) from test;
{code}
{noformat}
Error: [Amazon](500310) Invalid operation: length for type varchar cannot
exceed 65535; (state=22023,code=500310)
{noformat}
{code:sql}
select cast (col1 as char(65536)) from test;
{code}
{noformat}
Error: [Amazon](500310) Invalid operation: length for type bpchar cannot exceed
4096; (state=22023,code=500310)
{noformat}
{code:sql}
select cast (col2 as decimal(39)) from test;
{code}
{noformat}
Error: [Amazon](500310) Invalid operation: DECIMAL precision 39 must be between
1 and 38; (state=22023,code=500310)
{noformat}
{code:sql}
select cast (col2 as decimal(38,39)) from test;
{code}
{noformat}
Error: [Amazon](500310) Invalid operation: DECIMAL scale 39 must be between 0
and 37; (state=22023,code=500310)
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)