Skip to content

RedshiftPreparedStatement#toString generates incorrect Redshift query for query containing filter condition on decimal columns #129

Open
@mayankvadariya

Description

@mayankvadariya

Driver version

Redshift version

PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.79229
but issue doesn't seem to be related to Redshift server.

Client Operating System

mac. but NA for this issue

JAVA/JVM version

openjdk 23.0.1

Table schema

CREATE TABLE test_schema.t_decimal (
    c_decimal numeric(3,1) ENCODE az64
)
DISTSTYLE AUTO;

insert into test_schema.t_decimal values (CAST('10.1' AS decimal(3, 1)));

Problem description

  • Create an object of RedshiftPreparedStatement for SELECT * FROM "test_schema"."t_decimal" WHERE "c_decimal" = 10.1; sql query.
  • Output of RedshiftPreparedStatement.toString() for the above query produces SELECT "c_decimal" FROM "test_schema"."t_decimal" WHERE "c_decimal" = ('10.1'::numeric) output. Ideally it should generate SELECT "c_decimal" FROM "test_schema"."t_decimal" WHERE "c_decimal" = ('10.1'::numeric(3,1))

As we can see that the cast is missing precision ie'10.1'::numeric vs '10.1'::numeric(3,1) leading to no output from the Redshift database(ideally 10.1 row should be returned as an output when numeric(3,1) case is provided)

  1. Expected behaviour: SELECT "c_decimal" FROM "test_schema"."t_decimal" WHERE "c_decimal" = ('10.1'::numeric)
  2. Actual behaviour: SELECT "c_decimal" FROM "test_schema"."t_decimal" WHERE "c_decimal" = ('10.1'::numeric(3,1))
  3. Error message/stack trace:
  4. Any other details that can be helpful:

JDBC trace logs

Reproduction code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions