risingwavelabs / risingwave

Best-in-class stream processing, analytics, and management. Perform continuous analytics, or build event-driven applications, real-time ETL pipelines, and feature stores in minutes. Unified streaming and batch. PostgreSQL compatible.
https://go.risingwave.com/slack
Apache License 2.0
6.81k stars 565 forks source link

feat: Support TEMPORARY VIEW #9667

Open chenzl25 opened 1 year ago

chenzl25 commented 1 year ago

Is your feature request related to a problem? Please describe.

TEMPORARY VIEW: https://www.postgresql.org/docs/current/sql-createview.html

Some users want to use TEMPORARY VIEW instead of CTE to maintain their streaming SQLs because they have multiple SINKs referring to those VIEWs. Once their streaming queries are created, these VIEWs are no longer needed so we can borrow the syntax from PostgreSQL. By the way, creating a materialized view on temporary views in PostgreSQL is not allowed. If we intend to support TEMPORARY VIEW, we should find a way to display the definition of the materialized view created on temporary views. It seems we need to rewrite the original SQL.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

BugenZhao commented 1 year ago

What about making the temporary view a pure frontend stuff, which is stored in the session context and only used by binders? When we're creating streaming jobs, we can directly expand the SQL in the query and translate it into CTE for definition.

chenzl25 commented 1 year ago

What about making the temporary view a pure frontend stuff, which is stored in the session context and only used by binders? When we're creating streaming jobs, we can directly expand the SQL in the query and translate it into CTE for definition.

Yes. That is also the most practical way I can think.

neverchanje commented 1 year ago

to maintain their streaming SQLs because they have multiple SINKs referring to those VIEWs. Once their streaming queries are created, these VIEWs are no longer needed so we can borrow the syntax from PostgreSQL.

Could you provide some examples here? @chenzl25 Any alternatives to solve this problem?

By the way, creating a materialized view on temporary views in PostgreSQL is not allowed. If we intend to support TEMPORARY VIEW, we should find a way to display the definition of the materialized view created on temporary views.

I feel it's disallowed for a reason. 😂

chenzl25 commented 1 year ago

Could you provide some examples here? @chenzl25 Any alternatives to solve this problem?

Here is the temporary view syntax supported by Flink https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/create/#create-view.

Users can always use CTE as an alternative, but CTE can't be shared between different queries. Users can also use View, but View will exist for a long time (users don't want to see it anymore after they have created sinks).

github-actions[bot] commented 1 year ago

This issue has been open for 60 days with no activity. Could you please update the status? Feel free to continue discussion or close as not planned.

fuyufjh commented 1 year ago

Hi, any updates?

chenzl25 commented 1 year ago

Hi, any updates?

A low-priority issue. We don't intend to support it.

github-actions[bot] commented 2 months ago

This issue has been open for 60 days with no activity.

If you think it is still relevant today, and needs to be done in the near future, you can comment to update the status, or just manually remove the no-issue-activity label.

You can also confidently close this issue as not planned to keep our backlog clean. Don't worry if you think the issue is still valuable to continue in the future. It's searchable and can be reopened when it's time. 😄