morrySnow commented on code in PR #25884:
URL: https://github.com/apache/doris/pull/25884#discussion_r1375873795
##########
fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -422,7 +422,8 @@ columnDef
: colName=identifier type=dataType
KEY? (aggType=aggTypeDef)? ((NOT NULL) | NULL)?
(DEFAULT (nullValue=NULL | INTEGER_VALUE | stringValue=STRING_LITERAL
- | CURRENT_TIMESTAMP (LEFT_PAREN precision=number RIGHT_PAREN)?))?
+ | CURRENT_TIMESTAMP (LEFT_PAREN precision1=number RIGHT_PAREN)?))?
+ (ON UPDATE CURRENT_TIMESTAMP (LEFT_PAREN precision2=number
RIGHT_PAREN)?)?
Review Comment:
do not use precision1, precision2. please give a meaningful name
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java:
##########
@@ -176,7 +176,20 @@ public List<Rule> buildRules() {
// If the current load is a partial update,
the values of unmentioned
// columns will be filled in SegmentWriter.
And the output of sink node
// should not contain these unmentioned
columns, so we just skip them.
- continue;
+ try {
+ if (column.hasOnUpdateDefaultValue()) {
+ Expression defualtValueExpression =
FunctionBinder.INSTANCE.rewrite(
+ new
NereidsParser().parseExpression(
+
column.getOnUpdateDefaultValueExpr().toSqlWithoutTbl()),
+ new
ExpressionRewriteContext(ctx.cascadesContext));
+ columnToOutput.put(column.getName(),
+ new
Alias(defualtValueExpression, column.getName()));
+ } else {
+ continue;
+ }
+ } catch (Exception e) {
+ throw new
AnalysisException(e.getMessage(), e.getCause());
Review Comment:
u should add some error msg in exception, since it will be read by human
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java:
##########
@@ -198,6 +221,33 @@ public void validate(Set<String> keysSet, boolean
isEnableMergeOnWrite, KeysType
throw new AnalysisException(e.getMessage(), e);
}
}
+ if (onUpdateDefaultValue.isPresent()
+ && onUpdateDefaultValue.get().getValue() != null
+ && type.toCatalogDataType().isScalarType()) {
+ try {
+ ColumnDef.validateDefaultValue(type.toCatalogDataType(),
+ onUpdateDefaultValue.get().getValue(),
onUpdateDefaultValue.get().getDefaultValueExprDef());
+ } catch (Exception e) {
+ throw new AnalysisException(e.getMessage(), e);
Review Comment:
ditto
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -398,6 +398,11 @@ public PlanFragment
visitPhysicalOlapTableSink(PhysicalOlapTableSink<? extends P
for (Column col : olapTableSink.getCols()) {
partialUpdateCols.add(col.getName());
}
+ for (Column col : olapTable.getFullSchema()) {
+ if (col.hasOnUpdateDefaultValue()) {
+ partialUpdateCols.add(col.getName());
+ }
+ }
Review Comment:
i don't think handle `OnUpdateDefaultValue` in translator is a good idea.
translator should only do translate. u should process it in Nereids planner.
btw, the upper check also should do in Nereids planner rather than here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]