This is an automated email from the ASF dual-hosted git repository.
huajianlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 021f1408738 [refactor](cache) remove entrance of partition cache
(#34830)
021f1408738 is described below
commit 021f14087382caacaba400426c87c52c50785a67
Author: 924060929 <[email protected]>
AuthorDate: Fri May 17 20:45:19 2024 +0800
[refactor](cache) remove entrance of partition cache (#34830)
the partition cache has many bugs and few user use it, so we remove the
entrance of partition cache, and we will refactor it until support mtmv rewrite
function
---
.../main/java/org/apache/doris/common/Config.java | 7 -
.../java/org/apache/doris/qe/SessionVariable.java | 12 -
.../org/apache/doris/qe/cache/CacheAnalyzer.java | 10 +-
.../org/apache/doris/qe/HmsQueryCacheTest.java | 1 -
.../org/apache/doris/qe/OlapQueryCacheTest.java | 516 ---------------------
.../suites/nereids_p0/cache/partition_cache.groovy | 309 ------------
.../suites/query_p0/cache/partition_cache.groovy | 310 -------------
7 files changed, 3 insertions(+), 1162 deletions(-)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index bb34edba48d..8472ec78ad3 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -1303,13 +1303,6 @@ public class Config extends ConfigBase {
@ConfField(mutable = true, masterOnly = false)
public static boolean cache_enable_sql_mode = true;
- /**
- * If set to true, fe will get data from be cache,
- * This option is suitable for real-time updating of partial partitions.
- */
- @ConfField(mutable = true, masterOnly = false)
- public static boolean cache_enable_partition_mode = true;
-
/**
* Minimum interval between last version when caching results,
* This parameter distinguishes between offline and real-time updates
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 7ccbd2790de..a3993421b17 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -139,7 +139,6 @@ public class SessionVariable implements Serializable,
Writable {
public static final String ENABLE_REWRITE_ELEMENT_AT_TO_SLOT =
"enable_rewrite_element_at_to_slot";
public static final String ENABLE_ODBC_TRANSCATION =
"enable_odbc_transcation";
public static final String ENABLE_SQL_CACHE = "enable_sql_cache";
- public static final String ENABLE_PARTITION_CACHE =
"enable_partition_cache";
public static final String ENABLE_COST_BASED_JOIN_REORDER =
"enable_cost_based_join_reorder";
@@ -861,9 +860,6 @@ public class SessionVariable implements Serializable,
Writable {
@VariableMgr.VarAttr(name = ENABLE_SQL_CACHE)
public boolean enableSqlCache = false;
- @VariableMgr.VarAttr(name = ENABLE_PARTITION_CACHE)
- public boolean enablePartitionCache = false;
-
@VariableMgr.VarAttr(name = FORWARD_TO_MASTER)
public boolean forwardToMaster = true;
@@ -2508,14 +2504,6 @@ public class SessionVariable implements Serializable,
Writable {
this.enableSqlCache = enableSqlCache;
}
- public boolean isEnablePartitionCache() {
- return enablePartitionCache;
- }
-
- public void setEnablePartitionCache(boolean enablePartitionCache) {
- this.enablePartitionCache = enablePartitionCache;
- }
-
public int getPartitionedHashJoinRowsThreshold() {
return partitionedHashJoinRowsThreshold;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java
index 47fccfcd37a..c88f3bd13a1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java
@@ -142,11 +142,8 @@ public class CacheAnalyzer {
enableSqlCache = true;
}
}
- if (Config.cache_enable_partition_mode) {
- if (context.getSessionVariable().isEnablePartitionCache()) {
- enablePartitionCache = true;
- }
- }
+ // alread remove the entrance of partition cache, so we force set to
false
+ enablePartitionCache = false;
}
public TUniqueId getQueryId() {
@@ -206,8 +203,7 @@ public class CacheAnalyzer {
}
public static boolean canUseCache(SessionVariable sessionVariable) {
- return (sessionVariable.isEnableSqlCache() ||
sessionVariable.isEnablePartitionCache())
- && commonCacheCondition(sessionVariable);
+ return (sessionVariable.isEnableSqlCache()) &&
commonCacheCondition(sessionVariable);
}
public static boolean canUseSqlCache(SessionVariable sessionVariable) {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/HmsQueryCacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/HmsQueryCacheTest.java
index f342ca697b4..0414b5d1489 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/HmsQueryCacheTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/HmsQueryCacheTest.java
@@ -82,7 +82,6 @@ public class HmsQueryCacheTest extends AnalyzeCheckTestBase {
FeConstants.runningUnitTest = true;
Config.enable_query_hive_views = true;
Config.cache_enable_sql_mode = true;
- Config.cache_enable_partition_mode = true;
connectContext.getSessionVariable().setEnableSqlCache(true);
env = Env.getCurrentEnv();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
index 86a1bc17834..b29a9a4119c 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
@@ -70,7 +70,6 @@ import org.apache.doris.qe.cache.CacheAnalyzer;
import org.apache.doris.qe.cache.CacheAnalyzer.CacheMode;
import org.apache.doris.qe.cache.CacheCoordinator;
import org.apache.doris.qe.cache.CacheProxy;
-import org.apache.doris.qe.cache.PartitionCache;
import org.apache.doris.qe.cache.PartitionRange;
import org.apache.doris.qe.cache.RowBatchBuilder;
import org.apache.doris.qe.cache.SqlCache;
@@ -125,9 +124,7 @@ public class OlapQueryCacheTest {
FrontendOptions.init();
context = new ConnectContext();
Config.cache_enable_sql_mode = true;
- Config.cache_enable_partition_mode = true;
context.getSessionVariable().setEnableSqlCache(true);
- context.getSessionVariable().setEnablePartitionCache(true);
Config.cache_last_version_interval_second = 7200;
} catch (UnknownHostException e) {
@@ -347,15 +344,6 @@ public class OlapQueryCacheTest {
}
}
- private ScanNode createOrderScanNode(Collection<Long>
selectedPartitionIds) {
- OlapTable table = createOrderTable();
- TupleDescriptor desc = new TupleDescriptor(new TupleId(10004));
- desc.setTable(table);
- OlapScanNode node = new OlapScanNode(new PlanNodeId(10008), desc,
"ordernode");
- node.setSelectedPartitionIds(selectedPartitionIds);
- return node;
- }
-
private OlapTable createProfileTable() {
Column column2 = new Column("eventdate", ScalarType.DATE);
Column column3 = new Column("userid", ScalarType.INT);
@@ -610,21 +598,6 @@ public class OlapQueryCacheTest {
Assert.assertEquals(ca.getCacheMode(), CacheMode.None);
}
- @Test
- public void testPartitionModel() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(DISTINCT userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-15\" GROUP BY eventdate"
- );
-
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
- }
-
@Test
public void testParseByte() throws Exception {
RowBatchBuilder sb = new RowBatchBuilder(CacheMode.Partition);
@@ -637,91 +610,6 @@ public class OlapQueryCacheTest {
Assert.assertEquals(key2.realValue(), 3);
}
- @Test
- public void testPartitionIntTypeSql() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT `date`, COUNT(id) FROM `order` WHERE `date`>=20200112
and `date`<=20200115 GROUP BY date"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createOrderScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L);
//2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- hitRange = range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(hitRange, Cache.HitRange.Left);
- Assert.assertEquals(newRangeList.size(), 2);
- Assert.assertEquals(newRangeList.get(0).getCacheKey().realValue(),
20200114);
- Assert.assertEquals(newRangeList.get(1).getCacheKey().realValue(),
20200115);
-
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- Assert.assertEquals(sql, "(`date` >= 20200114) AND (`date` <=
20200115)");
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testSimpleCacheSql() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-15\" GROUP BY eventdate"
- );
-
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
-
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- hitRange = range.buildDiskPartitionRange(newRangeList);
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- Assert.assertEquals(sql, "(`eventdate` >= '2020-01-14') AND
(`eventdate` <= '2020-01-15')");
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
@Test
public void testHitSqlCache() throws Exception {
StatementBase parseStmt = parseSql(
@@ -736,307 +624,6 @@ public class OlapQueryCacheTest {
Assert.assertEquals(ca.getCacheMode(), CacheMode.Sql);
}
- @Test
- public void testHitPartPartition() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-14\" GROUP BY eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1578675600000L); // set now to 2020-01-11 1:00:00,
for hit partition cache
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 3);
-
- range.setCacheFlag(20200113);
- range.setCacheFlag(20200114);
-
- hitRange = range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(hitRange, Cache.HitRange.Right);
- Assert.assertEquals(newRangeList.size(), 2);
- Assert.assertEquals(newRangeList.get(0).getCacheKey().realValue(),
20200112);
- Assert.assertEquals(newRangeList.get(1).getCacheKey().realValue(),
20200112);
-
- List<PartitionRange.PartitionSingle> updateRangeList =
range.buildUpdatePartitionRange();
- Assert.assertEquals(updateRangeList.size(), 1);
-
Assert.assertEquals(updateRangeList.get(0).getCacheKey().realValue(), 20200112);
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testNoUpdatePartition() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-14\" GROUP BY eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1578675600000L); // set now to 2020-01-11 1:00:00,
for hit partition cache
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 3);
-
- range.setCacheFlag(20200112); //get data from cache
- range.setCacheFlag(20200113);
- range.setCacheFlag(20200114);
-
- hitRange = range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(hitRange, Cache.HitRange.Full);
- Assert.assertEquals(newRangeList.size(), 0);
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
-
- @Test
- public void testUpdatePartition() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-15\" GROUP BY eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setTooNewByKey(20200115);
-
- range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(newRangeList.size(), 2);
- cache.rewriteSelectStmt(newRangeList);
-
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- Assert.assertEquals(sql, "(`eventdate` >= '2020-01-13') AND
(`eventdate` <= '2020-01-15')");
-
- List<PartitionRange.PartitionSingle> updateRangeList =
range.buildUpdatePartitionRange();
- Assert.assertEquals(updateRangeList.size(), 2);
-
Assert.assertEquals(updateRangeList.get(0).getCacheKey().realValue(), 20200113);
-
Assert.assertEquals(updateRangeList.get(1).getCacheKey().realValue(), 20200114);
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testRewriteMultiPredicate1() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>\"2020-01-11\" and "
- + "eventdate<\"2020-01-16\""
- + " and eventid=1 GROUP BY eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- LOG.warn("Nokey multi={}",
cache.getNokeyStmt().getWhereClause().toSql());
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause().toSql(),
"(`eventid` = 1)");
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- range.buildDiskPartitionRange(newRangeList);
-
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- LOG.warn("MultiPredicate={}", sql);
- Assert.assertEquals(sql, "(`eventdate` > '2020-01-13') AND
(`eventdate` < '2020-01-16') AND (`eventid` = 1)");
- } catch (Exception e) {
- LOG.warn("multi ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testRewriteJoin() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT appevent.eventdate, country, COUNT(appevent.userid)
FROM appevent"
- + " INNER JOIN userprofile ON appevent.userid =
userprofile.userid"
- + " WHERE appevent.eventdate>=\"2020-01-12\" and
appevent.eventdate<=\"2020-01-15\""
- + " and eventid=1 GROUP BY appevent.eventdate, country"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
- cache.rewriteSelectStmt(null);
- LOG.warn("Join nokey={}",
cache.getNokeyStmt().getWhereClause().toSql());
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause().toSql(),
"(`eventid` = 1)");
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- range.buildDiskPartitionRange(newRangeList);
-
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- LOG.warn("Join rewrite={}", sql);
- Assert.assertEquals(sql, "(`appevent`.`eventdate` >= '2020-01-14')"
- + " AND (`appevent`.`eventdate` <= '2020-01-15') AND
(`eventid` = 1)");
- } catch (Exception e) {
- LOG.warn("Join ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testSubSelect() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, sum(pv) FROM (SELECT eventdate,
COUNT(userid) AS pv FROM appevent WHERE "
- + "eventdate>\"2020-01-11\" AND
eventdate<\"2020-01-16\""
- + " AND eventid=1 GROUP BY eventdate) tbl GROUP BY
eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L);
//2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition); //assert
cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- LOG.warn("Sub nokey={}", cache.getNokeyStmt().toSql());
- Assert.assertEquals(cache.getNokeyStmt().toSql(),
- "SELECT `eventdate` AS `eventdate`, sum(`pv`) AS
`sum(``pv``)` "
- + "FROM (SELECT `eventdate`, count(`userid`) `pv` "
- + "FROM `testDb`.`appevent` WHERE (`eventid` = 1)
GROUP BY `eventdate`) tbl "
- + "GROUP BY `eventdate`");
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- range.buildDiskPartitionRange(newRangeList);
-
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().toSql();
- LOG.warn("Sub rewrite={}", sql);
- Assert.assertEquals(sql,
- "SELECT `eventdate` AS `eventdate`, sum(`pv`) AS
`sum(``pv``)` "
- + "FROM (SELECT `eventdate`, count(`userid`) `pv` "
- + "FROM `testDb`.`appevent` WHERE (`eventdate` >
'2020-01-13') "
- + "AND (`eventdate` < '2020-01-16') AND (`eventid`
= 1) GROUP BY `eventdate`) tbl "
- + "GROUP BY `eventdate`");
- } catch (Exception e) {
- LOG.warn("sub ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testNotHitPartition() throws Exception {
- StatementBase parseStmt = parseSql(
- "SELECT eventdate, COUNT(userid) FROM appevent WHERE
eventdate>=\"2020-01-12\" and "
- + "eventdate<=\"2020-01-14\" GROUP BY eventdate"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1578675600000L); // set now to 2020-01-11 1:00:00,
for hit partition cache
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition); //assert
cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
- cache.rewriteSelectStmt(null);
- PartitionRange range = cache.getPartitionRange();
- range.analytics();
- hitRange = range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(hitRange, Cache.HitRange.None);
- Assert.assertEquals(newRangeList.size(), 2);
- Assert.assertEquals(newRangeList.get(0).getCacheKey().realValue(),
20200112);
- Assert.assertEquals(newRangeList.get(1).getCacheKey().realValue(),
20200114);
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
@Test
public void testSqlCacheKey() {
StatementBase parseStmt = parseSql(
@@ -1171,65 +758,6 @@ public class OlapQueryCacheTest {
Assert.assertEquals(selectedPartitionIds.size(),
sqlCache.getSumOfPartitionNum());
}
- @Test
- public void testPartitionCacheKeyWithView() {
- StatementBase parseStmt = parseSql("SELECT * from testDb.view3");
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
- Assert.assertEquals(cache.getSqlWithViewStmt(), "SELECT
`testDb`.`view3`.`eventdate` "
- + "AS `eventdate`, `testDb`.`view3`.`__count_1` AS
`__count_1` "
- + "FROM `testDb`.`view3`|SELECT `eventdate` AS
`eventdate`, count(`userid`) "
- + "AS `__count_1` FROM `testDb`.`appevent` WHERE
(`eventdate` >= '2020-01-12') "
- + "AND (`eventdate` <= '2020-01-15') GROUP BY
`eventdate`");
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
- @Test
- public void testPartitionCacheKeyWithSubSelectView() {
- StatementBase parseStmt = parseSql(
- "select origin.eventdate as eventdate, origin.cnt as cnt\n"
- + "from (\n"
- + " SELECT eventdate, COUNT(userid) as cnt \n"
- + " FROM view2 \n"
- + " WHERE eventdate>=\"2020-01-12\" and
eventdate<=\"2020-01-15\" GROUP BY eventdate\n"
- + ") origin"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createEventScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L); //2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
-
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
-
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
- Assert.assertEquals(cache.getSqlWithViewStmt(),
- "SELECT `origin`.`eventdate` AS `eventdate`,
`origin`.`cnt` AS `cnt` "
- + "FROM (SELECT `eventdate`, count(`userid`) `cnt`
"
- + "FROM `testDb`.`view2` GROUP BY `eventdate`)
origin|SELECT `eventdate` "
- + "AS `eventdate`, `userid` AS `userid` FROM
`testDb`.`appevent`");
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
-
@Test
public void testSqlCacheKeyWithNestedView() {
StatementBase parseStmt = parseSql("SELECT * from testDb.view4");
@@ -1290,48 +818,4 @@ public class OlapQueryCacheTest {
Assert.assertEquals(ca.getCacheMode(), CacheMode.Sql);
Assert.assertEquals(selectedPartitionIds.size() * 3, ((SqlCache)
ca.getCache()).getSumOfPartitionNum());
}
-
- @Test
- // test that some partitions do not exist in the table
- public void testNotExistPartitionSql() {
- StatementBase parseStmt = parseSql(
- "SELECT `date`, COUNT(id) FROM `order` WHERE `date`>=20200110
and `date`<=20200115 GROUP BY date"
- );
- ArrayList<Long> selectedPartitionIds
- = Lists.newArrayList(20200112L, 20200113L, 20200114L,
20200115L);
- List<ScanNode> scanNodes =
Lists.newArrayList(createOrderScanNode(selectedPartitionIds));
- CacheAnalyzer ca = new CacheAnalyzer(context, parseStmt, scanNodes);
- ca.checkCacheMode(1579053661000L);
//2020-1-15 10:01:01
- Assert.assertEquals(ca.getCacheMode(), CacheMode.Partition);
//assert cache model first
- try {
- PartitionCache cache = (PartitionCache) ca.getCache();
- cache.rewriteSelectStmt(null);
- Assert.assertEquals(cache.getNokeyStmt().getWhereClause(), null);
-
- PartitionRange range = cache.getPartitionRange();
- boolean flag = range.analytics();
- Assert.assertEquals(flag, true);
-
- int size = range.getPartitionSingleList().size();
- LOG.warn("Rewrite partition range size={}", size);
- Assert.assertEquals(size, 4);
-
- String sql;
- range.setCacheFlag(20200112L); //get data from cache
- range.setCacheFlag(20200113L); //get data from cache
-
- hitRange = range.buildDiskPartitionRange(newRangeList);
- Assert.assertEquals(hitRange, Cache.HitRange.Left);
- Assert.assertEquals(newRangeList.size(), 2);
- Assert.assertEquals(newRangeList.get(0).getCacheKey().realValue(),
20200114);
- Assert.assertEquals(newRangeList.get(1).getCacheKey().realValue(),
20200115);
-
- cache.rewriteSelectStmt(newRangeList);
- sql = ca.getRewriteStmt().getWhereClause().toSql();
- Assert.assertEquals(sql, "(`date` >= 20200114) AND (`date` <=
20200115)");
- } catch (Exception e) {
- LOG.warn("ex={}", e);
- Assert.fail(e.getMessage());
- }
- }
}
diff --git a/regression-test/suites/nereids_p0/cache/partition_cache.groovy
b/regression-test/suites/nereids_p0/cache/partition_cache.groovy
deleted file mode 100644
index 1b28f1fafbc..00000000000
--- a/regression-test/suites/nereids_p0/cache/partition_cache.groovy
+++ /dev/null
@@ -1,309 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// The cases is copied from https://github.com/trinodb/trino/tree/master
-//
/testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate
-// and modified by Doris.
-
-suite("partition_cache") {
- sql "SET enable_nereids_planner=true"
- sql "SET enable_fallback_to_original_planner=false"
- def tableName = "test_partition_cache"
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` date NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01'), ('2022-06-01')),
- PARTITION p202206 VALUES [('2022-06-01'), ('2022-07-01')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
-
- sql "sync"
-
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27",0),
- ("2022-05-28",0),
- ("2022-05-29",0),
- ("2022-05-30",0),
- ("2022-06-01",0),
- ("2022-06-02",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datev2 NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01'), ('2022-06-01')),
- PARTITION p202206 VALUES [('2022-06-01'), ('2022-07-01')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27",0),
- ("2022-05-28",0),
- ("2022-05-29",0),
- ("2022-05-30",0),
- ("2022-06-01",0),
- ("2022-06-02",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(3) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111'),
('2022-06-01 11:11:11.111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111'),
('2022-07-01 11:11:11.111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111",0),
- ("2022-05-28 11:11:11.111",0),
- ("2022-05-29 11:11:11.111",0),
- ("2022-05-30 11:11:11.111",0),
- ("2022-06-01 11:11:11.111",0),
- ("2022-06-02 11:11:11.111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(3) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111111'),
('2022-06-01 11:11:11.111111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111111'),
('2022-07-01 11:11:11.111111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111",0),
- ("2022-05-28 11:11:11.111",0),
- ("2022-05-29 11:11:11.111",0),
- ("2022-05-30 11:11:11.111",0),
- ("2022-06-01 11:11:11.111",0),
- ("2022-06-02 11:11:11.111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(6) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111'),
('2022-06-01 11:11:11.111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111'),
('2022-07-01 11:11:11.111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111111",0),
- ("2022-05-28 11:11:11.111111",0),
- ("2022-05-29 11:11:11.111111",0),
- ("2022-05-30 11:11:11.111111",0),
- ("2022-06-01 11:11:11.111111",0),
- ("2022-06-02 11:11:11.111111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-}
diff --git a/regression-test/suites/query_p0/cache/partition_cache.groovy
b/regression-test/suites/query_p0/cache/partition_cache.groovy
deleted file mode 100644
index 9dde76066fb..00000000000
--- a/regression-test/suites/query_p0/cache/partition_cache.groovy
+++ /dev/null
@@ -1,310 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// The cases is copied from https://github.com/trinodb/trino/tree/master
-//
/testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate
-// and modified by Doris.
-
-suite("partition_cache") {
- // TODO: regression-test does not support check query profile,
- // so this suite does not check whether cache is used, :)
- def tableName = "test_partition_cache"
- sql "ADMIN SET FRONTEND CONFIG ('cache_last_version_interval_second' =
'0')"
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` date NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01'), ('2022-06-01')),
- PARTITION p202206 VALUES [('2022-06-01'), ('2022-07-01')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
-
- sql "sync"
-
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27",0),
- ("2022-05-28",0),
- ("2022-05-29",0),
- ("2022-05-30",0),
- ("2022-06-01",0),
- ("2022-06-02",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datev2 NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01'), ('2022-06-01')),
- PARTITION p202206 VALUES [('2022-06-01'), ('2022-07-01')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27",0),
- ("2022-05-28",0),
- ("2022-05-29",0),
- ("2022-05-30",0),
- ("2022-06-01",0),
- ("2022-06-02",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28' and '2022-06-30'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(3) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111'),
('2022-06-01 11:11:11.111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111'),
('2022-07-01 11:11:11.111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111",0),
- ("2022-05-28 11:11:11.111",0),
- ("2022-05-29 11:11:11.111",0),
- ("2022-05-30 11:11:11.111",0),
- ("2022-06-01 11:11:11.111",0),
- ("2022-06-02 11:11:11.111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(3) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111111'),
('2022-06-01 11:11:11.111111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111111'),
('2022-07-01 11:11:11.111111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111",0),
- ("2022-05-28 11:11:11.111",0),
- ("2022-05-29 11:11:11.111",0),
- ("2022-05-30 11:11:11.111",0),
- ("2022-06-01 11:11:11.111",0),
- ("2022-06-02 11:11:11.111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-
- sql """ DROP TABLE IF EXISTS ${tableName} """
- sql """
- CREATE TABLE IF NOT EXISTS ${tableName} (
- `k1` datetimev2(6) NOT NULL COMMENT "",
- `k2` int(11) NOT NULL COMMENT ""
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- COMMENT "OLAP"
- PARTITION BY RANGE(`k1`)
- (PARTITION p202205 VALUES [('2022-05-01 11:11:11.111'),
('2022-06-01 11:11:11.111')),
- PARTITION p202206 VALUES [('2022-06-01 11:11:11.111'),
('2022-07-01 11:11:11.111')))
- DISTRIBUTED BY HASH(`k1`, `k2`) BUCKETS 32
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- )
- """
- sql """ INSERT INTO ${tableName} VALUES
- ("2022-05-27 11:11:11.111111",0),
- ("2022-05-28 11:11:11.111111",0),
- ("2022-05-29 11:11:11.111111",0),
- ("2022-05-30 11:11:11.111111",0),
- ("2022-06-01 11:11:11.111111",0),
- ("2022-06-02 11:11:11.111111",0)
- """
- sql " set enable_partition_cache=true "
-
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- qt_partition_cache """
- select
- k1,
- sum(k2) as total_pv
- from
- ${tableName}
- where
- k1 between '2022-05-28 11:11:11.111' and '2022-06-30
11:11:11.111'
- group by
- k1
- order by
- k1;
- """
- sql " set enable_partition_cache=false "
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]