[enhancement](Nereids) cast expression to the type with parameters (#14657)

This commit is contained in:
morrySnow
2022-12-23 18:29:50 +08:00
committed by GitHub
parent ef3da105c9
commit 27d64964e6
80 changed files with 479 additions and 642 deletions

View File

@ -21,19 +21,6 @@ parser grammar DorisParser;
options { tokenVocab = DorisLexer; }
@members {
/**
* When false, a literal with an exponent would be converted into
* double type rather than decimal type.
*/
public boolean legacy_exponent_literal_as_decimal_enabled = false;
/**
* When true, the behavior of keywords follows ANSI SQL standard.
*/
public boolean SQL_standard_keyword_behavior = true;
}
multiStatements
: (statement SEMICOLON*)+ EOF
;
@ -299,7 +286,7 @@ primaryExpression
RIGHT_PAREN #date_sub
| CASE whenClause+ (ELSE elseExpression=expression)? END #searchedCase
| CASE value=expression whenClause+ (ELSE elseExpression=expression)? END #simpleCase
| name=CAST LEFT_PAREN expression AS identifier RIGHT_PAREN #cast
| name=CAST LEFT_PAREN expression AS dataType RIGHT_PAREN #cast
| constant #constantDefault
| ASTERISK #star
| qualifiedName DOT ASTERISK #star
@ -346,6 +333,11 @@ unitIdentifier
: YEAR | MONTH | WEEK | DAY | HOUR | MINUTE | SECOND
;
dataType
: identifier (LEFT_PAREN INTEGER_VALUE
(COMMA INTEGER_VALUE)* RIGHT_PAREN)? #primitiveDataType
;
// this rule is used for explicitly capturing wrong identifiers such as test-table, which should actually be `test-table`
// replace identifier with errorCapturingIdentifier where the immediate follow symbol is not an expression, otherwise
// valid expressions such as "a-b" can be recognized as an identifier
@ -361,14 +353,12 @@ errorCapturingIdentifierExtra
identifier
: strictIdentifier
| {!SQL_standard_keyword_behavior}? strictNonReserved
;
strictIdentifier
: IDENTIFIER #unquotedIdentifier
| quotedIdentifier #quotedIdentifierAlternative
| {SQL_standard_keyword_behavior}? ansiNonReserved #unquotedIdentifier
| {!SQL_standard_keyword_behavior}? nonReserved #unquotedIdentifier
| nonReserved #unquotedIdentifier
;
quotedIdentifier
@ -380,272 +370,11 @@ number
| MINUS? (EXPONENT_VALUE | DECIMAL_VALUE) #decimalLiteral
;
// When `SQL_standard_keyword_behavior=true`, there are 2 kinds of keywords in Spark SQL.
// - Reserved keywords:
// Keywords that are reserved and can't be used as identifiers for table, view, column,
// function, alias, etc.
// there are 1 kinds of keywords in Doris.
// - Non-reserved keywords:
// Keywords that have a special meaning only in particular contexts and can be used as
// identifiers in other contexts. For example, `EXPLAIN SELECT ...` is a command, but EXPLAIN
// can be used as identifiers in other places.
// You can find the full keywords list by searching "Start of the keywords list" in this file.
// The non-reserved keywords are listed below. Keywords not in this list are reserved keywords.
ansiNonReserved
//--ANSI-NON-RESERVED-START
: ADD
| ADDDATE
| AFTER
| ALTER
| ANALYZE
| ANALYZED
| ANTI
| ARCHIVE
| ARRAY
| ASC
| AT
| AVG
| BETWEEN
| BUCKET
| BUCKETS
| BY
| CACHE
| CASCADE
| CATALOG
| CATALOGS
| CHANGE
| CLEAR
| CLUSTER
| CLUSTERED
| CODEGEN
| COLLECTION
| COLUMNS
| COMMENT
| COMMIT
| COMPACT
| COMPACTIONS
| COMPUTE
| CONCATENATE
| COST
| CUBE
| CURRENT
| DATA
| DATABASE
| DATABASES
| DATE
| DATE_ADD
| DATEDIFF
| DATE_DIFF
| DAY
| DAYS_ADD
| DAYS_SUB
| DATE_ADD
| DATE_SUB
| DBPROPERTIES
| DEFINED
| DELETE
| DELIMITED
| DESC
| DESCRIBE
| DFS
| DIRECTORIES
| DIRECTORY
| DISTRIBUTE
| DROP
| ESCAPED
| EXCHANGE
| EXISTS
| EXPLAIN
| EXPORT
| EXTENDED
| EXTERNAL
| EXTRACT
| FIELDS
| FILEFORMAT
| FIRST
| FOLLOWING
| FORMAT
| FORMATTED
| FUNCTION
| FUNCTIONS
| GLOBAL
| GROUPING
| GRAPH
| HOUR
| IF
| IGNORE
| IMPORT
| INDEX
| INDEXES
| INPATH
| INPUTFORMAT
| INSERT
| INTERVAL
| ISNULL
| ITEMS
| KEYS
| LAST
| LAZY
| LIKE
| ILIKE
| IS_NOT_NULL_PRED
| IS_NULL_PRED
| LIMIT
| OFFSET
| LINES
| LIST
| LOAD
| LOCAL
| LOCATION
| LOCK
| LOCKS
| LOGICAL
| MACRO
| MAP
| MATCHED
| MERGE
| MINUTE
| MONTH
| MSCK
| NAMESPACE
| NAMESPACES
| NO
| NULLS
| OF
| OPTIMIZED
| OPTION
| OPTIONS
| OUT
| OUTPUTFORMAT
| OVER
| OVERLAY
| OVERWRITE
| PARSED
| PARTITION
| PARTITIONED
| PARTITIONS
| PERCENTLIT
| PHYSICAL
| PIVOT
| PLACING
| PLAN
| POLICY
| POSITION
| PRECEDING
| PRINCIPALS
| PROPERTIES
| PURGE
| QUERY
| RANGE
| RECORDREADER
| RECORDWRITER
| RECOVER
| REDUCE
| REFRESH
| RENAME
| REPAIR
| REPEATABLE
| REPLACE
| RESET
| RESPECT
| RESTRICT
| REVOKE
| REWRITTEN
| RLIKE
| ROLE
| ROLES
| ROLLBACK
| ROLLUP
| ROW
| ROWS
| SCHEMA
| SCHEMAS
| SECOND
| SEMI
| SEPARATED
| SERDE
| SERDEPROPERTIES
| SET
| SETMINUS
| SETS
| SHOW
| SKEWED
| SORT
| SORTED
| START
| STATISTICS
| STORED
| STRATIFY
| STRUCT
| SUBDATE
| SUBSTR
| SUBSTRING
| SUM
| SYNC
| SYSTEM_TIME
| SYSTEM_VERSION
| TABLES
| TABLESAMPLE
| TBLPROPERTIES
| TEMPORARY
| TERMINATED
| TIMESTAMP
| TIMESTAMPADD
| TIMESTAMPDIFF
| TOUCH
| TRANSACTION
| TRANSACTIONS
| TRANSFORM
| TRIM
| TRUE
| TRUNCATE
| TRY_CAST
| TYPE
| UNARCHIVE
| UNBOUNDED
| UNCACHE
| UNLOCK
| UNSET
| UPDATE
| USE
| VALUES
| VERBOSE
| VERSION
| VIEW
| VIEWS
| WINDOW
| YEAR
| ZONE
//--ANSI-NON-RESERVED-END
;
// When `SQL_standard_keyword_behavior=false`, there are 2 kinds of keywords in Spark SQL.
// - Non-reserved keywords:
// Same definition as the one when `SQL_standard_keyword_behavior=true`.
// - Strict-non-reserved keywords:
// A strict version of non-reserved keywords, which can not be used as table alias.
// You can find the full keywords list by searching "Start of the keywords list" in this file.
// The strict-non-reserved keywords are listed in `strictNonReserved`.
// normal version of non-reserved keywords.
// The non-reserved keywords are listed in `nonReserved`.
// These 2 together contain all the keywords.
strictNonReserved
: ANTI
| CROSS
| EXCEPT
| FULL
| INNER
| INTERSECT
| JOIN
| LATERAL
| LEFT
| NATURAL
| ON
| RIGHT
| SEMI
| SETMINUS
| UNION
| USING
;
// TODO: need to stay consistent with the legacy
nonReserved
//--DEFAULT-NON-RESERVED-START
: ADD

View File

@ -65,6 +65,7 @@ import org.apache.doris.nereids.DorisParser.ParenthesizedExpressionContext;
import org.apache.doris.nereids.DorisParser.PlanTypeContext;
import org.apache.doris.nereids.DorisParser.PredicateContext;
import org.apache.doris.nereids.DorisParser.PredicatedContext;
import org.apache.doris.nereids.DorisParser.PrimitiveDataTypeContext;
import org.apache.doris.nereids.DorisParser.QualifiedNameContext;
import org.apache.doris.nereids.DorisParser.QueryContext;
import org.apache.doris.nereids.DorisParser.QueryOrganizationContext;
@ -776,7 +777,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
@Override
public Expression visitCast(DorisParser.CastContext ctx) {
return ParserUtils.withOrigin(ctx, () ->
new Cast(getExpression(ctx.expression()), DataType.convertFromString(ctx.identifier().getText())));
new Cast(getExpression(ctx.expression()), typedVisit(ctx.dataType())));
}
@Override
@ -1473,4 +1474,12 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
}
return ExplainLevel.ALL_PLAN;
}
@Override
public DataType visitPrimitiveDataType(PrimitiveDataTypeContext ctx) {
String dataType = ctx.identifier().getText().toLowerCase(Locale.ROOT);
List<String> l = Lists.newArrayList(dataType);
ctx.INTEGER_VALUE().stream().map(ParseTree::getText).forEach(l::add);
return DataType.convertPrimitiveFromStrings(l);
}
}

