This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 f2f06c1acc [feature](nereids) Support select temp partition (#15579)
f2f06c1acc is described below
commit f2f06c1acc8a4641b3eada524d7b8af595ac820e
Author: AKIRA <[email protected]>
AuthorDate: Wed Jan 4 11:04:36 2023 +0800
[feature](nereids) Support select temp partition (#15579)
Support such grammer:
select * from t_p temporary partition(tp1);
select * from t_p temporary partitions(tp1);
select * from t_p temporary partition tp1;
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 4 ++--
.../doris/nereids/analyzer/UnboundRelation.java | 21 +++++++++++++++------
.../doris/nereids/parser/LogicalPlanBuilder.java | 4 +++-
.../doris/nereids/rules/analysis/BindRelation.java | 2 +-
.../data/nereids_syntax_p0/select_partition.out | 9 +++++++++
.../nereids_syntax_p0/select_partition.groovy | 12 +++++++++++-
6 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 6b199654d8..4423f88992 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -312,8 +312,8 @@ qualifiedName
;
specifiedPartition
- : PARTITION identifier
- | PARTITIONS identifierList
+ : TEMPORARY? PARTITION (identifier | identifierList)
+ | TEMPORARY? PARTITIONS identifierList
;
constant
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
index cafc8cebbe..e61ba7818c 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
@@ -45,20 +45,23 @@ import java.util.Optional;
public class UnboundRelation extends LogicalRelation implements Unbound {
private final List<String> nameParts;
private final List<String> partNames;
+ private final boolean isTempPart;
public UnboundRelation(RelationId id, List<String> nameParts) {
- this(id, nameParts, Optional.empty(), Optional.empty(),
Collections.emptyList());
+ this(id, nameParts, Optional.empty(), Optional.empty(),
+ Collections.emptyList(), false);
}
- public UnboundRelation(RelationId id, List<String> nameParts, List<String>
partNames) {
- this(id, nameParts, Optional.empty(), Optional.empty(), partNames);
+ public UnboundRelation(RelationId id, List<String> nameParts, List<String>
partNames, boolean isTempPart) {
+ this(id, nameParts, Optional.empty(), Optional.empty(), partNames,
isTempPart);
}
public UnboundRelation(RelationId id, List<String> nameParts,
Optional<GroupExpression> groupExpression,
- Optional<LogicalProperties> logicalProperties, List<String>
partNames) {
+ Optional<LogicalProperties> logicalProperties, List<String>
partNames, boolean isTempPart) {
super(id, PlanType.LOGICAL_UNBOUND_RELATION, groupExpression,
logicalProperties);
this.nameParts = nameParts;
this.partNames =
ImmutableList.copyOf(Objects.requireNonNull(partNames, "partNames should not
null"));
+ this.isTempPart = isTempPart;
}
@Override
@@ -82,12 +85,14 @@ public class UnboundRelation extends LogicalRelation
implements Unbound {
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression)
{
- return new UnboundRelation(id, nameParts, groupExpression,
Optional.of(getLogicalProperties()), partNames);
+ return new UnboundRelation(id, nameParts, groupExpression,
Optional.of(getLogicalProperties()),
+ partNames, isTempPart);
}
@Override
public Plan withLogicalProperties(Optional<LogicalProperties>
logicalProperties) {
- return new UnboundRelation(id, nameParts, Optional.empty(),
logicalProperties, partNames);
+ return new UnboundRelation(id, nameParts, Optional.empty(),
logicalProperties, partNames,
+ isTempPart);
}
@Override
@@ -140,4 +145,8 @@ public class UnboundRelation extends LogicalRelation
implements Unbound {
public List<String> getPartNames() {
return partNames;
}
+
+ public boolean isTempPart() {
+ return isTempPart;
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 061f9ada40..affb175372 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -434,7 +434,9 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
public LogicalPlan visitTableName(TableNameContext ctx) {
List<String> tableId =
visitMultipartIdentifier(ctx.multipartIdentifier());
List<String> partitionNames = new ArrayList<>();
+ boolean isTempPart = false;
if (ctx.specifiedPartition() != null) {
+ isTempPart = ctx.specifiedPartition().TEMPORARY() != null;
if (ctx.specifiedPartition().identifier() != null) {
partitionNames.add(ctx.specifiedPartition().identifier().getText());
} else {
@@ -442,7 +444,7 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
}
}
LogicalPlan checkedRelation = withCheckPolicy(
- new UnboundRelation(RelationUtil.newRelationId(), tableId,
partitionNames));
+ new UnboundRelation(RelationUtil.newRelationId(), tableId,
partitionNames, isTempPart));
LogicalPlan plan = withTableAlias(checkedRelation, ctx.tableAlias());
for (LateralViewContext lateralViewContext : ctx.lateralView()) {
plan = withGenerate(plan, lateralViewContext);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
index d706c80438..bfc9979b7f 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
@@ -190,7 +190,7 @@ public class BindRelation extends OneAnalysisRuleFactory {
+ "Table: %s is not OLAP table", t.getName()));
}
return parts.stream().map(name -> {
- Partition part = ((OlapTable) t).getPartition(name);
+ Partition part = ((OlapTable) t).getPartition(name,
unboundRelation.isTempPart());
if (part == null) {
throw new IllegalStateException(String.format("Partition: %s
is not exists", name));
}
diff --git a/regression-test/data/nereids_syntax_p0/select_partition.out
b/regression-test/data/nereids_syntax_p0/select_partition.out
index 95e9e37894..5383ef8afb 100644
--- a/regression-test/data/nereids_syntax_p0/select_partition.out
+++ b/regression-test/data/nereids_syntax_p0/select_partition.out
@@ -12,3 +12,12 @@
-- !sql --
7 1 3
+-- !sql --
+16 1234 t
+
+-- !sql --
+16 1234 t
+
+-- !sql --
+16 1234 t
+
diff --git a/regression-test/suites/nereids_syntax_p0/select_partition.groovy
b/regression-test/suites/nereids_syntax_p0/select_partition.groovy
index be4008ff57..9caa21c96b 100644
--- a/regression-test/suites/nereids_syntax_p0/select_partition.groovy
+++ b/regression-test/suites/nereids_syntax_p0/select_partition.groovy
@@ -18,7 +18,6 @@
suite("query_on_specific_partition") {
sql "SET enable_vectorized_engine=true"
sql "SET enable_nereids_planner=true"
- sql "SET enable_fallback_to_original_planner=false"
sql """
DROP TABLE IF EXISTS t_p;
@@ -41,8 +40,13 @@ suite("query_on_specific_partition") {
);
"""
+ sql """ALTER TABLE t_p ADD TEMPORARY PARTITION tp1 VALUES [("15"),
("20"));"""
+
sql "INSERT INTO t_p VALUES(1, 1,'1')"
sql "INSERT INTO t_p VALUES(7, 1,'3')"
+ sql "INSERT INTO t_p TEMPORARY PARTITION(tp1) values(16,1234, 't');"
+
+ sql "SET enable_fallback_to_original_planner=false"
qt_sql "SELECT * FROM t_p PARTITION p1"
@@ -51,4 +55,10 @@ suite("query_on_specific_partition") {
order_qt_sql "SELECT * FROM t_p PARTITIONS (p2, p1)"
order_qt_sql "SELECT * FROM t_p PARTITIONS (p2, p1) WHERE id > 1"
+
+ qt_sql """select * from t_p temporary partition(tp1);"""
+
+ qt_sql """select * from t_p temporary partitions(tp1);"""
+
+ qt_sql """select * from t_p temporary partition tp1;"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]