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

SNOW-1639756: Add support for range_between interval #2164

Open
rwhitten577 opened this issue Aug 26, 2024 · 0 comments
Open

SNOW-1639756: Add support for range_between interval #2164

rwhitten577 opened this issue Aug 26, 2024 · 0 comments
Labels
feature New feature or request

Comments

@rwhitten577
Copy link

What is the current behavior?

RANGE BETWEEN INTERVAL was recently added to Snowflake SQL: https://community.snowflake.com/s/article/How-to-rewrite-a-RANGE-BETWEEN-INTERVAL-query-in-Snowflake

However, Window.range_between currently supports integer arguments for start and end. The new RANGE BETWEEN INTERVAL syntax does not work, unless you do something like convert the order_by timestamp to unix and set start/end to an integer value in seconds.

E.g.:

twenty_four_months_in_seconds = 63115200

window_spec = (
    Window.partition_by("id")
    .order_by(F.unix_timestamp("event_time"))
    .range_between(-twenty_four_months_in_seconds, Window.CURRENT_ROW)
)

What is the desired behavior?

Support non-int arguments for Window.range_between, at least allowing a literal like INTERVAL '24 MONTHS' PRECEDING

window_spec = (
    Window.partition_by("id")
    .order_by(F.unix_timestamp("event_time"))
    .range_between(F.lit("INTERVAL '24 MONTHS' PRECEDING", Window.CURRENT_ROW)
)

How would this improve snowflake-snowpark-python?

Support more flexible window functions and update to latest Snowflake SQL capabilities.

References, Other Background

@rwhitten577 rwhitten577 added the feature New feature or request label Aug 26, 2024
@github-actions github-actions bot changed the title Add support for range_between interval SNOW-1639756: Add support for range_between interval Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant