|
72 | 72 | import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.node; |
73 | 73 | import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project; |
74 | 74 | import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.singleGroupingSet; |
| 75 | +import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.tableScan; |
75 | 76 | import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.unnest; |
76 | 77 | import static com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values; |
77 | 78 | import static com.facebook.presto.testing.TestingAccessControlManager.TestingPrivilegeType.INSERT_TABLE; |
@@ -2921,6 +2922,46 @@ public void testAutoRefreshMaterializedViewAfterInsertion() |
2921 | 2922 | } |
2922 | 2923 | } |
2923 | 2924 |
|
| 2925 | + public void testMaterializedViewNotRefreshedInNonLegacyMode() |
| 2926 | + { |
| 2927 | + Session nonLegacySession = Session.builder(getSession()) |
| 2928 | + .setSystemProperty("legacy_materialized_views", "false") |
| 2929 | + .build(); |
| 2930 | + try { |
| 2931 | + assertUpdate("CREATE TABLE base_table (id BIGINT, name VARCHAR, part_key BIGINT) WITH (partitioned_by = ARRAY['part_key'])"); |
| 2932 | + assertUpdate("INSERT INTO base_table VALUES (1, 'Alice', 100), (2, 'Bob', 200)", 2); |
| 2933 | + assertUpdate("CREATE MATERIALIZED VIEW simple_mv WITH (partitioned_by = ARRAY['part_key']) AS SELECT id, name, part_key FROM base_table"); |
| 2934 | + |
| 2935 | + assertPlan(nonLegacySession, "SELECT * FROM simple_mv", |
| 2936 | + anyTree(tableScan("base_table"))); |
| 2937 | + } |
| 2938 | + finally { |
| 2939 | + assertUpdate("DROP TABLE base_table"); |
| 2940 | + assertUpdate("DROP MATERIALIZED VIEW simple_mv"); |
| 2941 | + } |
| 2942 | + } |
| 2943 | + |
| 2944 | + @Test |
| 2945 | + public void testMaterializedViewRefreshedInNonLegacyMode() |
| 2946 | + { |
| 2947 | + Session nonLegacySession = Session.builder(getSession()) |
| 2948 | + .setSystemProperty("legacy_materialized_views", "false") |
| 2949 | + .build(); |
| 2950 | + try { |
| 2951 | + assertUpdate("CREATE TABLE base_table (id BIGINT, name VARCHAR, part_key BIGINT) WITH (partitioned_by = ARRAY['part_key'])"); |
| 2952 | + assertUpdate("INSERT INTO base_table VALUES (1, 'Alice', 100), (2, 'Bob', 200)", 2); |
| 2953 | + assertUpdate("CREATE MATERIALIZED VIEW simple_mv WITH (partitioned_by = ARRAY['part_key']) AS SELECT id, name, part_key FROM base_table"); |
| 2954 | + assertUpdate("REFRESH MATERIALIZED VIEW simple_mv where part_key > 0", 2); |
| 2955 | + |
| 2956 | + assertPlan(nonLegacySession, "SELECT * FROM simple_mv", |
| 2957 | + anyTree(tableScan("simple_mv"))); |
| 2958 | + } |
| 2959 | + finally { |
| 2960 | + assertUpdate("DROP TABLE base_table"); |
| 2961 | + assertUpdate("DROP MATERIALIZED VIEW simple_mv"); |
| 2962 | + } |
| 2963 | + } |
| 2964 | + |
2924 | 2965 | private void setReferencedMaterializedViews(DistributedQueryRunner queryRunner, String tableName, List<String> referencedMaterializedViews) |
2925 | 2966 | { |
2926 | 2967 | appendTableParameter(replicateHiveMetastore(queryRunner), |
|
0 commit comments