-
Notifications
You must be signed in to change notification settings - Fork 554
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
FROM
first in SELECT
statements
#1400
Comments
Oh nice, I had no idea. |
Thanks @adriangb, now I can just make the feature request "support duckdb 'from first' syntax". |
I have a branch that supports this, I'll create a PR when I have time. Some related link |
samuelcolvin
changed the title
Support "leading from" sytnax?
Sep 14, 2024
FROM
first in SELECT
statements
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've had (what I think is) a very clever idea to improve SQL (bare with me, I know that sounds mad 😱).
It's as simple as this: we move the "FROM" clause to the start of select statements, so:
SELECT foo, bar FROM spam
becomesFROM spam SELECT foo, bar
SELECT * FROM my_table
becomesFROM my_table SELECT *
SELECT x FROM my_table WHERE y=1
becomesFROM my_table SELECT x WHERE y=1
SELECT x FROM (select ...) as t
becomesFROM (select ...) as t SELECT x
This has two big advantages:
FROM my_table SELECT a[CURSOR]
FROM users SELECT id, name, created_at
. The point is thatSELECT ... FROM ...
syntax follows some natural language which only puts the "from" at the end to developer suspense, at the cost of less easy understanding, we don't want suspense, we want easeI also think it would make CTEs read much better:
with t as (select 1 as a) from t select a
since usingt
is directly after the CTE.Unlike alternatives to SQL like PRQL and EdgeQL:
SELECT foo, bar FROM spam
still works fine, you just get to useFROM spam SELECT foo, bar
if you likesqlparser-rs
So here's my feature request: an optional flag (
allow_leading_from
) which allows theFROM
clause to come beforeSELECT
. It can even be a feature so it's compiled out for those who don't want it.WDYT?
The text was updated successfully, but these errors were encountered: