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

Discussion: SELECT * EXCEPT syntax #10265

Closed
TennyZhuang opened this issue Jun 9, 2023 · 4 comments
Closed

Discussion: SELECT * EXCEPT syntax #10265

TennyZhuang opened this issue Jun 9, 2023 · 4 comments

Comments

@TennyZhuang
Copy link
Contributor

This is an interesting feature supported by BigQuery. https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax

image

Why do we need that?

The feature is very useful to us since we don't support output rank in the common pattern Group TopN, see https://www.risingwave.dev/docs/current/sql-pattern-topn/

It can be very frustrating if we use the existing syntax and the table has a large number of columns (We've seen about 30-100 columns in user queries).

SELECT c1, c2, c3, c4, c5, c6
  FROM (
    SELECT c1, c2, c3, c4, c5, c6, 
      row_number() OVER (PARTITION BY grp
        ORDER BY sk) AS rank
    FROM t1)
WHERE rank <= N;

If we use * in the outer query, then the query will fail by:

fail to transform overAgg to groupTopN: the rank cannot be included in the outer select_list, see https://www.risingwave.dev/docs/current/sql-pattern-topn/ for more information

If we support the * EXCEPT [column_list] syntax, we can simply write the following query:

SELECT * EXCEPT rank
  FROM (
    SELECT c1, c2, c3, c4, c5, c6, 
      row_number() OVER (PARTITION BY grp
        ORDER BY sk) AS rank
    FROM t1)
WHERE rank <= N;
@github-actions github-actions bot added this to the release-0.20 milestone Jun 9, 2023
@xiangjinwu
Copy link
Contributor

#9092

@TennyZhuang
Copy link
Contributor Author

#9092

In all well-known database, only BigQuery supports that, but they use EXCEPT keyword :(

@st1page
Copy link
Contributor

st1page commented Jun 9, 2023

#9092

In all well-known database, only BigQuery supports that, but they use EXCEPT keyword :(

Sorry it is my typo 🥵 😿

@xxchan
Copy link
Member

xxchan commented Jun 9, 2023

Let's discuss in #9092

@xxchan xxchan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants