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

bug(meta): QueryRewriter for rename shall be aware of schemas #19028

Open
xiangjinwu opened this issue Oct 21, 2024 · 2 comments
Open

bug(meta): QueryRewriter for rename shall be aware of schemas #19028

xiangjinwu opened this issue Oct 21, 2024 · 2 comments
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@xiangjinwu
Copy link
Contributor

Describe the bug

The current definition accidentally updates all schemas. See reproduction steps for details.

struct QueryRewriter<'a> {
from: &'a str,
to: &'a str,
}

Error message/log

No error reported, but the meta catalog would contain invalid SQL.

To Reproduce

dev=> create schema a;
CREATE_SCHEMA

dev=> create schema b;
CREATE_SCHEMA

dev=> create table a.foo(f1 int);
CREATE_TABLE

dev=> create table b.foo(f1 int);
CREATE_TABLE

dev=> create materialized view mv as select * from a.foo union all select * from b.foo;
CREATE_MATERIALIZED_VIEW

dev=> alter table a.foo rename to bar;
ALTER_TABLE

dev=> select definition from rw_materialized_views ;
                                           definition                                           
------------------------------------------------------------------------------------------------
 CREATE MATERIALIZED VIEW mv AS SELECT * FROM a.bar AS foo UNION ALL SELECT * FROM b.bar AS foo
(1 row)

Expected behavior

b.foo referenced by mv shall remain unchanged:

dev=> select definition from rw_materialized_views ;
                                           definition                                           
------------------------------------------------------------------------------------------------
 CREATE MATERIALIZED VIEW mv AS SELECT * FROM a.bar AS foo UNION ALL SELECT * FROM b.foo
(1 row)

How did you deploy RisingWave?

No response

The version of RisingWave

No response

Additional context

May not be that common in practice.

@xiangjinwu xiangjinwu added the type/bug Something isn't working label Oct 21, 2024
@github-actions github-actions bot added this to the release-2.2 milestone Oct 21, 2024
@yezizp2012
Copy link
Member

The complexity increases when a catalog is created with search_path set to specific schemas. Since we don't rewrite and persist the schema in the definition, renaming them leads to more inconsistencies. Therefore, it's necessary to also persist the schemas. I will try to fix it.

@fuyufjh
Copy link
Member

fuyufjh commented Oct 28, 2024

Another related issue is select * from table. The table catalogs (columns) might be changed after alter table, so it's better to expand the * to actual columns when exeucuting create mv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants