Repository navigation
dialect(postgresql, oracle): CREATE and DROP MATERIALIZED VIEW - #89
Merged
Merged
Conversation
A materialized view could be read from PostgreSQL and Oracle, but the dialect API had no way to write one: a model that holds one could only be written as an ordinary view. DdlGenerator gains createMaterializedView(view, select, ifNotExists), dropMaterializedView(view, ifExists) and supportsMaterializedViews(), false by default. PostgreSQL writes CREATE MATERIALIZED VIEW [IF NOT EXISTS] and DROP MATERIALIZED VIEW [IF EXISTS]; Oracle writes the same with its defaults, built at once and refreshed on demand, and IF [NOT] EXISTS from 23 on. SQL Server's indexed views and ClickHouse's materialized views, which feed a table from the rows inserted into another, keep no query result of their own and are not taken for materialized views; MySQL, MariaDB, H2, DuckDB, SQLite, Derby, Hive, Impala and the ANSI dialect have none. The consistency tests now cover Hive and Impala too and check the statements of every dialect. On PostgreSQL and Oracle a materialized view is created, holds the rows of its query, is read back by the metadata provider as a materialized view with its query, and is dropped again. The metadata contract creates one where the database has them and expects the provider to report it. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A materialized view could be read from PostgreSQL and Oracle, but the dialect API had no way to write one: a model that holds one could only be written as an ordinary view.
What changes
DdlGeneratorgains:Optional<String> createMaterializedView(TableReference view, String selectSql, boolean ifNotExists)Optional<String> dropMaterializedView(TableReference view, boolean ifExists)boolean supportsMaterializedViews(), false by default; both methods return empty where it is false.CREATE MATERIALIZED VIEW [IF NOT EXISTS],DROP MATERIALIZED VIEW [IF EXISTS]IF [NOT] EXISTSfrom 23 onTests
The consistency tests now cover Hive and Impala too and check the statements of every dialect. On PostgreSQL and Oracle a materialized view is created, holds the rows of its query, is read back by the metadata provider as a materialized view with its query, and is dropped again. The metadata contract creates one where the database has them and expects the provider to report it.