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

[SPARK-42534][SQL][3.4] Fix DB2Dialect Limit clause #40155

Closed
wants to merge 1 commit into from

Conversation

sadikovi
Copy link
Contributor

@sadikovi sadikovi commented Feb 24, 2023

What changes were proposed in this pull request?

The PR fixes DB2 Limit clause syntax. Although DB2 supports LIMIT keyword, it seems that this support varies across databases and versions and the recommended way is to use FETCH FIRST x ROWS ONLY. In fact, some versions don't support LIMIT at all. Doc: https://www.ibm.com/docs/en/db2/11.5?topic=subselect-fetch-clause, usage example: https://www.mullinsconsulting.com/dbu_0502.htm.

Why are the changes needed?

Fixes the incorrect Limit clause which could cause errors when using against DB2 versions that don't support LIMIT.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

I added a unit test and an integration test to cover this functionality.

The PR fixes DB2 Limit clause syntax. Although DB2 supports LIMIT keyword, it seems that this support varies across databases and versions and the recommended way is to use `FETCH FIRST x ROWS ONLY`. In fact, some versions don't support LIMIT at all. Doc: https://www.ibm.com/docs/en/db2/11.5?topic=subselect-fetch-clause, usage example: https://www.mullinsconsulting.com/dbu_0502.htm.

Fixes the incorrect Limit clause which could cause errors when using against DB2 versions that don't support LIMIT.

No.

I added a unit test and an integration test to cover this functionality.

Closes apache#40134 from sadikovi/db2-limit-fix.

Authored-by: Ivan Sadikov <ivan.sadikov@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@github-actions github-actions bot added the SQL label Feb 24, 2023
@sadikovi
Copy link
Contributor Author

@cloud-fan I opened the backport for 3.4 but there is no JDBC query builder commit in 3.4 so one of the tests was removed.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (Pending CIs)

@cloud-fan
Copy link
Contributor

thanks, merging to 3.4!

cloud-fan pushed a commit that referenced this pull request Feb 24, 2023
### What changes were proposed in this pull request?

The PR fixes DB2 Limit clause syntax. Although DB2 supports LIMIT keyword, it seems that this support varies across databases and versions and the recommended way is to use `FETCH FIRST x ROWS ONLY`. In fact, some versions don't support LIMIT at all. Doc: https://www.ibm.com/docs/en/db2/11.5?topic=subselect-fetch-clause, usage example: https://www.mullinsconsulting.com/dbu_0502.htm.

### Why are the changes needed?

Fixes the incorrect Limit clause which could cause errors when using against DB2 versions that don't support LIMIT.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

I added a unit test and an integration test to cover this functionality.

Closes #40155 from sadikovi/db2-limit-fix-3.4.

Authored-by: Ivan Sadikov <ivan.sadikov@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@cloud-fan cloud-fan closed this Feb 24, 2023
snmvaughan pushed a commit to snmvaughan/spark that referenced this pull request Jun 20, 2023
### What changes were proposed in this pull request?

The PR fixes DB2 Limit clause syntax. Although DB2 supports LIMIT keyword, it seems that this support varies across databases and versions and the recommended way is to use `FETCH FIRST x ROWS ONLY`. In fact, some versions don't support LIMIT at all. Doc: https://www.ibm.com/docs/en/db2/11.5?topic=subselect-fetch-clause, usage example: https://www.mullinsconsulting.com/dbu_0502.htm.

### Why are the changes needed?

Fixes the incorrect Limit clause which could cause errors when using against DB2 versions that don't support LIMIT.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

I added a unit test and an integration test to cover this functionality.

Closes apache#40155 from sadikovi/db2-limit-fix-3.4.

Authored-by: Ivan Sadikov <ivan.sadikov@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants