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: support logical view #4628

Merged
merged 12 commits into from
Apr 1, 2022
Merged

Conversation

Veeupup
Copy link
Contributor

@Veeupup Veeupup commented Mar 30, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

  • support logical view:

code base:

  • create
  • alter
  • drop
  • read from view

docs

  • docs

test

  • stateless-test

Changelog

  • New Feature

Related Issues

Fixes #4610

Test Plan

Unit Tests

Stateless Tests

@vercel
Copy link

vercel bot commented Mar 30, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/8MbMyK6Z7oqB7JDc4EyzfurXJsXC
✅ Preview: https://databend-git-fork-veeupup-supportview-databend.vercel.app

@mergify
Copy link
Contributor

mergify bot commented Mar 30, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Mar 30, 2022
Veeupup added 2 commits March 31, 2022 14:47
Signed-off-by: Veeupup <code@tanweime.com>
@sundy-li
Copy link
Member

Almost looks good to me, missing some stateless tests .

@Veeupup
Copy link
Contributor Author

Veeupup commented Mar 31, 2022

Almost looks good to me, missing some stateless tests .

ok, I'll write some stateless tests when alter is finished.

Signed-off-by: Veeupup <code@tanweime.com>
@Veeupup Veeupup changed the title feature: support view feature: support logical view Mar 31, 2022
Signed-off-by: Veeupup <code@tanweime.com>
@Veeupup Veeupup marked this pull request as ready for review March 31, 2022 10:22
@Veeupup Veeupup requested a review from BohuTANG as a code owner March 31, 2022 10:22
@Veeupup Veeupup requested review from sundy-li and b41sh March 31, 2022 11:07
@b41sh
Copy link
Member

b41sh commented Mar 31, 2022

need to add some docs for View.

@leiysky
Copy link
Contributor

leiysky commented Mar 31, 2022

What will happen when a table depended by a view get dropped?

@Veeupup
Copy link
Contributor Author

Veeupup commented Mar 31, 2022

it acts as Clickhouse, view just converts query from view table into subquery.
so, if this happens, it'll give error messages just like Clickhouse to tell that the subquery's table not exists. cc @leiysky

# in clickhouse
:) create view view_t1 as select a from t1;
:) drop table t1;
:) select * from view_t1;

SELECT *
FROM view_test

Query id: d3101f4a-2f80-4662-96aa-d3295172bc45


0 rows in set. Elapsed: 0.006 sec.

Received exception from server (version 21.12.1):
Code: 60. DB::Exception: Received from 0.0.0.0:9000. DB::Exception: Table default.t1 doesn't exist. (UNKNOWN_TABLE)
# in databend
databend :) create view view_t1 as select * from t1;
databend :) drop table t1;
databend :) select * from view_t1;

SELECT *
FROM view_t1

Query id: 87fb4594-bd23-4c34-856f-f53f8e6a878b
....
0 rows in set. Elapsed: 0.012 sec.

Received exception from server (version 2021.5.0):
Code: 1025. DB::Exception: Received from 0.0.0.0:9000. DB:Exception. Unknown table 't1'. ()

@sundy-li
Copy link
Member

If Alter/Drop happens to the dependent table, the query from the view may fail.

Users should recreate the view manually.

@leiysky
Copy link
Contributor

leiysky commented Mar 31, 2022

it acts as Clickhouse, view just converts query from view table into subquery.

Make sense.

@Veeupup
Copy link
Contributor Author

Veeupup commented Apr 1, 2022

review resolved. cc @sundy-li @b41sh

Signed-off-by: Veeupup <code@tanweime.com>
@sundy-li
Copy link
Member

sundy-li commented Apr 1, 2022

/LGTM now

@b41sh
Copy link
Member

b41sh commented Apr 1, 2022

/LGTM

@sundy-li sundy-li merged commit 548f90a into databendlabs:main Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Support View Create/Select/Alter
7 participants