[feature-wip] Support in predicate for datev2 type (#10810)
This commit is contained in:
@ -167,10 +167,12 @@ public class CastExpr extends Expr {
|
||||
}
|
||||
String typeName = Function.getUdfTypeName(toType.getPrimitiveType());
|
||||
// only refactor date/datetime for vectorized engine.
|
||||
if (toType.getPrimitiveType() == PrimitiveType.DATE
|
||||
|| toType.getPrimitiveType() == PrimitiveType.DATEV2) {
|
||||
if (toType.getPrimitiveType() == PrimitiveType.DATE) {
|
||||
typeName = "date_val";
|
||||
}
|
||||
if (toType.getPrimitiveType() == PrimitiveType.DATEV2) {
|
||||
typeName = "datev2_val";
|
||||
}
|
||||
String beSymbol = "doris::" + beClass + "::cast_to_"
|
||||
+ typeName;
|
||||
functionSet.addBuiltinBothScalaAndVectorized(ScalarFunction.createBuiltin(getFnName(toType),
|
||||
|
||||
@ -175,7 +175,7 @@ public class DateLiteral extends LiteralExpr {
|
||||
public DateLiteral(Type type, boolean isMax) throws AnalysisException {
|
||||
super();
|
||||
this.type = type;
|
||||
if (type.equals(Type.DATE)) {
|
||||
if (type.equals(Type.DATE) || type.equals(Type.DATEV2)) {
|
||||
if (isMax) {
|
||||
copy(MAX_DATE);
|
||||
} else {
|
||||
@ -479,9 +479,10 @@ public class DateLiteral extends LiteralExpr {
|
||||
return this;
|
||||
}
|
||||
if (targetType.equals(Type.DATE) || targetType.equals(Type.DATEV2)) {
|
||||
return new DateLiteral(this.year, this.month, this.day);
|
||||
return new DateLiteral(this.year, this.month, this.day, targetType);
|
||||
} else if (targetType.equals(Type.DATETIME)) {
|
||||
return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.second);
|
||||
return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.second,
|
||||
targetType);
|
||||
} else if (targetType.isDatetimeV2()) {
|
||||
return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.microsecond,
|
||||
targetType);
|
||||
|
||||
@ -519,9 +519,10 @@ public class Function implements Writable {
|
||||
return "string_val";
|
||||
case DATE:
|
||||
case DATETIME:
|
||||
case DATEV2:
|
||||
case DATETIMEV2:
|
||||
return "datetime_val";
|
||||
case DATEV2:
|
||||
return "datev2_val";
|
||||
case DECIMALV2:
|
||||
return "decimalv2_val";
|
||||
case DECIMAL32:
|
||||
@ -567,9 +568,10 @@ public class Function implements Writable {
|
||||
return "StringVal";
|
||||
case DATE:
|
||||
case DATETIME:
|
||||
case DATEV2:
|
||||
case DATETIMEV2:
|
||||
return "DateTimeVal";
|
||||
case DATEV2:
|
||||
return "DateV2Val";
|
||||
case DECIMALV2:
|
||||
return "DecimalV2Val";
|
||||
case DECIMAL32:
|
||||
|
||||
@ -1388,6 +1388,19 @@ public class FunctionSet<T> {
|
||||
"",
|
||||
"",
|
||||
true, false, true, true));
|
||||
addBuiltin(AggregateFunction.createBuiltin(FunctionSet.WINDOW_FUNNEL,
|
||||
Lists.newArrayList(Type.BIGINT, Type.STRING, Type.DATEV2, Type.BOOLEAN),
|
||||
Type.INT,
|
||||
Type.VARCHAR,
|
||||
true,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
true, false, true, true));
|
||||
|
||||
for (Type t : Type.getSupportedTypes()) {
|
||||
if (t.isNull()) {
|
||||
@ -2328,7 +2341,7 @@ public class FunctionSet<T> {
|
||||
// collect_list
|
||||
Type[] arraySubTypes = {Type.BOOLEAN, Type.SMALLINT, Type.TINYINT, Type.INT, Type.BIGINT, Type.LARGEINT,
|
||||
Type.FLOAT, Type.DOUBLE, Type.DATE, Type.DATETIME, Type.DECIMALV2, Type.DECIMAL32, Type.DECIMAL64,
|
||||
Type.DECIMAL128, Type.VARCHAR, Type.STRING};
|
||||
Type.DECIMAL128, Type.VARCHAR, Type.STRING, Type.DATEV2};
|
||||
for (Type t : arraySubTypes) {
|
||||
addBuiltin(AggregateFunction.createBuiltin(COLLECT_LIST, Lists.newArrayList(t), new ArrayType(t), t,
|
||||
"", "", "", "", "", true, false, true, true));
|
||||
@ -2462,6 +2475,16 @@ public class FunctionSet<T> {
|
||||
prefix + "20timestamp_avg_removeEPN9doris_udf15FunctionContextERKNS1_11DateTimeValEPNS1_9StringValE",
|
||||
prefix + "22timestamp_avg_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
|
||||
false, true, false, true));
|
||||
addBuiltin(AggregateFunction.createBuiltin("avg",
|
||||
Lists.<Type>newArrayList(Type.DATEV2), Type.DATEV2, Type.DATEV2,
|
||||
prefix + "8avg_initEPN9doris_udf15FunctionContextEPNS1_9StringValE",
|
||||
prefix + "20timestamp_avg_updateEPN9doris_udf15FunctionContextERKNS1_11DateTimeValEPNS1_9StringValE",
|
||||
prefix + "9avg_mergeEPN9doris_udf15FunctionContextERKNS1_9StringValEPS4_",
|
||||
stringValSerializeOrFinalize,
|
||||
prefix + "23timestamp_avg_get_valueEPN9doris_udf15FunctionContextERKNS1_9StringValE",
|
||||
prefix + "20timestamp_avg_removeEPN9doris_udf15FunctionContextERKNS1_11DateTimeValEPNS1_9StringValE",
|
||||
prefix + "22timestamp_avg_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
|
||||
false, true, false, true));
|
||||
|
||||
// Group_concat(string)
|
||||
addBuiltin(AggregateFunction.createBuiltin("group_concat", Lists.<Type>newArrayList(Type.VARCHAR), Type.VARCHAR,
|
||||
|
||||
@ -730,15 +730,6 @@ public class ScalarType extends Type {
|
||||
return false;
|
||||
}
|
||||
ScalarType other = (ScalarType) o;
|
||||
if ((this.isDate() && other.isDateV2()) || (this.isDateV2() && other.isDate())) {
|
||||
return true;
|
||||
}
|
||||
if ((this.isDatetime() && other.isDatetimeV2()) || (this.isTime() && other.isTimeV2())) {
|
||||
return other.decimalScale() == 0;
|
||||
}
|
||||
if ((this.isDatetimeV2() && other.isDatetime()) || (this.isTimeV2() && other.isTime())) {
|
||||
return this.decimalScale() == 0;
|
||||
}
|
||||
if ((this.isDatetimeV2() && other.isDatetimeV2()) || (this.isTimeV2() && other.isTimeV2())) {
|
||||
return this.decimalScale() == other.decimalScale();
|
||||
}
|
||||
@ -757,6 +748,10 @@ public class ScalarType extends Type {
|
||||
if (type.isDecimalV2Type() || type == PrimitiveType.DATETIMEV2 || type == PrimitiveType.TIMEV2) {
|
||||
return precision == other.precision && scale == other.scale;
|
||||
}
|
||||
if (type == PrimitiveType.DATETIMEV2 || type == PrimitiveType.TIMEV2) {
|
||||
return precision == other.precision && scale == other.scale
|
||||
&& type == ((ScalarType) o).getPrimitiveType();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ public class ColumnTypeTest {
|
||||
|
||||
TypeDef type5 = TypeDef.createDatetimeV2(0);
|
||||
TypeDef type6 = TypeDef.create(PrimitiveType.DATETIME);
|
||||
Assert.assertEquals(type5.getType(), type6.getType());
|
||||
Assert.assertNotEquals(type5.getType(), type6.getType());
|
||||
Assert.assertNotEquals(type.getType(), type6.getType());
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ public class ColumnTypeTest {
|
||||
TypeDef type = TypeDef.create(PrimitiveType.DATE);
|
||||
TypeDef type2 = TypeDef.create(PrimitiveType.DATEV2);
|
||||
type.analyze(null);
|
||||
Assert.assertEquals(type.getType(), type2.getType());
|
||||
Assert.assertNotEquals(type.getType(), type2.getType());
|
||||
|
||||
// different type
|
||||
TypeDef type3 = TypeDef.createDatetimeV2(6);
|
||||
@ -182,7 +182,7 @@ public class ColumnTypeTest {
|
||||
|
||||
TypeDef type5 = TypeDef.createTimeV2(0);
|
||||
TypeDef type6 = TypeDef.create(PrimitiveType.TIME);
|
||||
Assert.assertEquals(type5.getType(), type6.getType());
|
||||
Assert.assertNotEquals(type5.getType(), type6.getType());
|
||||
Assert.assertNotEquals(type.getType(), type6.getType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user