[refactor](Nereids) expression translate no long rely on legacy planner code (#17671)

This commit is contained in:
morrySnow
2023-03-23 23:05:15 +08:00
committed by GitHub
parent 47bd3e77e8
commit c1bd5b26a8
26 changed files with 887 additions and 261 deletions

View File

@ -1002,8 +1002,4 @@ public class AnalyticExpr extends Expr {
}
return Joiner.on(", ").join(strings);
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
}

View File

@ -756,11 +756,6 @@ public class ArithmeticExpr extends Expr {
}
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
@Override
public void write(DataOutput out) throws IOException {
Text.writeString(out, op.name());

View File

@ -119,9 +119,4 @@ public class BetweenPredicate extends Predicate {
public int hashCode() {
return 31 * super.hashCode() + Boolean.hashCode(isNotBetween);
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
throw new AnalysisException("analyze between predicate for Nereids do not implementation.");
}
}

View File

@ -21,6 +21,7 @@
package org.apache.doris.analysis;
import org.apache.doris.catalog.Function;
import org.apache.doris.catalog.Function.NullableMode;
import org.apache.doris.catalog.FunctionSet;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.ScalarFunction;
@ -168,6 +169,18 @@ public class BinaryPredicate extends Predicate implements Writable {
children.add(e2);
}
public BinaryPredicate(Operator op, Expr e1, Expr e2, Type retType, NullableMode nullableMode) {
super();
this.op = op;
this.opcode = op.opcode;
Preconditions.checkNotNull(e1);
children.add(e1);
Preconditions.checkNotNull(e2);
children.add(e2);
fn = new Function(new FunctionName(op.name), Lists.newArrayList(e1.getType(), e2.getType()), retType,
false, true, nullableMode);
}
protected BinaryPredicate(BinaryPredicate other) {
super(other);
op = other.op;
@ -779,10 +792,4 @@ public class BinaryPredicate extends Predicate implements Writable {
}
return hasNullableChild();
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
super.finalizeImplForNereids();
fn = getBuiltinFunction(op.name, collectChildReturnTypes(), Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
}
}

View File

@ -88,6 +88,16 @@ public class CaseExpr extends Expr {
}
}
/**
* use for Nereids ONLY
*/
public CaseExpr(List<CaseWhenClause> whenClauses, Expr elseExpr) {
this(null, whenClauses, elseExpr);
// nereids do not have CaseExpr, and nereids will unify the types,
// so just use the first then type
type = children.get(1).getType();
}
protected CaseExpr(CaseExpr other) {
super(other);
hasCaseExpr = other.hasCaseExpr;
@ -428,11 +438,4 @@ public class CaseExpr extends Expr {
}
return false;
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
// nereids do not have CaseExpr, and nereids will unify the types,
// so just use the first then type
type = children.get(1).getType();
}
}

View File

@ -114,13 +114,20 @@ public class CastExpr extends Expr {
* Just use for nereids, put analyze() in finalizeImplForNereids
*/
public CastExpr(Type targetType, Expr e, Void v) {
super();
Preconditions.checkArgument(targetType.isValid());
Preconditions.checkNotNull(e);
type = targetType;
targetTypeDef = null;
isImplicit = true;
children.add(e);
try {
analyze();
} catch (AnalysisException ex) {
LOG.warn("Implicit casts fail", ex);
Preconditions.checkState(false,
"Implicit casts should never throw analysis exception.");
}
analysisDone();
}
/**
@ -572,17 +579,6 @@ public class CastExpr extends Expr {
|| (!children.get(0).getType().isDateType() && getType().isDateType());
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
try {
analyze();
} catch (AnalysisException ex) {
LOG.warn("Implicit casts fail", ex);
Preconditions.checkState(false,
"Implicit casts should never throw analysis exception.");
}
}
@Override
public String getStringValueForArray() {
return children.get(0).getStringValueForArray();

View File

@ -273,11 +273,6 @@ public class CompoundPredicate extends Predicate {
return hasNullableChild();
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
@Override
public String toString() {
return toSqlImpl();

View File

@ -40,9 +40,4 @@ public class DefaultValueExpr extends Expr {
public Expr clone() {
return null;
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
}

View File

@ -2154,21 +2154,6 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
return true;
}
public final void finalizeForNereids() throws AnalysisException {
if (isAnalyzed()) {
return;
}
for (Expr child : children) {
child.finalizeForNereids();
}
finalizeImplForNereids();
analysisDone();
}
public void finalizeImplForNereids() throws AnalysisException {
throw new AnalysisException("analyze for Nereids do not implementation.");
}
public void materializeSrcExpr() {
if (this instanceof SlotRef) {
SlotRef thisRef = (SlotRef) this;

View File

@ -1857,26 +1857,6 @@ public class FunctionCallExpr extends Expr {
return result.toString();
}
public void finalizeImplForNereids() throws AnalysisException {
}
private List<Type> getArgTypesForNereids() {
if (argTypesForNereids.isPresent()) {
return argTypesForNereids.get();
} else {
return Lists.newArrayList(collectChildReturnTypes());
}
}
/**
* NOTICE: This function only used for Nereids, should not call it if u don't
* know what it is mean.
*/
public void setMergeForNereids(boolean isMergeAggFn) {
this.isMergeAggFn = isMergeAggFn;
}
public List<OrderByElement> getOrderByElements() {
return orderByElements;
}

View File

@ -21,6 +21,7 @@
package org.apache.doris.analysis;
import org.apache.doris.catalog.Function;
import org.apache.doris.catalog.Function.NullableMode;
import org.apache.doris.catalog.FunctionSet;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.ScalarFunction;
@ -100,6 +101,22 @@ public class InPredicate extends Predicate {
this.isNotIn = isNotIn;
}
/**
* use for Nereids ONLY
*/
public InPredicate(Expr compareExpr, List<Expr> inList, boolean isNotIn, boolean allConstant) {
this(compareExpr, inList, isNotIn);
type = Type.BOOLEAN;
if (allConstant) {
opcode = isNotIn ? TExprOpcode.FILTER_NOT_IN : TExprOpcode.FILTER_IN;
} else {
opcode = isNotIn ? TExprOpcode.FILTER_NEW_NOT_IN : TExprOpcode.FILTER_NEW_IN;
fn = new Function(new FunctionName(isNotIn ? NOT_IN_ITERATE : IN_ITERATE),
Lists.newArrayList(getChild(0).getType(), getChild(1).getType()), Type.BOOLEAN,
true, true, NullableMode.DEPEND_ON_ARGUMENT);
}
}
protected InPredicate(InPredicate other) {
super(other);
isNotIn = other.isNotIn();
@ -331,39 +348,4 @@ public class InPredicate extends Predicate {
public boolean isNullable() {
return hasNullableChild();
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
super.finalizeImplForNereids();
boolean allConstant = true;
for (int i = 1; i < children.size(); ++i) {
if (!children.get(i).isConstant()) {
allConstant = false;
break;
}
}
// Only lookup fn_ if all subqueries have been rewritten. If the second child is a
// subquery, it will have type ArrayType, which cannot be resolved to a builtin
// function and will fail analysis.
Type[] argTypes = {getChild(0).type, getChild(1).type};
if (allConstant) {
// fn = getBuiltinFunction(analyzer, isNotIn ? NOT_IN_SET_LOOKUP : IN_SET_LOOKUP,
// argTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
opcode = isNotIn ? TExprOpcode.FILTER_NOT_IN : TExprOpcode.FILTER_IN;
// Todo: need to implement completely type cast compatibility, like castAllToCompatibleType();
Type compatibleType = getChild(0).getType();
for (int i = 1; i < children.size(); ++i) {
compatibleType = Type.getCmpType(compatibleType, getChild(i).getType());
}
for (int i = 0; i < children.size(); ++i) {
if (!getChild(i).getType().equals(compatibleType)) {
getChild(i).setType(compatibleType);
}
}
} else {
fn = getBuiltinFunction(isNotIn ? NOT_IN_ITERATE : IN_ITERATE,
argTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
opcode = isNotIn ? TExprOpcode.FILTER_NEW_NOT_IN : TExprOpcode.FILTER_NEW_IN;
}
}
}

View File

@ -33,11 +33,8 @@ import org.apache.doris.thrift.TExprNodeType;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class IsNullPredicate extends Predicate {
private static final Logger LOG = LogManager.getLogger(IsNullPredicate.class);
private static final String IS_NULL = "is_null_pred";
private static final String IS_NOT_NULL = "is_not_null_pred";
@ -87,10 +84,22 @@ public class IsNullPredicate extends Predicate {
private final boolean isNotNull;
public IsNullPredicate(Expr e, boolean isNotNull) {
this(e, isNotNull, false);
}
/**
* use for Nereids ONLY
*/
public IsNullPredicate(Expr e, boolean isNotNull, boolean isNereids) {
super();
this.isNotNull = isNotNull;
Preconditions.checkNotNull(e);
children.add(e);
if (isNereids) {
fn = new Function(new FunctionName(isNotNull ? IS_NOT_NULL : IS_NULL),
Lists.newArrayList(e.getType()), Type.BOOLEAN, false, true, NullableMode.ALWAYS_NOT_NULLABLE);
Preconditions.checkState(fn != null, "tupleisNull fn == NULL");
}
}
protected IsNullPredicate(IsNullPredicate other) {
@ -174,15 +183,4 @@ public class IsNullPredicate extends Predicate {
}
return childValue instanceof NullLiteral ? new BoolLiteral(!isNotNull) : new BoolLiteral(isNotNull);
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
super.finalizeImplForNereids();
if (isNotNull) {
fn = getBuiltinFunction(IS_NOT_NULL, collectChildReturnTypes(), Function.CompareMode.IS_INDISTINGUISHABLE);
} else {
fn = getBuiltinFunction(IS_NULL, collectChildReturnTypes(), Function.CompareMode.IS_INDISTINGUISHABLE);
}
Preconditions.checkState(fn != null, "tupleisNull fn == NULL");
}
}

View File

@ -260,11 +260,6 @@ public abstract class LiteralExpr extends Expr implements Comparable<LiteralExpr
return this instanceof NullLiteral;
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
@Override
public String toString() {
return getStringValue();

View File

@ -157,9 +157,4 @@ public abstract class Predicate extends Expr {
public Pair<SlotId, SlotId> getEqSlots() {
return null;
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
type = Type.BOOLEAN;
}
}

View File

@ -526,11 +526,6 @@ public class SlotRef extends Expr {
return desc.getIsNullable();
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

View File

@ -19,6 +19,7 @@ package org.apache.doris.analysis;
import org.apache.doris.analysis.ArithmeticExpr.Operator;
import org.apache.doris.catalog.Function;
import org.apache.doris.catalog.Function.NullableMode;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Type;
@ -31,7 +32,7 @@ import org.apache.doris.thrift.TExprNodeType;
import org.apache.doris.thrift.TExprOpcode;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -46,7 +47,7 @@ import java.util.Map;
*/
public class TimestampArithmeticExpr extends Expr {
private static final Logger LOG = LogManager.getLogger(TimestampArithmeticExpr.class);
private static Map<String, TimeUnit> TIME_UNITS_MAP = new HashMap<String, TimeUnit>();
private static final Map<String, TimeUnit> TIME_UNITS_MAP = new HashMap<String, TimeUnit>();
static {
for (TimeUnit timeUnit : TimeUnit.values()) {
@ -97,40 +98,24 @@ public class TimestampArithmeticExpr extends Expr {
* @param timeUnitIdent interval time unit, could be 'year', 'month', 'day', 'hour', 'minute', 'second'.
* @param dataType the return data type of this expression.
*/
public TimestampArithmeticExpr(String funcName, Expr e1, Expr e2, String timeUnitIdent, Type dataType) {
public TimestampArithmeticExpr(String funcName, ArithmeticExpr.Operator op,
Expr e1, Expr e2, String timeUnitIdent, Type dataType, NullableMode nullableMode) {
this.funcName = funcName;
this.timeUnitIdent = timeUnitIdent;
this.timeUnit = TIME_UNITS_MAP.get(timeUnitIdent.toUpperCase(Locale.ROOT));
this.op = op;
this.intervalFirst = false;
children.add(e1);
children.add(e2);
this.type = dataType;
}
fn = new Function(new FunctionName(funcName.toLowerCase(Locale.ROOT)),
Lists.newArrayList(e1.getType(), e2.getType()), dataType, false, true, nullableMode);
try {
opcode = getOpCode();
} catch (AnalysisException e) {
throw new RuntimeException(e);
}
/**
* used for Nereids ONLY.
* C'tor for non-function-call like arithmetic, e.g., 'a + interval b year'.
* e1 always refers to the timestamp to be added/subtracted from, and e2
* to the time value (even in the interval-first case).
*
* @param op operator of this function either ADD or SUBTRACT.
* @param e1 non interval literal child of this function
* @param e2 interval literal child of this function
* @param timeUnitIdent interval time unit, could be 'year', 'month', 'day', 'hour', 'minute', 'second'.
* @param intervalFirst true if the left child is interval literal
* @param dataType the return data type of this expression.
*/
public TimestampArithmeticExpr(ArithmeticExpr.Operator op, Expr e1, Expr e2,
String timeUnitIdent, boolean intervalFirst, Type dataType) {
Preconditions.checkState(op == Operator.ADD || op == Operator.SUBTRACT);
this.funcName = null;
this.op = op;
this.timeUnitIdent = timeUnitIdent;
this.timeUnit = TIME_UNITS_MAP.get(timeUnitIdent.toUpperCase(Locale.ROOT));
this.intervalFirst = intervalFirst;
children.add(e1);
children.add(e2);
this.type = dataType;
}
protected TimestampArithmeticExpr(TimestampArithmeticExpr other) {
@ -475,15 +460,4 @@ public class TimestampArithmeticExpr extends Expr {
return description;
}
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
if (StringUtils.isEmpty(funcName)) {
throw new AnalysisException("function name is null");
}
timeUnit = TIME_UNITS_MAP.get(timeUnitIdent.toUpperCase());
opcode = getOpCode();
fn = getBuiltinFunction(funcName.toLowerCase(), collectChildReturnTypes(),
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
}
}

View File

@ -239,9 +239,4 @@ public class TupleIsNullPredicate extends Predicate {
public boolean isNullable() {
return false;
}
@Override
public void finalizeImplForNereids() throws AnalysisException {
super.finalizeImplForNereids();
}
}

View File

@ -83,6 +83,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionVisit
import org.apache.doris.nereids.types.coercion.AbstractDataType;
import org.apache.doris.thrift.TFunctionBinaryType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
@ -99,8 +100,7 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
public static ExpressionTranslator INSTANCE = new ExpressionTranslator();
/**
* The entry function of ExpressionTranslator, call {@link Expr#finalizeForNereids()} to generate
* some attributes using in BE.
* The entry function of ExpressionTranslator.
*
* @param expression nereids expression
* @param context translator context
@ -108,16 +108,8 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
*/
public static Expr translate(Expression expression, PlanTranslatorContext context) {
Expr staleExpr = expression.accept(INSTANCE, context);
try {
if (staleExpr.getType() instanceof ScalarType) {
((ScalarType) staleExpr.getType()).setByteSize((long) expression.getDataType().width());
}
staleExpr.finalizeForNereids();
} catch (Exception e) {
throw new AnalysisException(
"Translate Nereids expression `" + expression.toSql()
+ "` to stale expression failed. " + e.getMessage(), e);
if (staleExpr.getType() instanceof ScalarType) {
((ScalarType) staleExpr.getType()).setByteSize(expression.getDataType().width());
}
return staleExpr;
}
@ -131,42 +123,54 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
public Expr visitEqualTo(EqualTo equalTo, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.EQ,
equalTo.child(0).accept(this, context),
equalTo.child(1).accept(this, context));
equalTo.child(1).accept(this, context),
equalTo.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
}
@Override
public Expr visitGreaterThan(GreaterThan greaterThan, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.GT,
greaterThan.child(0).accept(this, context),
greaterThan.child(1).accept(this, context));
greaterThan.child(1).accept(this, context),
greaterThan.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
}
@Override
public Expr visitGreaterThanEqual(GreaterThanEqual greaterThanEqual, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.GE,
greaterThanEqual.child(0).accept(this, context),
greaterThanEqual.child(1).accept(this, context));
greaterThanEqual.child(1).accept(this, context),
greaterThanEqual.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
}
@Override
public Expr visitLessThan(LessThan lessThan, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.LT,
lessThan.child(0).accept(this, context),
lessThan.child(1).accept(this, context));
lessThan.child(1).accept(this, context),
lessThan.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
}
@Override
public Expr visitLessThanEqual(LessThanEqual lessThanEqual, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.LE,
lessThanEqual.child(0).accept(this, context),
lessThanEqual.child(1).accept(this, context));
lessThanEqual.child(1).accept(this, context),
lessThanEqual.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
}
@Override
public Expr visitNullSafeEqual(NullSafeEqual nullSafeEqual, PlanTranslatorContext context) {
return new BinaryPredicate(Operator.EQ_FOR_NULL,
nullSafeEqual.child(0).accept(this, context),
nullSafeEqual.child(1).accept(this, context));
nullSafeEqual.child(1).accept(this, context),
nullSafeEqual.getDataType().toCatalogDataType(),
NullableMode.ALWAYS_NOT_NULLABLE);
}
@Override
@ -176,19 +180,21 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
List<Expr> inList = inPredicate.getOptions().stream()
.map(e -> translate(e, context))
.collect(Collectors.toList());
boolean allConstant = inPredicate.getOptions().stream().allMatch(Expression::isConstant);
return new org.apache.doris.analysis.InPredicate(
inPredicate.getCompareExpr().accept(this, context),
inList,
true);
inList, true, allConstant);
} else if (not.child() instanceof EqualTo) {
EqualTo equalTo = (EqualTo) not.child();
return new BinaryPredicate(Operator.NE,
equalTo.child(0).accept(this, context),
equalTo.child(1).accept(this, context));
equalTo.child(1).accept(this, context),
equalTo.getDataType().toCatalogDataType(),
NullableMode.DEPEND_ON_ARGUMENT);
} else if (not.child() instanceof InSubquery || not.child() instanceof Exists) {
return new BoolLiteral(true);
} else if (not.child() instanceof IsNull) {
return new IsNullPredicate(((IsNull) not.child()).child().accept(this, context), true);
return new IsNullPredicate(((IsNull) not.child()).child().accept(this, context), true, true);
} else {
return new CompoundPredicate(CompoundPredicate.Operator.NOT,
not.child(0).accept(this, context), null);
@ -261,7 +267,7 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
if (defaultValue.isPresent()) {
elseExpr = defaultValue.get().accept(this, context);
}
return new CaseExpr(null, caseWhenClauses, elseExpr);
return new CaseExpr(caseWhenClauses, elseExpr);
}
@Override
@ -276,9 +282,10 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
List<Expr> inList = inPredicate.getOptions().stream()
.map(e -> e.accept(this, context))
.collect(Collectors.toList());
return new org.apache.doris.analysis.InPredicate(inPredicate.getCompareExpr().accept(this, context),
inList,
false);
boolean allConstant = inPredicate.getOptions().stream().allMatch(Expression::isConstant);
return new org.apache.doris.analysis.InPredicate(
inPredicate.getCompareExpr().accept(this, context),
inList, false, allConstant);
}
@Override
@ -417,15 +424,15 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
@Override
public Expr visitTimestampArithmetic(TimestampArithmetic arithmetic, PlanTranslatorContext context) {
if (arithmetic.getFuncName() == null) {
return new TimestampArithmeticExpr(arithmetic.getOp(), arithmetic.left().accept(this, context),
arithmetic.right().accept(this, context), arithmetic.getTimeUnit().toString(),
arithmetic.isIntervalFirst(), arithmetic.getDataType().toCatalogDataType());
} else {
return new TimestampArithmeticExpr(arithmetic.getFuncName(), arithmetic.left().accept(this, context),
arithmetic.right().accept(this, context), arithmetic.getTimeUnit().toString(),
arithmetic.getDataType().toCatalogDataType());
Preconditions.checkNotNull(arithmetic.getFuncName(),
"funcName in TimestampArithmetic should not be null");
NullableMode nullableMode = NullableMode.ALWAYS_NULLABLE;
if (arithmetic.children().stream().anyMatch(e -> e.getDataType().isDateV2LikeType())) {
nullableMode = NullableMode.DEPEND_ON_ARGUMENT;
}
return new TimestampArithmeticExpr(arithmetic.getFuncName(), arithmetic.getOp(),
arithmetic.left().accept(this, context), arithmetic.right().accept(this, context),
arithmetic.getTimeUnit().toString(), arithmetic.getDataType().toCatalogDataType(), nullableMode);
}
@Override
@ -435,7 +442,7 @@ public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTra
@Override
public Expr visitIsNull(IsNull isNull, PlanTranslatorContext context) {
return new IsNullPredicate(isNull.child().accept(this, context), false);
return new IsNullPredicate(isNull.child().accept(this, context), false, true);
}
// TODO: Supports for `distinct`

View File

@ -38,9 +38,11 @@ import org.apache.doris.analysis.TableRef;
import org.apache.doris.analysis.TupleDescriptor;
import org.apache.doris.analysis.TupleId;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Function.NullableMode;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf;
import org.apache.doris.catalog.Type;
import org.apache.doris.catalog.external.ExternalTable;
import org.apache.doris.common.Pair;
import org.apache.doris.common.UserException;
@ -2092,11 +2094,12 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
Expr rhs = exprIdToSlotRef.get(exprId);
Expr bothNull = new CompoundPredicate(CompoundPredicate.Operator.AND,
new IsNullPredicate(lhs, false), new IsNullPredicate(rhs, false));
new IsNullPredicate(lhs, false, true), new IsNullPredicate(rhs, false, true));
Expr lhsEqRhsNotNull = new CompoundPredicate(CompoundPredicate.Operator.AND,
new CompoundPredicate(CompoundPredicate.Operator.AND,
new IsNullPredicate(lhs, true), new IsNullPredicate(rhs, true)),
new BinaryPredicate(BinaryPredicate.Operator.EQ, lhs, rhs));
new IsNullPredicate(lhs, true, true), new IsNullPredicate(rhs, true, true)),
new BinaryPredicate(BinaryPredicate.Operator.EQ, lhs, rhs,
Type.BOOLEAN, NullableMode.DEPEND_ON_ARGUMENT));
Expr remainder = windowExprsHaveMatchedNullable(exprIdToExpr, exprIdToSlotRef, expressions, i + 1, size);
return new CompoundPredicate(CompoundPredicate.Operator.AND,

View File

@ -103,21 +103,14 @@ public class RuntimeFilterTranslator {
context.setTargetNullCount();
return;
}
Expr targetExpr = null;
Expr targetExpr;
if (filter.getType() == TRuntimeFilterType.BITMAP) {
if (filter.getTargetExpression().equals(filter.getTargetExpr())) {
targetExpr = target;
} else {
RuntimeFilterExpressionTranslator translator = new RuntimeFilterExpressionTranslator(
context.getExprIdToOlapScanNodeSlotRef());
try {
targetExpr = filter.getTargetExpression().accept(translator, ctx);
targetExpr.finalizeForNereids();
} catch (org.apache.doris.common.AnalysisException e) {
throw new AnalysisException(
"Translate Nereids expression to stale expression failed. " + e.getMessage(), e);
}
targetExpr = filter.getTargetExpression().accept(translator, ctx);
}
} else {
targetExpr = target;

View File

@ -33,6 +33,8 @@ import java.util.stream.Collectors;
/**
* In predicate expression.
* InPredicate could not use traits PropagateNullable, because fold constant will do wrong fold, such as
* 3 in (1, null, 3, 4) => null
*/
public class InPredicate extends Expression {
@ -54,17 +56,17 @@ public class InPredicate extends Expression {
return BooleanType.INSTANCE;
}
@Override
public boolean nullable() throws UnboundException {
return children().stream().anyMatch(Expression::nullable);
}
@Override
public InPredicate withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() > 1);
return new InPredicate(children.get(0), ImmutableList.copyOf(children).subList(1, children.size()));
}
@Override
public boolean nullable() throws UnboundException {
return children().stream().anyMatch(Expression::nullable);
}
@Override
public String toString() {
return compareExpr + " IN " + options.stream()

View File

@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.expressions;
import org.apache.doris.nereids.exceptions.UnboundException;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BooleanType;
@ -31,7 +32,7 @@ import java.util.Objects;
/**
* expr is null predicate.
*/
public class IsNull extends Expression implements UnaryExpression {
public class IsNull extends Expression implements UnaryExpression, AlwaysNotNullable {
public IsNull(Expression e) {
super(e);
@ -42,11 +43,6 @@ public class IsNull extends Expression implements UnaryExpression {
return visitor.visitIsNull(this, context);
}
@Override
public boolean nullable() {
return false;
}
@Override
public IsNull withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);

View File

@ -17,7 +17,7 @@
package org.apache.doris.nereids.trees.expressions;
import org.apache.doris.nereids.exceptions.UnboundException;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import com.google.common.base.Preconditions;
@ -28,7 +28,7 @@ import java.util.List;
* Null safe equal expression: a <=> b.
* Unlike normal equal to expression, null <=> null is true.
*/
public class NullSafeEqual extends ComparisonPredicate {
public class NullSafeEqual extends ComparisonPredicate implements AlwaysNotNullable {
/**
* Constructor of Null Safe Equal ComparisonPredicate.
*
@ -39,11 +39,6 @@ public class NullSafeEqual extends ComparisonPredicate {
super(left, right, "<=>");
}
@Override
public boolean nullable() throws UnboundException {
return false;
}
@Override
public String toString() {
return "(" + left() + " <=> " + right() + ")";

View File

@ -109,10 +109,6 @@ public class TimestampArithmetic extends Expression implements BinaryExpression,
return funcName;
}
public boolean isIntervalFirst() {
return intervalFirst;
}
public Operator getOp() {
return op;
}

View File

@ -0,0 +1,703 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !test_timestamp_arithmetic --
0
-- !test_timestamp_arithmetic_2 --
0
-- !test_timestamp_arithmetic_3 --
\N
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
2012-03-12
2012-03-13
-- !test_timestamp_arithmetic_4 --
\N
2012-03-01T00:00:01
2012-03-02T00:00:01
2012-03-03T00:00:01
2012-03-04T00:00:01
2012-03-05T00:00:01
2012-03-06T00:00:01
2012-03-07T00:00:01
2012-03-08T00:00:01
2012-03-09T00:00:01
2012-03-10T00:00:01
2012-03-11T00:00:01
2012-03-12T00:00:01
-- !test_timestamp_arithmetic_5 --
\N
2012-02-29
2012-03-01
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
-- !test_timestamp_arithmetic_6 --
\N
2012-02-29T23:59:59
2012-03-01T23:59:59
2012-03-02T23:59:59
2012-03-03T23:59:59
2012-03-04T23:59:59
2012-03-05T23:59:59
2012-03-06T23:59:59
2012-03-07T23:59:59
2012-03-08T23:59:59
2012-03-09T23:59:59
2012-03-10T23:59:59
2012-03-11T23:59:59
-- !test_timestamp_arithmetic_7 --
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
2012-03-12
2012-03-13
-- !test_timestamp_arithmetic_8 --
2012-03-01T00:00:01
2012-03-02T00:00:01
2012-03-03T00:00:01
2012-03-04T00:00:01
2012-03-05T00:00:01
2012-03-06T00:00:01
2012-03-07T00:00:01
2012-03-08T00:00:01
2012-03-09T00:00:01
2012-03-10T00:00:01
2012-03-11T00:00:01
2012-03-12T00:00:01
-- !test_timestamp_arithmetic_9 --
2012-02-29
2012-03-01
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
-- !test_timestamp_arithmetic_10 --
2012-02-29T23:59:59
2012-03-01T23:59:59
2012-03-02T23:59:59
2012-03-03T23:59:59
2012-03-04T23:59:59
2012-03-05T23:59:59
2012-03-06T23:59:59
2012-03-07T23:59:59
2012-03-08T23:59:59
2012-03-09T23:59:59
2012-03-10T23:59:59
2012-03-11T23:59:59
-- !test_timestamp_arithmetic_11 --
\N
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
2012-03-12
2012-03-13
-- !test_timestamp_arithmetic_12 --
\N
2012-03-01T00:00:01
2012-03-02T00:00:01
2012-03-03T00:00:01
2012-03-04T00:00:01
2012-03-05T00:00:01
2012-03-06T00:00:01
2012-03-07T00:00:01
2012-03-08T00:00:01
2012-03-09T00:00:01
2012-03-10T00:00:01
2012-03-11T00:00:01
2012-03-12T00:00:01
-- !test_timestamp_arithmetic_13 --
\N
2012-02-29
2012-03-01
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
-- !test_timestamp_arithmetic_14 --
\N
2012-02-29T23:59:59
2012-03-01T23:59:59
2012-03-02T23:59:59
2012-03-03T23:59:59
2012-03-04T23:59:59
2012-03-05T23:59:59
2012-03-06T23:59:59
2012-03-07T23:59:59
2012-03-08T23:59:59
2012-03-09T23:59:59
2012-03-10T23:59:59
2012-03-11T23:59:59
-- !test_timestamp_arithmetic_15 --
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
2012-03-12
2012-03-13
-- !test_timestamp_arithmetic_16 --
2012-03-01T00:00:01
2012-03-02T00:00:01
2012-03-03T00:00:01
2012-03-04T00:00:01
2012-03-05T00:00:01
2012-03-06T00:00:01
2012-03-07T00:00:01
2012-03-08T00:00:01
2012-03-09T00:00:01
2012-03-10T00:00:01
2012-03-11T00:00:01
2012-03-12T00:00:01
-- !test_timestamp_arithmetic_17 --
2012-02-29
2012-03-01
2012-03-02
2012-03-03
2012-03-04
2012-03-05
2012-03-06
2012-03-07
2012-03-08
2012-03-09
2012-03-10
2012-03-11
-- !test_timestamp_arithmetic_18 --
2012-02-29T23:59:59
2012-03-01T23:59:59
2012-03-02T23:59:59
2012-03-03T23:59:59
2012-03-04T23:59:59
2012-03-05T23:59:59
2012-03-06T23:59:59
2012-03-07T23:59:59
2012-03-08T23:59:59
2012-03-09T23:59:59
2012-03-10T23:59:59
2012-03-11T23:59:59
-- !test_timestamp_arithmetic_19 --
\N
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_20 --
\N
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_21 --
\N
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_22 --
\N
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_23 --
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_24 --
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_25 --
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_26 --
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_27 --
\N
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_28 --
\N
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_29 --
\N
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_30 --
\N
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_31 --
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_32 --
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_33 --
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_34 --
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_35 --
\N
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_36 --
\N
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_37 --
\N
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_38 --
\N
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_39 --
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_40 --
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_41 --
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_42 --
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_43 --
\N
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_44 --
\N
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_45 --
\N
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_46 --
\N
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11
-- !test_timestamp_arithmetic_47 --
2012-03-02T01:00:01
2012-03-03T02:01:02
2012-03-04T03:02:03
2012-03-05T04:03:04
2012-03-06T05:04:05
2012-03-07T06:05:06
2012-03-08T07:06:07
2012-03-09T08:07:08
2012-03-10T09:08:09
2012-03-11T10:09:10
2012-03-12T11:10:11
2012-03-13T12:11:12
-- !test_timestamp_arithmetic_48 --
2012-03-01T01:00:02
2012-03-02T02:01:03
2012-03-03T03:02:04
2012-03-04T04:03:05
2012-03-05T05:04:06
2012-03-06T06:05:07
2012-03-07T07:06:08
2012-03-08T08:07:09
2012-03-09T09:08:10
2012-03-10T10:09:11
2012-03-11T11:10:12
2012-03-12T12:11:13
-- !test_timestamp_arithmetic_49 --
2012-02-29T01:00:01
2012-03-01T02:01:02
2012-03-02T03:02:03
2012-03-03T04:03:04
2012-03-04T05:04:05
2012-03-05T06:05:06
2012-03-06T07:06:07
2012-03-07T08:07:08
2012-03-08T09:08:09
2012-03-09T10:09:10
2012-03-10T11:10:11
2012-03-11T12:11:12
-- !test_timestamp_arithmetic_50 --
2012-03-01T01:00
2012-03-02T02:01:01
2012-03-03T03:02:02
2012-03-04T04:03:03
2012-03-05T05:04:04
2012-03-06T06:05:05
2012-03-07T07:06:06
2012-03-08T08:07:07
2012-03-09T09:08:08
2012-03-10T10:09:09
2012-03-11T11:10:10
2012-03-12T12:11:11

View File

@ -0,0 +1,50 @@
set enable_nereids_planner=true;
set enable_fallback_to_original_planner=false;
select kdt + interval 1 day from fn_test order by kdt;
select kdt + interval 1 second from fn_test order by kdt;
select kdt - interval 1 day from fn_test order by kdt;
select kdt - interval 1 second from fn_test order by kdt;
select kdt + interval 1 day from fn_test_not_nullable order by kdt;
select kdt + interval 1 second from fn_test_not_nullable order by kdt;
select kdt - interval 1 day from fn_test_not_nullable order by kdt;
select kdt - interval 1 second from fn_test_not_nullable order by kdt;
select kdtv2 + interval 1 day from fn_test order by kdt;
select kdtv2 + interval 1 second from fn_test order by kdt;
select kdtv2 - interval 1 day from fn_test order by kdt;
select kdtv2 - interval 1 second from fn_test order by kdt;
select kdtv2 + interval 1 day from fn_test_not_nullable order by kdt;
select kdtv2 + interval 1 second from fn_test_not_nullable order by kdt;
select kdtv2 - interval 1 day from fn_test_not_nullable order by kdt;
select kdtv2 - interval 1 second from fn_test_not_nullable order by kdt;
select kdtm + interval 1 day from fn_test order by kdt;
select kdtm + interval 1 second from fn_test order by kdt;
select kdtm - interval 1 day from fn_test order by kdt;
select kdtm - interval 1 second from fn_test order by kdt;
select kdtm + interval 1 day from fn_test_not_nullable order by kdt;
select kdtm + interval 1 second from fn_test_not_nullable order by kdt;
select kdtm - interval 1 day from fn_test_not_nullable order by kdt;
select kdtm - interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s1 + interval 1 day from fn_test order by kdt;
select kdtmv2s1 + interval 1 second from fn_test order by kdt;
select kdtmv2s1 - interval 1 day from fn_test order by kdt;
select kdtmv2s1 - interval 1 second from fn_test order by kdt;
select kdtmv2s1 + interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s1 + interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s1 - interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s1 - interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s2 + interval 1 day from fn_test order by kdt;
select kdtmv2s2 + interval 1 second from fn_test order by kdt;
select kdtmv2s2 - interval 1 day from fn_test order by kdt;
select kdtmv2s2 - interval 1 second from fn_test order by kdt;
select kdtmv2s2 + interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s2 + interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s2 - interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s2 - interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s3 + interval 1 day from fn_test order by kdt;
select kdtmv2s3 + interval 1 second from fn_test order by kdt;
select kdtmv2s3 - interval 1 day from fn_test order by kdt;
select kdtmv2s3 - interval 1 second from fn_test order by kdt;
select kdtmv2s3 + interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s3 + interval 1 second from fn_test_not_nullable order by kdt;
select kdtmv2s3 - interval 1 day from fn_test_not_nullable order by kdt;
select kdtmv2s3 - interval 1 second from fn_test_not_nullable order by kdt;