View File

@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.plans.commands.ExplainCommand;
import org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.types.DataType;
import com.google.common.collect.Lists;
import org.antlr.v4.runtime.CharStreams;
@ -90,6 +91,10 @@ public class NereidsParser {
return parse(expression, DorisParser::expression);
}
public DataType parseDataType(String dataType) {
return parse(dataType, DorisParser::dataType);
}
private <T> T parse(String sql, Function<DorisParser, ParserRuleContext> parseFunction) {
ParserRuleContext tree = toAst(sql, parseFunction);
LogicalPlanBuilder logicalPlanBuilder = new LogicalPlanBuilder();

View File

@ -61,7 +61,7 @@ public class Coalesce extends ScalarFunction
FunctionSignature.ret(DoubleType.INSTANCE).varArgs(DoubleType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).varArgs(DateTimeType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).varArgs(DateType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).varArgs(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).varArgs(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).varArgs(DateV2Type.INSTANCE),
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).varArgs(DecimalV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BitmapType.INSTANCE).varArgs(BitmapType.INSTANCE),

View File

@ -42,8 +42,8 @@ public class ConvertTz extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT)
);

View File

@ -41,7 +41,7 @@ public class CurrentTimestamp extends DateTimeWithPrecision
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(IntegerType.INSTANCE)
);
/**

View File

@ -41,7 +41,7 @@ public class Date extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -41,11 +41,12 @@ public class DateDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE)
);

View File

@ -43,7 +43,8 @@ public class DateFormat extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT)
);

View File

@ -40,7 +40,8 @@ public class DateTrunc extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, VarcharType.SYSTEM_DEFAULT)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT)
);
/**

View File

@ -38,7 +38,7 @@ public class DateV2 extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -41,7 +41,7 @@ public class Day extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class DayCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class DayFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class DayName extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class DayOfMonth extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class DayOfWeek extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class DayOfYear extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,7 +40,8 @@ import java.util.List;
public class DaysAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -41,14 +41,15 @@ public class DaysDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -40,7 +40,8 @@ import java.util.List;
public class DaysSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -57,7 +57,7 @@ public class Greatest extends ScalarFunction
FunctionSignature.ret(DoubleType.INSTANCE).varArgs(DoubleType.INSTANCE),
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).varArgs(DecimalV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeType.INSTANCE).varArgs(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).varArgs(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).varArgs(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).varArgs(StringType.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class Hour extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class HourCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class HourFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,9 +40,10 @@ import java.util.List;
public class HoursAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public HoursAdd(Expression arg0, Expression arg1) {

View File

@ -41,14 +41,15 @@ public class HoursDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -40,9 +40,10 @@ import java.util.List;
public class HoursSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public HoursSub(Expression arg0, Expression arg1) {

View File

@ -75,8 +75,8 @@ public class If extends ScalarFunction
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(BooleanType.INSTANCE, DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(BooleanType.INSTANCE, DateType.INSTANCE, DateType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(BooleanType.INSTANCE, DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(BooleanType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(BooleanType.INSTANCE, DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT)

View File

@ -41,7 +41,7 @@ public class LocalTime extends DateTimeWithPrecision
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(IntegerType.INSTANCE)
);
/**

View File

@ -41,7 +41,7 @@ public class LocalTimestamp extends DateTimeWithPrecision
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(IntegerType.INSTANCE)
);
/**

View File

@ -41,7 +41,7 @@ public class Minute extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class MinuteCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class MinuteFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -41,9 +41,10 @@ public class MinutesAdd extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public MinutesAdd(Expression arg0, Expression arg1) {

View File

@ -41,14 +41,15 @@ public class MinutesDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -41,9 +41,10 @@ public class MinutesSub extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public MinutesSub(Expression arg0, Expression arg1) {

View File

@ -41,7 +41,7 @@ public class Month extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class MonthCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class MonthFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class MonthName extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,8 @@ public class MonthsAdd extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -41,14 +41,15 @@ public class MonthsDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -40,7 +40,8 @@ import java.util.List;
public class MonthsSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class Now extends DateTimeWithPrecision
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(IntegerType.INSTANCE)
);
/**

View File

@ -61,7 +61,8 @@ public class NullIf extends ScalarFunction
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, DateType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT)
.args(DecimalV2Type.SYSTEM_DEFAULT, DecimalV2Type.SYSTEM_DEFAULT),

View File

@ -63,9 +63,12 @@ public class Nvl extends ScalarFunction
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT)
.args(DecimalV2Type.SYSTEM_DEFAULT, DecimalV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BitmapType.INSTANCE).args(BitmapType.INSTANCE, BitmapType.INSTANCE),

View File

@ -41,7 +41,7 @@ public class Quarter extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class Second extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class SecondCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,19 +40,21 @@ public class SecondFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -41,9 +41,10 @@ public class SecondsAdd extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public SecondsAdd(Expression arg0, Expression arg1) {

View File

@ -41,14 +41,15 @@ public class SecondsDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -41,9 +41,10 @@ public class SecondsSub extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
public SecondsSub(Expression arg0, Expression arg1) {

View File

@ -42,11 +42,12 @@ public class TimeDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(TimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(TimeV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE)
);

View File

@ -39,7 +39,7 @@ public class Timestamp extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -41,7 +41,7 @@ public class ToDate extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -38,7 +38,7 @@ public class ToDateV2 extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -44,7 +44,7 @@ public class UnixTimestamp extends ScalarFunction
FunctionSignature.ret(IntegerType.INSTANCE).args(),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE)

View File

@ -40,10 +40,10 @@ public class Week extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class WeekCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class WeekFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class WeekOfYear extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -41,7 +41,7 @@ public class Weekday extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
);

View File

@ -41,14 +41,15 @@ public class WeeksDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -42,7 +42,7 @@ public class Year extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE)
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -40,18 +40,20 @@ public class YearCeil extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,18 +40,20 @@ public class YearFloor extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE)
.args(DateTimeType.INSTANCE, IntegerType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE)
.args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(DateV2Type.INSTANCE)
.args(DateV2Type.INSTANCE, IntegerType.INSTANCE, DateV2Type.INSTANCE)
);

View File

@ -40,10 +40,10 @@ public class YearWeek extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -40,7 +40,8 @@ import java.util.List;
public class YearsAdd extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -41,14 +41,15 @@ public class YearsDiff extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE)
.args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateV2Type.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.INSTANCE)
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, DateTimeType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -40,7 +40,8 @@ import java.util.List;
public class YearsSub extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.INSTANCE).args(DateTimeV2Type.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -28,11 +28,11 @@ import org.joda.time.LocalDateTime;
public class DateTimeV2Literal extends DateTimeLiteral {
public DateTimeV2Literal(String s) {
super(DateTimeV2Type.INSTANCE, s);
super(DateTimeV2Type.SYSTEM_DEFAULT, s);
}
public DateTimeV2Literal(long year, long month, long day, long hour, long minute, long second) {
super(DateTimeV2Type.INSTANCE, year, month, day, hour, minute, second);
super(DateTimeV2Type.SYSTEM_DEFAULT, year, month, day, hour, minute, second);
}
public DateTimeV2Literal(DateTimeV2Type dataType,

View File

@ -21,6 +21,7 @@ import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
import org.apache.doris.nereids.trees.expressions.literal.DoubleLiteral;
import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
@ -33,12 +34,10 @@ import org.apache.doris.nereids.types.coercion.PrimitiveType;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Abstract class for all data type in Nereids.
@ -46,16 +45,8 @@ import java.util.regex.Pattern;
public abstract class DataType implements AbstractDataType {
public static final int DEFAULT_SCALE = 0;
public static final int DEFAULT_PRECISION = 9;
public static final int DATETIME_PRECISION = 18;
private static final Pattern CHAR_PATTERN = Pattern.compile("char(\\s*\\(\\s*(\\d+)\\s*\\))?");
private static final Pattern VARCHAR_PATTERN = Pattern.compile("varchar(\\s*\\(\\s*(\\d+)\\s*\\))?");
private static final Pattern DATETIME_PATTERN = Pattern.compile("datetime(\\s*\\(\\s*(\\d+)\\s*\\))?");
private static final Pattern DATETIME_V2_PATTERN = Pattern.compile("datetimev2(\\s*\\(\\s*(\\d+)\\s*\\))?");
private static final Pattern DECIMAL_PATTERN =
Pattern.compile("decimal(\\s*\\(\\s*(\\d+)(\\s*,\\s*(\\d+))?\\s*\\))?");
private static final Pattern DECIMAL_V3_PATTERN =
Pattern.compile("decimalv3(\\s*\\(\\s*(\\d+)(\\s*,\\s*(\\d+))?\\s*\\))?");
protected static final NereidsParser PARSER = new NereidsParser();
// use class and supplier here to avoid class load deadlock.
private static final Map<Class<? extends NumericType>, Supplier<DataType>> PROMOTION_MAP
@ -166,41 +157,74 @@ public abstract class DataType implements AbstractDataType {
* Convert to data type in Nereids.
* throw exception when cannot convert to Nereids type
*
* @param type data type in string representation
* @param types data type in string representation
* @return data type in Nereids
*/
public static DataType convertFromString(String type) {
// TODO: use a better way to resolve types
// TODO: support varchar, char, decimal
type = type.toLowerCase().trim();
public static DataType convertPrimitiveFromStrings(List<String> types) {
String type = types.get(0).toLowerCase().trim();
switch (type) {
case "bool":
case "boolean":
return BooleanType.INSTANCE;
case "tinyint":
case "tinyint(4)":
return TinyIntType.INSTANCE;
case "smallint":
case "smallint(6)":
return SmallIntType.INSTANCE;
case "int":
case "int(11)":
return IntegerType.INSTANCE;
case "bigint":
case "bigint(20)":
return BigIntType.INSTANCE;
case "largeint":
case "largeint(40)":
return LargeIntType.INSTANCE;
case "float":
return FloatType.INSTANCE;
case "double":
return DoubleType.INSTANCE;
case "decimal":
return fromCatalogType(ScalarType.createDecimalType());
switch (types.size()) {
case 1:
return DecimalV2Type.SYSTEM_DEFAULT;
case 2:
return DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)), 0);
case 3:
return DecimalV2Type.createDecimalV2Type(
Integer.parseInt(types.get(1)), Integer.parseInt(types.get(2)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "decimalv3":
switch (types.size()) {
case 1:
return DecimalV3Type.SYSTEM_DEFAULT;
case 2:
return DecimalV3Type.createDecimalV3Type(Integer.parseInt(types.get(1)));
case 3:
return DecimalV3Type.createDecimalV3Type(
Integer.parseInt(types.get(1)), Integer.parseInt(types.get(2)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "text":
case "string":
return StringType.INSTANCE;
case "varchar":
switch (types.size()) {
case 1:
return VarcharType.SYSTEM_DEFAULT;
case 2:
return VarcharType.createVarcharType(Integer.parseInt(types.get(1)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "char":
switch (types.size()) {
case 1:
return CharType.SYSTEM_DEFAULT;
case 2:
return CharType.createCharType(Integer.parseInt(types.get(1)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "null":
case "null_type": // ScalarType.NULL.toSql() return "null_type", so support it
return NullType.INSTANCE;
@ -210,6 +234,24 @@ public abstract class DataType implements AbstractDataType {
return DateV2Type.INSTANCE;
case "time":
return TimeType.INSTANCE;
case "datetime":
switch (types.size()) {
case 1:
return DateTimeType.INSTANCE;
case 2:
return DateTimeV2Type.of(Integer.parseInt(types.get(1)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "datetimev2":
switch (types.size()) {
case 1:
return DateTimeV2Type.SYSTEM_DEFAULT;
case 2:
return DateTimeV2Type.of(Integer.parseInt(types.get(1)));
default:
throw new AnalysisException("Nereids do not support type: " + type);
}
case "hll":
return HllType.INSTANCE;
case "bitmap":
@ -219,32 +261,29 @@ public abstract class DataType implements AbstractDataType {
case "json":
return JsonType.INSTANCE;
default:
Optional<DataType> newType = matchVarchar(type);
if (newType.isPresent()) {
return newType.get();
}
newType = matchChar(type);
if (newType.isPresent()) {
return newType.get();
}
newType = matchDateTime(type);
if (newType.isPresent()) {
return newType.get();
}
newType = matchDecimalType(type);
if (newType.isPresent()) {
return newType.get();
}
if (type.startsWith("array")) {
return resolveArrayType(type);
}
throw new AnalysisException("Nereids do not support type: " + type);
}
}
/**
* Convert to data type in Nereids.
* throw exception when cannot convert to Nereids type
*
* @param type data type in string representation
* @return data type in Nereids
*/
public static DataType convertFromString(String type) {
try {
return PARSER.parseDataType(type);
} catch (Exception e) {
// TODO: remove it when Nereids parser support array
if (type.startsWith("array")) {
return resolveArrayType(type);
}
throw e;
}
}
/**
* just for generate function and migrate to nereids
* @param type legacy date type
@ -459,85 +498,6 @@ public abstract class DataType implements AbstractDataType {
public abstract int width();
private static Optional<DataType> matchChar(String type) {
Matcher matcher = CHAR_PATTERN.matcher(type);
if (matcher.find() && matcher.group().equals(type)) {
String len = matcher.group(2);
CharType charType = len != null
? CharType.createCharType(Integer.parseInt(len))
: CharType.SYSTEM_DEFAULT;
return Optional.of(charType);
}
return Optional.empty();
}
private static Optional<DataType> matchVarchar(String type) {
Matcher matcher = VARCHAR_PATTERN.matcher(type);
if (matcher.find() && matcher.group().equals(type)) {
String scale = matcher.group(2);
VarcharType varcharType = scale != null
? VarcharType.createVarcharType(Integer.parseInt(scale))
: VarcharType.SYSTEM_DEFAULT;
return Optional.of(varcharType);
}
return Optional.empty();
}
private static Optional<DataType> matchDateTime(String type) {
Matcher matcher = DATETIME_PATTERN.matcher(type);
if (matcher.find() && matcher.group().equals(type)) {
String scale = matcher.group(2);
return Optional.of(
fromCatalogType(scale != null
? ScalarType.createDatetimeV2Type(Integer.parseInt(scale))
: ScalarType.createDatetimeType())
);
}
matcher = DATETIME_V2_PATTERN.matcher(type);
if (matcher.find()) {
String scale = matcher.group(2);
return Optional.of(
fromCatalogType(scale != null
? ScalarType.createDatetimeV2Type(Integer.parseInt(scale))
: ScalarType.createDatetimeV2Type(0))
);
}
return Optional.empty();
}
private static Optional<DataType> matchDecimalType(String type) {
Matcher matcher = DECIMAL_PATTERN.matcher(type);
if (matcher.find() && matcher.group().equals(type)) {
String precision = matcher.group(2);
String scale = matcher.group(4);
if (scale != null) {
return Optional.of(fromCatalogType(
ScalarType.createDecimalType(Integer.parseInt(precision), Integer.parseInt(scale))));
}
if (precision != null) {
return Optional.of(fromCatalogType(ScalarType.createDecimalType(Integer.parseInt(precision))));
}
return Optional.of(fromCatalogType(ScalarType.createDecimalType()));
}
matcher = DECIMAL_V3_PATTERN.matcher(type);
if (matcher.find() && matcher.group().equals(type)) {
String precision = matcher.group(2);
String scale = matcher.group(4);
if (scale != null) {
return Optional.of(fromCatalogType(
ScalarType.createDecimalV3Type(Integer.parseInt(precision), Integer.parseInt(scale))));
}
if (precision != null) {
return Optional.of(fromCatalogType(ScalarType.createDecimalV3Type(Integer.parseInt(precision))));
}
return Optional.of(fromCatalogType(ScalarType.createDecimalV3Type()));
}
return Optional.empty();
}
private static ArrayType resolveArrayType(String type) {
if (!type.startsWith("array")) {
throw new AnalysisException("Not array type: " + type);

View File

@ -19,6 +19,7 @@ package org.apache.doris.nereids.types;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.types.coercion.DateLikeType;
import com.google.common.base.Preconditions;
@ -30,7 +31,7 @@ import java.util.Objects;
*/
public class DateTimeV2Type extends DateLikeType {
public static final int MAX_SCALE = 6;
public static final DateTimeV2Type INSTANCE = new DateTimeV2Type(0);
public static final DateTimeV2Type SYSTEM_DEFAULT = new DateTimeV2Type(0);
private static final int WIDTH = 8;
@ -41,9 +42,14 @@ public class DateTimeV2Type extends DateLikeType {
this.scale = scale;
}
/**
* create DateTimeV2Type from scale
*/
public static DateTimeV2Type of(int scale) {
if (scale == INSTANCE.scale) {
return INSTANCE;
if (scale == SYSTEM_DEFAULT.scale) {
return SYSTEM_DEFAULT;
} else if (scale > MAX_SCALE || scale < 0) {
throw new AnalysisException("Scale of Datetime/Time must between 0 and 6. Scale was set to: " + scale);
} else {
return new DateTimeV2Type(scale);
}

View File

@ -38,6 +38,7 @@ public class DecimalV2Type extends FractionalType {
public static int MAX_PRECISION = 27;
public static int MAX_SCALE = 9;
public static final DecimalV2Type SYSTEM_DEFAULT = new DecimalV2Type(MAX_PRECISION, MAX_SCALE);
public static final DecimalV2Type CATALOG_DEFAULT = new DecimalV2Type(DEFAULT_PRECISION, DEFAULT_SCALE);
private static final DecimalV2Type BOOLEAN_DECIMAL = new DecimalV2Type(1, 0);
private static final DecimalV2Type TINYINT_DECIMAL = new DecimalV2Type(3, 0);
@ -76,6 +77,9 @@ public class DecimalV2Type extends FractionalType {
if (precision == SYSTEM_DEFAULT.precision && scale == SYSTEM_DEFAULT.scale) {
return SYSTEM_DEFAULT;
}
if (precision == CATALOG_DEFAULT.precision && scale == CATALOG_DEFAULT.scale) {
return CATALOG_DEFAULT;
}
return new DecimalV2Type(Math.min(precision, MAX_PRECISION), Math.min(scale, MAX_SCALE));
}

View File

@ -36,13 +36,12 @@ import java.util.Objects;
*/
@Developing
public class DecimalV3Type extends FractionalType {
public static final int MAX_DECIMALV2_SCALE = 9;
public static final int MAX_DECIMAL32_PRECISION = 9;
public static final int MAX_DECIMAL64_PRECISION = 18;
public static final int MAX_DECIMAL128_PRECISION = 38;
public static final DecimalV3Type DEFAULT_DECIMAL32 = new DecimalV3Type(DEFAULT_PRECISION, DEFAULT_SCALE);
public static final DecimalV3Type DEFAULT_DECIMAL64 = new DecimalV3Type(DEFAULT_PRECISION, DEFAULT_SCALE);
public static final DecimalV3Type DEFAULT_DECIMAL32 = new DecimalV3Type(MAX_DECIMAL32_PRECISION, DEFAULT_SCALE);
public static final DecimalV3Type DEFAULT_DECIMAL64 = new DecimalV3Type(MAX_DECIMAL64_PRECISION, DEFAULT_SCALE);
public static final DecimalV3Type DEFAULT_DECIMAL128 = new DecimalV3Type(MAX_DECIMAL128_PRECISION, DEFAULT_SCALE);
public static final DecimalV3Type SYSTEM_DEFAULT = DEFAULT_DECIMAL32;
@ -82,22 +81,21 @@ public class DecimalV3Type extends FractionalType {
/** createDecimalV3Type. */
public static DecimalV3Type createDecimalV3Type(int precision) {
if (precision <= MAX_DECIMAL32_PRECISION) {
return DEFAULT_DECIMAL32;
}
if (precision <= MAX_DECIMAL64_PRECISION) {
return DEFAULT_DECIMAL64;
}
if (precision <= MAX_DECIMAL128_PRECISION) {
return DEFAULT_DECIMAL128;
}
return createDecimalV3Type(precision, DEFAULT_SCALE);
}
return new DecimalV3Type(Math.min(precision, MAX_DECIMAL128_PRECISION), DEFAULT_SCALE);
/** createDecimalV3Type. */
public static DecimalV3Type createDecimalV3Type(int precision, int scale) {
Preconditions.checkArgument(precision > 0 && precision <= MAX_DECIMAL128_PRECISION);
Preconditions.checkArgument(scale >= 0);
Preconditions.checkArgument(precision >= scale);
return new DecimalV3Type(precision, scale);
}
public static DecimalV3Type createDecimalV3Type(BigDecimal bigDecimal) {
int precision = org.apache.doris.analysis.DecimalLiteral.getBigDecimalPrecision(bigDecimal);
return createDecimalV3Type(precision);
int scale = org.apache.doris.analysis.DecimalLiteral.getBigDecimalScale(bigDecimal);
return createDecimalV3Type(precision, scale);
}
public static DecimalV3Type widerDecimalV3Type(DecimalV3Type left, DecimalV3Type right) {

View File

@ -23,6 +23,7 @@ import org.apache.doris.common.Pair;
import org.apache.doris.nereids.StatementContext;
import org.apache.doris.nereids.exceptions.ParseException;
import org.apache.doris.nereids.glue.LogicalPlanAdapter;
import org.apache.doris.nereids.trees.expressions.Cast;
import org.apache.doris.nereids.trees.expressions.literal.DecimalLiteral;
import org.apache.doris.nereids.trees.plans.JoinHint;
import org.apache.doris.nereids.trees.plans.JoinType;
@ -34,6 +35,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalCTE;
import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import org.apache.doris.nereids.types.DecimalV2Type;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -232,7 +234,7 @@ public class NereidsParserTest extends ParserTestBase {
}
@Test
public void parseDecimal() {
public void testParseDecimal() {
String f1 = "SELECT col1 * 0.267081789095306 FROM t";
NereidsParser nereidsParser = new NereidsParser();
LogicalPlan logicalPlan = nereidsParser.parseSingle(f1);
@ -299,4 +301,15 @@ public class NereidsParserTest extends ParserTestBase {
parsePlan("select * from t1 join [shuffle,broadcast] t2 on t1.key=t2.key")
.assertThrowsExactly(ParseException.class);
}
@Test
public void testParseCast() {
String sql = "SELECT CAST(1 AS DECIMAL(20, 6)) FROM t";
NereidsParser nereidsParser = new NereidsParser();
LogicalPlan logicalPlan = nereidsParser.parseSingle(sql);
Cast cast = (Cast) logicalPlan.getExpressions().get(0).child(0);
DecimalV2Type decimalV2Type = (DecimalV2Type) cast.getDataType();
Assertions.assertEquals(20, decimalV2Type.getPrecision());
Assertions.assertEquals(6, decimalV2Type.getScale());
}
}

View File

@ -236,68 +236,68 @@ public class ExpressionRewriteTest extends ExpressionRewriteTestHelper {
// DateTimeV2 -> DateTime
assertRewrite(
new GreaterThan(new Cast(dt, DateTimeV2Type.INSTANCE), dtv2),
new GreaterThan(new Cast(dt, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new GreaterThan(dt, dt));
// DateTimeV2 -> DateV2
assertRewrite(
new GreaterThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2),
new GreaterThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new GreaterThan(dv2, dv2));
assertRewrite(
new LessThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2),
new LessThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new LessThan(dv2, dv2PlusOne));
assertRewrite(
new EqualTo(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2),
new EqualTo(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2));
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2));
// DateTime -> DateV2
assertRewrite(
new GreaterThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dt),
new GreaterThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new GreaterThan(dv2, dv2));
assertRewrite(
new LessThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dt),
new LessThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new LessThan(dv2, dv2PlusOne));
assertRewrite(
new EqualTo(new Cast(dv2, DateTimeV2Type.INSTANCE), dt),
new EqualTo(new Cast(dv2, DateTimeV2Type.INSTANCE), dt));
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dt));
// DateTimeV2 -> Date
assertRewrite(
new GreaterThan(new Cast(d, DateTimeV2Type.INSTANCE), dtv2),
new GreaterThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new GreaterThan(d, d));
assertRewrite(
new LessThan(new Cast(d, DateTimeV2Type.INSTANCE), dtv2),
new LessThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new LessThan(d, dPlusOne));
assertRewrite(
new EqualTo(new Cast(d, DateTimeV2Type.INSTANCE), dtv2),
new EqualTo(new Cast(d, DateTimeV2Type.INSTANCE), dtv2));
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2));
// DateTime -> Date
assertRewrite(
new GreaterThan(new Cast(d, DateTimeV2Type.INSTANCE), dt),
new GreaterThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new GreaterThan(d, d));
assertRewrite(
new LessThan(new Cast(d, DateTimeV2Type.INSTANCE), dt),
new LessThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new LessThan(d, dPlusOne));
assertRewrite(
new EqualTo(new Cast(d, DateTimeV2Type.INSTANCE), dt),
new EqualTo(new Cast(d, DateTimeV2Type.INSTANCE), dt));
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dt),
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dt));
// DateV2 -> Date
assertRewrite(
new GreaterThan(new Cast(d, DateTimeV2Type.INSTANCE), dv2),
new GreaterThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dv2),
new GreaterThan(d, d));
// test hour, minute and second all zero
Expression dtv2AtZeroClock = new DateTimeV2Literal(1, 1, 1, 0, 0, 0);
assertRewrite(
new GreaterThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2AtZeroClock),
new GreaterThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2AtZeroClock),
new GreaterThan(dv2, dv2));
assertRewrite(
new LessThan(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2AtZeroClock),
new LessThan(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2AtZeroClock),
new LessThan(dv2, dv2));
assertRewrite(
new EqualTo(new Cast(dv2, DateTimeV2Type.INSTANCE), dtv2AtZeroClock),
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT), dtv2AtZeroClock),
new EqualTo(dv2, dv2));
}

View File

@ -50,4 +50,62 @@ public class DataTypeTest {
Assertions.assertNotEquals(varcharType1, varcharType3);
Assertions.assertNotEquals(varcharType1.hashCode(), varcharType3.hashCode());
}
@Test
void testConvertFromString() {
// boolean
Assertions.assertEquals(BooleanType.INSTANCE, DataType.convertFromString("bool"));
Assertions.assertEquals(BooleanType.INSTANCE, DataType.convertFromString("boolean"));
// tinyint
Assertions.assertEquals(TinyIntType.INSTANCE, DataType.convertFromString("tinyint"));
// smallint
Assertions.assertEquals(SmallIntType.INSTANCE, DataType.convertFromString("smallint"));
// int
Assertions.assertEquals(IntegerType.INSTANCE, DataType.convertFromString("int"));
// bigint
Assertions.assertEquals(BigIntType.INSTANCE, DataType.convertFromString("bigint"));
// largeint
Assertions.assertEquals(LargeIntType.INSTANCE, DataType.convertFromString("largeint"));
// float
Assertions.assertEquals(FloatType.INSTANCE, DataType.convertFromString("float"));
// double
Assertions.assertEquals(DoubleType.INSTANCE, DataType.convertFromString("double"));
// decimalv2
Assertions.assertEquals(DecimalV2Type.createDecimalV2Type(13, 9),
DataType.convertFromString("decimal(13, 9)"));
// decimalv3
Assertions.assertEquals(DecimalV3Type.createDecimalV3Type(13, 9),
DataType.convertFromString("decimalv3(13, 9)"));
// text
Assertions.assertEquals(StringType.INSTANCE, DataType.convertFromString("text"));
// string
Assertions.assertEquals(StringType.INSTANCE, DataType.convertFromString("string"));
// char
Assertions.assertEquals(CharType.createCharType(10), DataType.convertFromString("char(10)"));
// varchar
Assertions.assertEquals(VarcharType.createVarcharType(10), DataType.convertFromString("varchar(10)"));
// null
Assertions.assertEquals(NullType.INSTANCE, DataType.convertFromString("null"));
Assertions.assertEquals(NullType.INSTANCE, DataType.convertFromString("null_type"));
// date
Assertions.assertEquals(DateType.INSTANCE, DataType.convertFromString("date"));
// datev2
Assertions.assertEquals(DateV2Type.INSTANCE, DataType.convertFromString("datev2"));
// time
Assertions.assertEquals(TimeType.INSTANCE, DataType.convertFromString("time"));
// datetime
Assertions.assertEquals(DateTimeType.INSTANCE, DataType.convertFromString("datetime"));
// datetimev2
Assertions.assertEquals(DateTimeV2Type.of(3), DataType.convertFromString("datetimev2(3)"));
// hll
Assertions.assertEquals(HllType.INSTANCE, DataType.convertFromString("hll"));
// bitmap
Assertions.assertEquals(BitmapType.INSTANCE, DataType.convertFromString("bitmap"));
// quantile_state
Assertions.assertEquals(QuantileStateType.INSTANCE, DataType.convertFromString("quantile_state"));
// json
Assertions.assertEquals(JsonType.INSTANCE, DataType.convertFromString("json"));
// array
Assertions.assertEquals(ArrayType.of(IntegerType.INSTANCE), DataType.convertFromString("array<int>"));
}
}