-
Notifications
You must be signed in to change notification settings - Fork 3
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
[WIP] Add baseline infrastructure for emulating materialized views #56
base: main
Are you sure you want to change the base?
Conversation
# FIXME: SQLParseException[Target table name must not include a schema] | ||
sql_ddl = f"ALTER TABLE {mview.staging_table_fullname} RENAME TO {mview.table_name}" | ||
logger.info(f"Activating materialized view: {sql_ddl}") | ||
self.store.execute(sa.text(sql_ddl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a ticket in crate/crate, about that currently, you can't rename a table "into a different schema", i.e. it will always be doc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like resolving this issue might not be too difficult. If someone has the capacity to file a corresponding issue at crate/crate, I will appreciate it. /cc @hammerhead, @hlcianfagna 🌻
// we do not support renaming to a different schema, thus the target table identifier must not include a schema
// this is an artificial limitation, technically it can be done
List<String> newIdentParts = node.newName().getParts();
if (newIdentParts.size() > 1) {
throw new IllegalArgumentException("Target table name must not include a schema");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hlcianfagna suggested to use ALTER CLUSTER SWAP TABLE
as a workaround at crate/crate#14833 (comment). Thank you.
# TODO: IF NOT EXISTS | ||
sql_ddl = f"CREATE TABLE {mview.staging_table_fullname} AS (\n{mview.sql}\n)" | ||
logger.info(f"Creating materialized view (staging): {sql_ddl}") | ||
self.store.execute(sa.text(sql_ddl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another spot where I discovered a shortcoming in SQL syntax: CREATE TABLE ... AS ...
does not support the IF NOT EXISTS
infix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We filed a database issue about it.
What the title says. Description will be expanded while we go.