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

Add support to sort by varchar columns on window functions using RANGE PRECEDING or FOLLOWING #24502

Open
psantos-denodo opened this issue Feb 5, 2025 · 0 comments

Comments

@psantos-denodo
Copy link

Presto is able to execute window functions ordering by a varchar using ROWS PRECEDING/FOLLOWING but it is not able to execute the same window function using RANGE.

-- query using ROWS: Ok

SELECT suppkey, name, nationkey,
    SUM(acctbal) OVER (
      PARTITION BY nationkey
      ORDER BY phone DESC
      ROWS BETWEEN 10 PRECEDING AND 1 FOLLOWING
    )
FROM sf1.supplier;

-- query using RANGE: Window frame of type RANGE PRECEDING or FOLLOWING requires that sort item type be numeric, datetime or interval (actual: varchar(15))

SELECT suppkey, name, nationkey,
    SUM(acctbal) OVER (
      PARTITION BY nationkey
      ORDER BY phone DESC
      RANGE BETWEEN 10 PRECEDING AND 1 FOLLOWING
    )
FROM sf1.supplier;

Expected Behavior or Use Case

Both queries should be supported

Context

Find it during testing, it is not currently affecting a real environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant