Fix: Error rather than silently ignore extra parameter passed to ceil/floor#18265
Fix: Error rather than silently ignore extra parameter passed to ceil/floor#18265Jefffrey merged 11 commits intoapache:mainfrom
Conversation
Jefffrey
left a comment
There was a problem hiding this comment.
Could we add a test to lock in this behaviour? (Specifically that if we provide scale or datetime then it throws an error)
Preferably as an SLT, see: https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest
|
Thats a good call, I'll get to it |
|
I added the two basic tests that throw an error if an extra Scale parameter is passed. Please let me know if there are any imporvements I can make |
|
See an example of adding a test that expects to fail: datafusion/datafusion/sqllogictest/test_files/aggregate.slt Lines 203 to 205 in 2a82897
|
|
I hope this is alright. |
alamb
left a comment
There was a problem hiding this comment.
Thank you @toxicteddy00077 and @Jefffrey
I also pushed up a test for the to datetime syntax as well
|
Thanks @toxicteddy00077 |
…/floor (apache#18265) ## Which issue does this PR close? <!-- --> - Closes apache#18175 ## Rationale for this change <!-- --> The Ceil/Floor calls via SQL was being parsed such that they were taking 2 arguments instead of 1, the second of which is not currently needed and the second argument was being ignored and passed silently. ## What changes are included in this PR? <!-- --> The second parameter(`field`) which was being passed if is of the `CeilFloorKind` enum from `sqlparser` crate . Neither of the enum's two variants (`DateTimeField` and `Scale`)are being implemented hence they have been ignored with apporpriate error type and only succeeds if the `DateTimeField` has `NoDateTime` variant i,e it is treated as empty. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> All Unit Tests pass successfully. --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
…/floor (apache#18265) ## Which issue does this PR close? <!-- --> - Closes apache#18175 ## Rationale for this change <!-- --> The Ceil/Floor calls via SQL was being parsed such that they were taking 2 arguments instead of 1, the second of which is not currently needed and the second argument was being ignored and passed silently. ## What changes are included in this PR? <!-- --> The second parameter(`field`) which was being passed if is of the `CeilFloorKind` enum from `sqlparser` crate . Neither of the enum's two variants (`DateTimeField` and `Scale`)are being implemented hence they have been ignored with apporpriate error type and only succeeds if the `DateTimeField` has `NoDateTime` variant i,e it is treated as empty. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> All Unit Tests pass successfully. --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Which issue does this PR close?
Rationale for this change
The Ceil/Floor calls via SQL was being parsed such that they were taking 2 arguments instead of 1, the second of which is not currently needed and the second argument was being ignored and passed silently.
What changes are included in this PR?
The second parameter(
field) which was being passed if is of theCeilFloorKindenum fromsqlparsercrate . Neither of the enum's two variants (DateTimeFieldandScale)are being implemented hence they have been ignored with apporpriate error type and only succeeds if theDateTimeFieldhasNoDateTimevariant i,e it is treated as empty.Are these changes tested?
All Unit Tests pass successfully.