Refactor is*View ViewReaderUtil methods #18570
Conversation
5ef7b79 to
ef9e1e4
Compare
ef9e1e4 to
42bcd40
Compare
|
(just rebased) |
42bcd40 to
15b8ee1
Compare
There was a problem hiding this comment.
In theory, the old code could replace an MV with a View (see #15622)
There was a problem hiding this comment.
Could we add a test to verify it isn't allowed now ?
There was a problem hiding this comment.
it would be very hard to write such a test. from linked PR desc
This would have only been possible during a rare race condition since the engine also checks that an existing entity is not a MV before calling on the connector to create or replace the view.
There was a problem hiding this comment.
In theory, the old code could replace an MV with a View.
There was a problem hiding this comment.
Could we add a test to verify it isn't allowed now ?
c001569 to
790056a
Compare
|
rebased to resolve logical conflicts |
|
CI happy. please review. |
There was a problem hiding this comment.
Do we have a test verifying that COMMENT ON VIEW doesn't work on an MV ?
There was a problem hiding this comment.
idk. note that i am not changing this. toConnectorViewDefinition(...).orElseThrow on next line throws for anything that's not a view
There was a problem hiding this comment.
Could we add a test to verify it isn't allowed now ?
There was a problem hiding this comment.
Could we add a test to verify it isn't allowed now ?
|
there are conflicts, will rebase |
Just to help review later commits.
The check above excludes everything that does not look like a Presto/Trino view, so the second check looks redundant. This also makes one method parameter redundant, removed.
The method is supposed to get a Trino view that's going to be updated. Its check for `translateHiveViews` was redundant, the calling code is never supposed to operate on a Hive view, regardless of `translateHiveViews` flag. (And if it matter, the `translateHiveViews` condition would probably be negated.) It was probably not user-facing problem as the calling code is likely unreachable when Hive view translation is not enabled. The commit also adds a check that the table object being operated on does not represent a Trino Materialized View. The previously checked `isPrestoView` returns true for both, but the table is supposed to represent ordinary Trino View.
Previously the `isTrinoView` would be true for Trino VIEW or Trino MATERIALIZED VIEW (since `isPrestoView()` returns true for both). This wasn't intentional, the code reserved `isTrinoMaterializedView` variable for MVs. This didn't had any end-user visible effect because the variables are currently later OR-ed.
Just for easier review of subsequent commits.
A "trino view" and "trino materialized view" need separate handling in connectors (regardless what philosophical question whether materialized view is also a view), so let this be expressed on utility function level. This changes - `isTrinoMaterializedView` refactor-only change, no behavioral changes, - `isPrestoView` - deprecated, replaced with `isTrinoView` which returns false for materialized views; `isPrestoView` is equivalent of `isTrinoView || isTrinoMaterializedView`, - `isHiveOrTrinoView` - deprecated, replaced with `isSomeKindOfAView` which still returns true for materialized views (but returns false for Hive's own materialzied view which is treated as an ordinary table by Trino), - `isHiveView` - new method.
790056a to
4ea0a43
Compare
|
will merge if still green |
|
|
||
| String tableType = getTableType(table); | ||
| Map<String, String> parameters = getTableParameters(table); | ||
| if (isPrestoView(parameters) && isHiveOrPrestoView(getTableType(table))) { |
| Table table = getTable(); | ||
|
|
||
| if (isPrestoView(table) && isHiveOrPrestoView(table)) { | ||
| if (isTrinoView(table) || isTrinoMaterializedView(table)) { |
There was a problem hiding this comment.
no, we we allow trino V and MV here (and fail on eg Hive views which are not supported by Iceberg -- they are neither tables or views, so something needs to throw on them)
A "trino view" and "trino materialized view" need separate handling in
connectors (regardless what philosophical question whether materialized
view is also a view), so let this be expressed on utility function
level.
This changes
isTrinoMaterializedViewrefactor-only change, no behavioral changes,isPrestoView- deprecated, replaced withisTrinoViewwhich returnsfalse for materialized views;
isPrestoViewis equivalent ofisTrinoView || isTrinoMaterializedView,isHiveOrTrinoView- deprecated, replaced withisSomeKindOfAViewwhichstill returns true for materialized views (but returns false for
Hive's own materialzied view which is treated as an ordinary table by
Trino),
isHiveView- new method.