[bug](MTMV) Fix the wrong interpretation for NEVER REFRESH (#19800)

This commit is contained in:
Adonis Ling
2023-05-18 23:56:56 +08:00
committed by GitHub
parent dfc4432e83
commit adc5522c9b
2 changed files with 23 additions and 1 deletions

View File

@ -1731,7 +1731,7 @@ opt_mv_refersh_info ::=
:}
| KW_NEVER KW_REFRESH
{:
RESULT = new MVRefreshInfo(false);
RESULT = new MVRefreshInfo(true);
:}
;

View File

@ -512,4 +512,26 @@ public class MultiTableMaterializedViewTest extends TestWithFeService {
+ "INNER JOIN part p ON (p.p_partkey = l.lo_partkey)").execute();
Assertions.assertNull(connectContext.getState().getErrorCode(), connectContext.getState().getErrorMessage());
}
@Test
void testCreateNeverRefreshMaterializedView() throws Exception {
createTable("create table test.t1 (pk int, v1 int sum) aggregate key (pk) "
+ "distributed by hash (pk) buckets 1 properties ('replication_num' = '1');");
createTable("create table test.t2 (pk int, v2 int sum) aggregate key (pk) "
+ "distributed by hash (pk) buckets 1 properties ('replication_num' = '1');");
new StmtExecutor(connectContext, "create materialized view mv "
+ "build immediate never refresh key (mpk) distributed by hash (mpk) "
+ "properties ('replication_num' = '1') "
+ "as select test.t1.pk as mpk from test.t1, test.t2 where test.t1.pk = test.t2.pk").execute();
Assertions.assertNull(connectContext.getState().getErrorCode(), connectContext.getState().getErrorMessage());
ShowExecutor showExecutor = new ShowExecutor(connectContext,
(ShowStmt) parseAndAnalyzeStmt("show create table mv"));
ShowResultSet resultSet = showExecutor.execute();
String result = resultSet.getResultRows().get(0).get(1);
Assertions.assertTrue(result.contains("CREATE MATERIALIZED VIEW `mv`\n"
+ "BUILD IMMEDIATE NEVER REFRESH \n"
+ "KEY(`mpk`)\n"
+ "DISTRIBUTED BY HASH(`mpk`) BUCKETS 10"));
}
}