Skip to content

Commit

Permalink
expr thrift
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Aug 15, 2023
1 parent 48de399 commit de9cee8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ public void analyze(Analyzer analyzer) throws UserException, AnalysisException {
ExpressionPartitionDesc expressionPartitionDesc = (ExpressionPartitionDesc) partitionDesc;
try {
expressionPartitionDesc.analyze(columnDefs, properties);
// expressionPartitionDesc.analyzeExpr(analyzer);
} catch (AnalysisException e) {
throw new AnalysisException("ExpressionPartitionDesc analyze error with: " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public RangePartitionDesc getRangePartitionDesc() {
return rangePartitionDesc;
}

public void analyzeExpr(Analyzer analyzer) throws AnalysisException {
expr.analyze(analyzer);
}

public static SlotRef getSlotRefFromFunctionCallExpr(Expr expr) {
if (expr instanceof FunctionCallExpr) {
ArrayList<Expr> children = expr.getChildren();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.DistributionInfo;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.ExpressionRangePartitionInfo;
import org.apache.doris.catalog.HashDistributionInfo;
import org.apache.doris.catalog.Index;
import org.apache.doris.catalog.ListPartitionItem;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void complete(Analyzer analyzer) throws UserException {
tSink.setNumReplicas(numReplicas);
tSink.setNeedGenRollup(dstTable.shouldLoadToNewRollup());
tSink.setSchema(createSchema(tSink.getDbId(), dstTable, analyzer));
tSink.setPartition(createPartition(tSink.getDbId(), dstTable));
tSink.setPartition(createPartition(tSink.getDbId(), dstTable, analyzer));
List<TOlapTableLocationParam> locationParams = createLocation(dstTable);
tSink.setLocation(locationParams.get(0));
if (singleReplicaLoad) {
Expand Down Expand Up @@ -296,7 +297,7 @@ private List<String> getDistColumns(DistributionInfo distInfo) throws UserExcept
return distColumns;
}

private TOlapTablePartitionParam createPartition(long dbId, OlapTable table) throws UserException {
private TOlapTablePartitionParam createPartition(long dbId, OlapTable table, Analyzer analyzer) throws UserException {
TOlapTablePartitionParam partitionParam = new TOlapTablePartitionParam();
partitionParam.setDbId(dbId);
partitionParam.setTableId(table.getId());
Expand Down Expand Up @@ -349,6 +350,21 @@ private TOlapTablePartitionParam createPartition(long dbId, OlapTable table) thr
if (partitionIds.isEmpty()) {
partitionParam.setPartitions(new ArrayList<TOlapTablePartition>());
}
if (partitionInfo instanceof ExpressionRangePartitionInfo) {
ExpressionRangePartitionInfo exprPartitionInfo = (ExpressionRangePartitionInfo) partitionInfo;
List<Expr> exprs = exprPartitionInfo.getPartitionExprs();
if (analyzer != null) {
tupleDescriptor.setTable(table);
analyzer.registerTupleDescriptor(tupleDescriptor);
for(Expr e : exprs) {
e.analyze(analyzer);
}
}
partitionParam.setPartitionFunctionExprs(Expr.treesToThrift(exprs));
partitionParam.setEnableAutomaticPartition(true);
} else {
partitionParam.setEnableAutomaticPartition(false);
}
break;
}
case UNPARTITIONED: {
Expand Down
2 changes: 2 additions & 0 deletions gensrc/thrift/Descriptors.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ struct TOlapTablePartitionParam {
6: required list<TOlapTablePartition> partitions

7: optional list<string> partition_columns
8: optional list<Exprs.TExpr> partition_function_exprs
9: optional bool enable_automatic_partition
}

struct TOlapTableIndex {
Expand Down

0 comments on commit de9cee8

Please sign in to comment.