mustafasrepo opened a new pull request, #3916:
URL: https://github.com/apache/arrow-datafusion/pull/3916
# Support for non-u64 types for Window Bound
# Which issue does this PR close?
This PR closes the #3571 .
# Rationale for this change
With this change we are adding support for queries like below.
```sql
SELECT
COUNT(*) OVER(ORDER BY ts RANGE BETWEEN '1 DAY' PRECEDING AND '1 DAY'
FOLLOWING) as cnt
FROM t
```
# What changes are included in this PR?
- Closing this issue requires support for parsing expressions inside window
frame queries. Hence we have updated sqlparser version.
- `assert_contains` and `assert_not_contains` macros are used in tests at
different places. These macros were duplicated where they were used, we have
moved them under
[https://github.com/synnada-ai/arrow-datafusion/blob/feature/window_bound_scalar/datafusion/common/src/test_util.rs](https://github.com/synnada-ai/arrow-datafusion/blob/feature/window_bound_scalar/datafusion/common/src/test_util.rs)
to prevent code duplication.
- Util codes for datetime arithmetic are moved under
[https://github.com/synnada-ai/arrow-datafusion/blob/feature/window_bound_scalar/datafusion/common/src/scalar.rs](https://github.com/synnada-ai/arrow-datafusion/blob/feature/window_bound_scalar/datafusion/common/src/scalar.rs).
They are reached now with `.add` and `.sub` api of `ScalarValue` enum.
- We removed type coercions between `ScalarValue` types. Arithmetic
operations are done only between same types (for `datetime` types arithmetic
operations are done only with `INTERVAL` types.)
- Previously we were rejecting queries in the form
```sql
SELECT
COUNT(c1) OVER (ORDER BY c2 RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING)
FROM aggregate_test_100
```
during window frame creation. Since we are supporting more reach variants
such as
```sql
SELECT
COUNT(*) OVER(ORDER BY ts RANGE BETWEEN '1 DAY' PRECEDING AND '1 MONTH'
PRECEDING) as cnt
FROM t
```
it is not easy to do rejection during creation. We now do calculations for
whether window frame is valid after physical schema information is available.
Where we can do validation calculation with appropriate types. This doesn’t
change anything for end users.
- sqlparser had also changes in `Expr` type. We have incorporated those
changes. However, possibly they are written with come new capabilities in mind.
We just did bare minimum to support current test suit.
# Are there any user-facing changes?
N.A
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]