-
Notifications
You must be signed in to change notification settings - Fork 65
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
Support LATERAL subqueries. #24
Comments
Isn’t possible to replace to with, for example, WITH clause and JOIN clause? |
I think for really complicated stuff, just import the CSVs into the SQL database of your choice and have your way with them.
I see CSVQ as a tool to do quick and dirty queries on smallish data sets. And that it does excellently.
el
—
Sent from Dr Lisse’s iPad Mini 5
…On 28. Dec 2019, 09:12 +0200, Yuki ***@***.***>, wrote:
Isn’t possible to replace to with, for example, WITH clause and JOIN clause?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Yes, I made csvq for simple confirmations and calculations of data. I’ll fix as much as possible obvious bugs or features that are useful in most cases, but in most cases I think that it will work with existing features. |
Possibly. I'd have to do more research. The following solutions are likely inefficient:
More than CTE and Cross Join suggests that This answer to How to get previous and current row value using recursive CTE? compares solutions using Common Table Expressions, window functions, and |
I highly appreciate that
I don't expect
I'm not yet sure, either, but |
I may do this eventually, but for now I'm exploring what computations I may perform using
I agree. |
Okey, maybe I will implement it, but now the priority is low because it can be done in other ways. |
LATERAL JOIN is now included and released in version 1.13.0. |
I tested a
-- lateral_query1.sql
SELECT user_id, first_order_time, next_order_time, id FROM
(SELECT user_id, min(created_at) AS first_order_time FROM orders GROUP BY user_id) o1
LEFT JOIN LATERAL
(SELECT id, created_at AS next_order_time
FROM orders o2
WHERE o2.user_id = o1.user_id AND created_at > o1.first_order_time
ORDER BY created_at ASC LIMIT 1)
o2 ON true; -- lateral_query2.sql
SELECT user_id, first_order_time, next_order_time, id FROM
(SELECT user_id, min(created_at) AS first_order_time FROM orders GROUP BY user_id) o1
INNER JOIN LATERAL
(SELECT id, created_at AS next_order_time
FROM orders o2
WHERE o2.user_id = o1.user_id AND created_at > o1.first_order_time
ORDER BY created_at ASC LIMIT 1)
o2 ON true;
The resuls of each these queries matches those in PostgreSQL’s LATERAL JOIN. |
From ChangeLog: https://github.com/mithrandie/csvq/releases/v1.13.0 * Support LATERAL join. mithrandie/csvq#24) * Support USING join condition in FULL OUTER JOIN. * Support $XDG_CONFIG_HOME environment variable for configuration files. PR: 246632 Submitted by: vulcan@wired.sh (maintainer) git-svn-id: svn+ssh://svn.freebsd.org/ports/head@536207 35697150-7ecd-e111-bb59-0022644237b5
From ChangeLog: https://github.com/mithrandie/csvq/releases/v1.13.0 * Support LATERAL join. mithrandie/csvq#24) * Support USING join condition in FULL OUTER JOIN. * Support $XDG_CONFIG_HOME environment variable for configuration files. PR: 246632 Submitted by: vulcan@wired.sh (maintainer) git-svn-id: svn+ssh://svn.freebsd.org/ports/head@536207 35697150-7ecd-e111-bb59-0022644237b5
From ChangeLog: https://github.com/mithrandie/csvq/releases/v1.13.0 * Support LATERAL join. mithrandie/csvq#24) * Support USING join condition in FULL OUTER JOIN. * Support $XDG_CONFIG_HOME environment variable for configuration files. PR: 246632 Submitted by: vulcan@wired.sh (maintainer)
Please implement LATERAL subqueries. According to Add LATERAL Joins or CROSS APPLY to Your SQL Tool Chain, SQL:1999 introduced "lateral derived tables". Many popular relational database systems support lateral subqueries:
APPLY
implements lateral subqueries.In PostgreSQL’s LATERAL JOIN, Krzysztof Kempiński explains how LATERAL subqueries work in PostgreSQL 9.3.
The text was updated successfully, but these errors were encountered: