Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getColumns for Late binding views #74

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

ssheikin
Copy link
Contributor

@ssheikin ssheikin commented Nov 29, 2022

... where column is a CASE numeric with null

If we have a late binding view defined as example view test_view, the JDBC driver will fail to obtain its schema through the standard JDBC method DatabaseMetaData.getColumns, with the following error: ERROR: invalid input syntax for integer: ""

Testcase:

CREATE OR REPLACE VIEW test_view AS
WITH test_data AS (SELECT 'value1' AS value UNION ALL SELECT 'value2' AS value)
SELECT CASE WHEN value = 'value1' THEN 123.45 END AS numeric_with_null
FROM test_data WITH NO SCHEMA BINDING;

SELECT * FROM test_view;

Initial issue is described in
#45 Some specific field types in late-binding views cause the Redshift JDBC driver to throw an error on the getColumns call when fetching field metadata, but

2.1.0.5
Fix Github issue 45
4c24b47
seems fix some of these cases, but not all.
Specifically, a case statement that produces a mix of numeric and null values still results in an error.

maybe issue was reintroduced with
2.1.0.8
Fix numeric scale issue with Numeric data type of an external table e080dd6

Description

Do not parse not existing precision (as i other parts of existing code)

Motivation and Context

#45 was not fixed completely.

Testing

CREATE OR REPLACE VIEW test_view AS
WITH test_data AS (SELECT 'value1' AS value UNION ALL SELECT 'value2' AS value)
SELECT CASE WHEN value = 'value1' THEN 123.45 END AS numeric_with_null
FROM test_data WITH NO SCHEMA BINDING;

SELECT * FROM test_view;

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG

This section is not appropriate for this project.

License

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

... where column is a CASE numeric with null

If we have a late binding view defined as example view test_view,
the JDBC driver will fail to obtain its schema through the standard JDBC method
`DatabaseMetaData.getColumns`, with the following error:
`ERROR: invalid input syntax for integer: ""`

Testcase:
```
CREATE OR REPLACE VIEW test_view AS
WITH test_data AS (SELECT 'value1' AS value UNION ALL SELECT 'value2' AS value)
SELECT CASE WHEN value = 'value1' THEN 123.45 END AS numeric_with_null
FROM test_data WITH NO SCHEMA BINDING;

SELECT * FROM test_view;
```

Initial issue is described in
aws#45
Some specific field types in late-binding views cause the Redshift JDBC
driver to throw an error on the `getColumns` call when fetching field
metadata, but

2.1.0.5
Fix Github issue 45
4c24b47
seems fix some of these cases, but not all.
Specifically, a case statement that produces a mix of
numeric and null values still results in an error.

maybe issue was reintroduced with
2.1.0.8
Fix numeric scale issue with Numeric data type of an external table
e080dd6
@ssheikin
Copy link
Contributor Author

ssheikin commented Dec 5, 2022

@bhvkshah @Brooke-white @iggarish @hyandell Could you please take a look on this PR?

@bhvkshah
Copy link
Contributor

bhvkshah commented Dec 5, 2022

@ssheikin Thanks for submitting this PR, we will review this and get back to you as soon as we have an update.

@ssheikin
Copy link
Contributor Author

@bhvkshah @Brooke-white Have you got a chance to take a look on this pr?

Copy link
Contributor

@bhvkshah bhvkshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bhvkshah bhvkshah merged commit 64ef72e into aws:master Dec 16, 2022
@kokosing
Copy link

Thank you!

@ssheikin ssheikin deleted the ssheikin/numeric_without_precision branch November 26, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants