question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window clause improvements

See original GitHub issue

Two edge cases are not parsed well:

SELECT SUM(x) OVER (PARTITION BY a ORDER BY d ROWS 1 PRECEDING)

and

SELECT SUM(x) OVER (PARTITION BY a ORDER BY date ROWS BETWEEN 1 PRECEDING 1 FOLLOWING)

The first will transpile assuming BETWEEN, the second throws parse error because date is parsed as keyword instead of column name.

https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tobymaocommented, Sep 6, 2022

order by date desc works but not order by date row

1reaction
alippaicommented, Sep 6, 2022

Already did that on my side. Thanks for helping with the workaround. Also managed to find the minimal case producing wrong output for you (in case you need it):

select * from a order by date desc limit 1

this is interpreted as

SELECT * FROM a ORDER BY CAST(desc AS DATE) LIMIT 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

T-SQL Windowing Improvements in SQL Server 2022
In this article I focus on windowing and NULL-related improvements. These include the new WINDOW clause and the windowing NULL treatment ...
Read more >
SQL Server Window Functions Performance Improvement
In this part of the tutorial, we'll learn how we can improve the execution performance of queries using window functions.
Read more >
Fixtures and Improvements Sample Clauses - Law Insider
Fixtures and Improvements. Tenant shall make no alterations, additions or improvements, nor attach fixtures, without Landlords' prior written consent.
Read more >
WINDOW Clause (Sliding Windows) - Amazon Kinesis Data ...
The WINDOW clause for a sliding windowed query specifies the rows over which analytic functions are computed across a group of rows in...
Read more >
Analytic Function Syntax Enhancements (WINDOW, GROUPS ...
This article describes the syntax enhancements to analytic function introduced in Oracle database 21c. Setup; WINDOW Clause; GROUPS Clause ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found