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

Unparser: numeric values in window frame definition are converted into string literals #12982

Open
sgrebnov opened this issue Oct 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sgrebnov
Copy link
Member

sgrebnov commented Oct 17, 2024

Describe the bug

As pointed here: https://github.com/apache/datafusion/pull/12946/files#r1803027063

window frame definition SUM(id) OVER (PARTITION BY first_name ROWS BETWEEN 5 PRECEDING AND 2 FOLLOWING) is incorrectly unparsed as SUM(id) OVER (PARTITION BY first_name ROWS BETWEEN '5' PRECEDING AND '2' FOLLOWING)

long literals 5 and 2 are converted to string literals '5' and '2'

To Reproduce

The following test can be used

#[test]
fn test_aggregation_to_sql() {
    sql_round_trip(
        GenericDialect {},
        r#"SELECT id, first_name,
        SUM(id) OVER (PARTITION BY first_name ROWS BETWEEN 5 PRECEDING AND 2 FOLLOWING) AS moving_sum
        FROM person
        GROUP BY id, first_name;"#,
        r#"SELECT person.id, person.first_name, SUM(person.id) OVER (PARTITION BY person.first_name ROWS BETWEEN 5 PRECEDING AND 2 FOLLOWING) AS moving_sum FROM person GROUP BY person.id, person.first_name"#,
    );
}

Expected behavior

window frame definition is unparsed correctly

Additional context

https://github.com/apache/datafusion/pull/12946/files#r1803027063

@sgrebnov sgrebnov added the bug Something isn't working label Oct 17, 2024
@sgrebnov sgrebnov changed the title Unparser: numeric values in window frame definition are converted to string literals Unparser: numeric values in window frame definition are converted into string literals Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant