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

Feature Request: Window Function Column Resolution #421

Open
silvercrow08 opened this issue Sep 12, 2023 · 1 comment
Open

Feature Request: Window Function Column Resolution #421

silvercrow08 opened this issue Sep 12, 2023 · 1 comment

Comments

@silvercrow08
Copy link

silvercrow08 commented Sep 12, 2023

This would be super helpful for parsing more advanced SQL select statements, like:

SELECT DATE_TRUNC('month', o.order_date) AS month, c.customer_id, c.customer_name, p.product_name, SUM(oi.quantity * oi.unit_price) AS revenue, ROW_NUMBER() OVER (PARTITION BY DATE_TRUNC('month', o.order_date), c.customer_id ORDER BY SUM(oi.quantity * oi.unit_price) DESC) AS revenue_rank FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.order_date >= '2022-01-01' AND o.order_date <= '2022-12-31' GROUP BY DATE_TRUNC('month', o.order_date), c.customer_id, c.customer_name, p.product_name

Having the last column auto-resolve to 'revenue_rank' would be SUPER helpful.

P.S: Does anyone know of any techniques to do this right now? I'm trying to design a solution from scratch using string indexing, but it's been extremely challenging

@silvercrow08
Copy link
Author

I actually just used a regex to solve this, but having it built-in to the library would be fantastic! I'd imagine it would be a pretty common use-case

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

No branches or pull requests

1 participant