[Improvement](functions)Optimized some datetime function's return value (#18369)

This commit is contained in:
zclllyybb
2023-04-19 15:51:11 +08:00
committed by GitHub
parent 1f5f5a12b6
commit fb377a9da9
31 changed files with 462 additions and 279 deletions

View File

@ -46,12 +46,16 @@ private:
static const int min_be_exec_version;
};
// When we have some breaking change for execute engine, we should update be_exec_version.
// 0: not contain be_exec_version.
// 1: start from doris 1.2
// a. remove ColumnString terminating zero.
// b. runtime filter use new hash method.
inline const int BeExecVersionManager::max_be_exec_version = 1;
/*
* When we have some breaking change for execute engine, we should update be_exec_version.
* 0: not contain be_exec_version.
* 1: start from doris 1.2
* a. remove ColumnString terminating zero.
* b. runtime filter use new hash method.
* 2: start from doris 2.0
* a. function month/day/hour/minute/second's return type is changed to smaller type.
*/
inline const int BeExecVersionManager::max_be_exec_version = 2;
inline const int BeExecVersionManager::min_be_exec_version = 0;
} // namespace doris

View File

@ -225,6 +225,7 @@ Status BlockChanger::change_block(vectorized::Block* ref_block,
ObjectPool pool;
RuntimeState* state = pool.add(new RuntimeState());
state->set_desc_tbl(&_desc_tbl);
state->set_be_exec_version(_fe_compatible_version);
RowDescriptor row_desc =
RowDescriptor(_desc_tbl.get_tuple_descriptor(_desc_tbl.get_row_tuples()[0]), false);
@ -1087,6 +1088,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
sc_params.ref_rowset_readers = rs_readers;
sc_params.delete_handler = &delete_handler;
sc_params.base_tablet_schema = base_tablet_schema;
sc_params.be_exec_version = request.be_exec_version;
DCHECK(request.__isset.alter_tablet_type);
switch (request.alter_tablet_type) {
case TAlterTabletType::SCHEMA_CHANGE:
@ -1651,6 +1653,7 @@ Status SchemaChangeHandler::_parse_request(const SchemaChangeParams& sc_params,
BlockChanger* changer, bool* sc_sorting,
bool* sc_directly) {
changer->set_type(sc_params.alter_tablet_type);
changer->set_compatible_version(sc_params.be_exec_version);
TabletSharedPtr base_tablet = sc_params.base_tablet;
TabletSharedPtr new_tablet = sc_params.new_tablet;

View File

@ -17,6 +17,8 @@
#pragma once
#include <cstdint>
#include "common/status.h"
#include "gen_cpp/AgentService_types.h"
#include "olap/column_mapping.h"
@ -48,6 +50,8 @@ public:
void set_type(AlterTabletType type) { _type = type; }
void set_compatible_version(int32_t version) noexcept { _fe_compatible_version = version; }
bool has_where() const { return _where_expr != nullptr; }
private:
@ -62,6 +66,8 @@ private:
std::shared_ptr<TExpr> _where_expr;
AlterTabletType _type;
int32_t _fe_compatible_version = -1;
};
class SchemaChange {
@ -263,6 +269,7 @@ private:
std::unordered_map<std::string, AlterMaterializedViewParam> materialized_params_map;
DescriptorTbl* desc_tbl = nullptr;
ObjectPool pool;
int32_t be_exec_version;
};
static Status _do_process_alter_tablet_v2(const TAlterTabletReqV2& request);

View File

@ -372,6 +372,8 @@ public:
return 0;
}
void set_be_exec_version(int32_t version) noexcept { _query_options.be_exec_version = version; }
private:
Status create_error_log_file();

View File

@ -55,8 +55,9 @@ doris::Status VectorizedFnCall::prepare(doris::RuntimeState* state,
"and restart be.");
}
} else {
_function = SimpleFunctionFactory::instance().get_function(_fn.name.function_name,
argument_template, _data_type);
// get the function. won't prepare function.
_function = SimpleFunctionFactory::instance().get_function(
_fn.name.function_name, argument_template, _data_type, state->be_exec_version());
}
if (_function == nullptr) {
std::string type_str;

View File

@ -300,11 +300,14 @@ public:
using FunctionBuilderPtr = std::shared_ptr<IFunctionBuilder>;
/// used in function_factory. when we register a function, save a builder. to get a function, to get a builder.
/// will use DefaultFunctionBuilder as the default builder in function's registration if we didn't explicitly specify.
class FunctionBuilderImpl : public IFunctionBuilder {
public:
FunctionBasePtr build(const ColumnsWithTypeAndName& arguments,
const DataTypePtr& return_type) const final {
const DataTypePtr& func_return_type = get_return_type(arguments);
// check return types equal.
DCHECK(return_type->equals(*func_return_type) ||
// For null constant argument, `get_return_type` would return
// Nullable<DataTypeNothing> when `use_default_implementation_for_nulls` is true.
@ -371,6 +374,7 @@ protected:
/// If it isn't, will convert all ColumnLowCardinality arguments to full columns.
virtual bool can_be_executed_on_low_cardinality_dictionary() const { return true; }
/// return a real function object to execute. called in build(...).
virtual FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
const DataTypePtr& return_type) const = 0;
@ -449,7 +453,7 @@ protected:
}
};
/// Wrappers over IFunction.
/// Wrappers over IFunction. If we (default)use DefaultFunction as wrapper, all function execution will go through this.
class DefaultExecutable final : public PreparedFunctionImpl {
public:
@ -485,6 +489,10 @@ private:
std::shared_ptr<IFunction> function;
};
/*
* when we register a function which didn't specify its base(i.e. inherited from IFunction), actually we use this as a wrapper.
* it saves real implementation as `function`.
*/
class DefaultFunction final : public IFunctionBase {
public:
DefaultFunction(std::shared_ptr<IFunction> function_, DataTypes arguments_,
@ -498,6 +506,7 @@ public:
const DataTypes& get_argument_types() const override { return arguments; }
const DataTypePtr& get_return_type() const override { return return_type; }
// return a default wrapper for IFunction.
PreparedFunctionPtr prepare(FunctionContext* context, const Block& /*sample_block*/,
const ColumnNumbers& /*arguments*/,
size_t /*result*/) const override {
@ -599,7 +608,9 @@ protected:
FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
const DataTypePtr& return_type) const override {
DataTypes data_types(arguments.size());
for (size_t i = 0; i < arguments.size(); ++i) data_types[i] = arguments[i].type;
for (size_t i = 0; i < arguments.size(); ++i) {
data_types[i] = arguments[i].type;
}
return std::make_shared<DefaultFunction>(function, data_types, return_type);
}

View File

@ -124,6 +124,10 @@ using FunctionCurrentTime = FunctionCurrentDateOrDateTime<CurrentTimeImpl<Curren
using FunctionUtcTimeStamp = FunctionCurrentDateOrDateTime<UtcTimestampImpl>;
using FunctionTimeToSec = FunctionCurrentDateOrDateTime<TimeToSecImpl>;
/// @TEMPORARY: for be_exec_version=2
using FunctionToWeekTwoArgsOld =
FunctionDateOrDateTimeComputation<ToWeekTwoArgsImplOld<DataTypeDateTime>>;
void register_function_date_time_computation(SimpleFunctionFactory& factory) {
factory.register_function<FunctionAddSeconds>();
factory.register_function<FunctionAddMinutes>();
@ -178,6 +182,8 @@ void register_function_date_time_computation(SimpleFunctionFactory& factory) {
factory.register_alias("days_add", "date_add");
factory.register_alias("days_add", "adddate");
factory.register_alias("months_add", "add_months");
/// @TEMPORARY: for be_exec_version=2
factory.register_alternative_function<FunctionToWeekTwoArgsOld>();
}
} // namespace doris::vectorized

View File

@ -270,7 +270,7 @@ TIME_DIFF_FUNCTION_IMPL(HoursDiffImpl, hours_diff, HOUR);
TIME_DIFF_FUNCTION_IMPL(MintueSDiffImpl, minutes_diff, MINUTE);
TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND);
#define TIME_FUNCTION_TWO_ARGS_IMPL(CLASS, NAME, FUNCTION) \
#define TIME_FUNCTION_TWO_ARGS_IMPL(CLASS, NAME, FUNCTION, RETURN_TYPE) \
template <typename DateType> \
struct CLASS { \
using ArgType = std::conditional_t< \
@ -280,7 +280,7 @@ TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND);
std::is_same_v<DateType, DataTypeDateV2>, DateV2Value<DateV2ValueType>, \
std::conditional_t<std::is_same_v<DateType, DataTypeDateTimeV2>, \
DateV2Value<DateTimeV2ValueType>, VecDateTimeValue>>; \
using ReturnType = DataTypeInt32; \
using ReturnType = RETURN_TYPE; \
static constexpr auto name = #NAME; \
static constexpr auto is_nullable = false; \
static inline ReturnType::FieldType execute(const ArgType& t0, const Int32 mode, \
@ -294,8 +294,11 @@ TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND);
} \
}
TIME_FUNCTION_TWO_ARGS_IMPL(ToYearWeekTwoArgsImpl, yearweek, year_week(mysql_week_mode(mode)));
TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImpl, week, week(mysql_week_mode(mode)));
TIME_FUNCTION_TWO_ARGS_IMPL(ToYearWeekTwoArgsImpl, yearweek, year_week(mysql_week_mode(mode)),
DataTypeInt32);
TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImpl, week, week(mysql_week_mode(mode)), DataTypeInt8);
/// @TEMPORARY: for be_exec_version=2
TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImplOld, week, week(mysql_week_mode(mode)), DataTypeInt32);
template <typename FromType1, typename FromType2, typename ToType, typename Transform>
struct DateTimeOp {

View File

@ -106,6 +106,10 @@ using FunctionDatetimeV2ToYearWeekTwoArgs =
using FunctionDatetimeV2ToWeekTwoArgs =
FunctionDateOrDateTimeComputation<ToWeekTwoArgsImpl<DataTypeDateTimeV2>>;
/// @TEMPORARY: for be_exec_version=2
using FunctionDatetimeV2ToWeekTwoArgsOld =
FunctionDateOrDateTimeComputation<ToWeekTwoArgsImplOld<DataTypeDateTimeV2>>;
void register_function_date_time_computation_v2(SimpleFunctionFactory& factory) {
factory.register_function<FunctionAddSecondsV2>();
factory.register_function<FunctionAddMinutesV2>();
@ -168,6 +172,9 @@ void register_function_date_time_computation_v2(SimpleFunctionFactory& factory)
factory.register_function<FunctionToWeekTwoArgsV2>();
factory.register_function<FunctionDatetimeV2ToYearWeekTwoArgs>();
factory.register_function<FunctionDatetimeV2ToWeekTwoArgs>();
/// @TEMPORARY: for be_exec_version=2
factory.register_alternative_function<FunctionDatetimeV2ToWeekTwoArgsOld>();
}
} // namespace doris::vectorized

View File

@ -41,7 +41,9 @@ public:
bool is_variadic() const override { return true; }
size_t get_number_of_arguments() const override { return 0; }
DataTypes get_variadic_argument_types_impl() const override {
if constexpr (has_variadic_argument) return Transform::get_variadic_argument_types();
if constexpr (has_variadic_argument) {
return Transform::get_variadic_argument_types();
}
return {};
}

View File

@ -23,6 +23,8 @@
#include <mutex>
#include <string>
#include "agent/be_exec_version_manager.h"
#include "udf/udf.h"
#include "vec/exprs/table_function/table_function.h"
#include "vec/functions/function.h"
@ -99,6 +101,8 @@ class SimpleFunctionFactory {
using Creator = std::function<FunctionBuilderPtr()>;
using FunctionCreators = phmap::flat_hash_map<std::string, Creator>;
using FunctionIsVariadic = phmap::flat_hash_set<std::string>;
/// @TEMPORARY: for be_exec_version=2
constexpr static int DATETIME_FUNCTION_NEW = 2;
public:
void register_function(const std::string& name, const Creator& ptr) {
@ -135,14 +139,25 @@ public:
function_alias[alias] = name;
}
/// @TEMPORARY: for be_exec_version=2
template <class Function>
void register_alternative_function() {
static std::string suffix {"_old_for_version_before_2_0"};
function_to_replace[Function::name] = Function::name + suffix;
register_function(Function::name + suffix, &createDefaultFunction<Function>);
}
FunctionBasePtr get_function(const std::string& name, const ColumnsWithTypeAndName& arguments,
const DataTypePtr& return_type) {
const DataTypePtr& return_type,
int be_version = BeExecVersionManager::get_newest_version()) {
std::string key_str = name;
if (function_alias.count(name)) {
key_str = function_alias[name];
}
temporary_function_update(be_version, key_str);
// if function is variadic, added types_str as key
if (function_variadic_set.count(key_str)) {
for (auto& arg : arguments) {
@ -155,24 +170,35 @@ public:
}
auto iter = function_creators.find(key_str);
if (iter != function_creators.end()) {
return iter->second()->build(arguments, return_type);
if (iter == function_creators.end()) {
LOG(WARNING) << fmt::format("Function signature {} is not found", key_str);
return nullptr;
}
LOG(WARNING) << fmt::format("Function signature {} is not found", key_str);
return nullptr;
return iter->second()->build(arguments, return_type);
}
private:
FunctionCreators function_creators;
FunctionIsVariadic function_variadic_set;
std::unordered_map<std::string, std::string> function_alias;
/// @TEMPORARY: for be_exec_version=2. replace function to old version.
std::unordered_map<std::string, std::string> function_to_replace;
template <typename Function>
static FunctionBuilderPtr createDefaultFunction() {
return std::make_shared<DefaultFunctionBuilder>(Function::create());
}
/// @TEMPORARY: for be_exec_version=2
void temporary_function_update(int fe_version_now, std::string& name) {
// replace if fe is old version.
if (fe_version_now < DATETIME_FUNCTION_NEW &&
function_to_replace.find(name) != function_to_replace.end()) {
name = function_to_replace[name];
}
}
public:
static SimpleFunctionFactory& instance() {
static std::once_flag oc;

View File

@ -22,34 +22,62 @@
namespace doris::vectorized {
using FunctionWeekOfYear = FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<Int64>>;
using FunctionWeekOfYear = FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekOfYearImpl<Int64>>;
using FunctionWeekOfYearV2 =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<UInt32>>;
using FunctionDayOfYear = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<Int64>>;
using FunctionDayOfYearV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<UInt32>>;
using FunctionDayOfWeek = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<Int64>>;
using FunctionDayOfWeekV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<UInt32>>;
using FunctionDayOfMonth = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<Int64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekOfYearImpl<UInt32>>;
using FunctionDayOfYear = FunctionDateOrDateTimeToSomething<DataTypeInt16, DayOfYearImpl<Int64>>;
using FunctionDayOfYearV2 = FunctionDateOrDateTimeToSomething<DataTypeInt16, DayOfYearImpl<UInt32>>;
using FunctionDayOfWeek = FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfWeekImpl<Int64>>;
using FunctionDayOfWeekV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfWeekImpl<UInt32>>;
using FunctionDayOfMonth = FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfMonthImpl<Int64>>;
using FunctionDayOfMonthV2 =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<UInt32>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfMonthImpl<UInt32>>;
using FunctionYearWeek =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearWeekOneArgImpl<Int64>>;
using FunctionYearWeekV2 =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearWeekOneArgImpl<UInt32>>;
using FunctionWeekDay = FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekDayImpl<Int64>>;
using FunctionWeekDayV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekDayImpl<UInt32>>;
using FunctionWeekDay = FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekDayImpl<Int64>>;
using FunctionWeekDayV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekDayImpl<UInt32>>;
using FunctionDateTimeV2WeekOfYear =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekOfYearImpl<UInt64>>;
using FunctionDateTimeV2DayOfYear =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt16, DayOfYearImpl<UInt64>>;
using FunctionDateTimeV2DayOfWeek =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfWeekImpl<UInt64>>;
using FunctionDateTimeV2DayOfMonth =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, DayOfMonthImpl<UInt64>>;
using FunctionDateTimeV2YearWeek =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearWeekOneArgImpl<UInt64>>;
using FunctionDateTimeV2WeekDay =
FunctionDateOrDateTimeToSomething<DataTypeInt8, WeekDayImpl<UInt64>>;
/// @TEMPORARY: for be_exec_version=2
using FunctionWeekOfYearOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<Int64>>;
using FunctionWeekOfYearV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<UInt32>>;
using FunctionDayOfYearOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<Int64>>;
using FunctionDayOfYearV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<UInt32>>;
using FunctionDayOfWeekOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<Int64>>;
using FunctionDayOfWeekV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<UInt32>>;
using FunctionDayOfMonthOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<Int64>>;
using FunctionDayOfMonthV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<UInt32>>;
using FunctionWeekDayOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekDayImpl<Int64>>;
using FunctionWeekDayV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekDayImpl<UInt32>>;
using FunctionDateTimeV2WeekOfYearOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekOfYearImpl<UInt64>>;
using FunctionDateTimeV2DayOfYearOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfYearImpl<UInt64>>;
using FunctionDateTimeV2DayOfWeekOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfWeekImpl<UInt64>>;
using FunctionDateTimeV2DayOfMonthOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, DayOfMonthImpl<UInt64>>;
using FunctionDateTimeV2WeekDayOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, WeekDayImpl<UInt64>>;
void register_function_time_of_function(SimpleFunctionFactory& factory) {
@ -71,5 +99,22 @@ void register_function_time_of_function(SimpleFunctionFactory& factory) {
factory.register_function<FunctionDateTimeV2DayOfMonth>();
factory.register_function<FunctionDateTimeV2YearWeek>();
factory.register_function<FunctionDateTimeV2WeekDay>();
/// @TEMPORARY: for be_exec_version=2
factory.register_alternative_function<FunctionWeekOfYearOld>();
factory.register_alternative_function<FunctionWeekOfYearV2Old>();
factory.register_alternative_function<FunctionDateTimeV2WeekOfYearOld>();
factory.register_alternative_function<FunctionDayOfYearOld>();
factory.register_alternative_function<FunctionDayOfYearV2Old>();
factory.register_alternative_function<FunctionDateTimeV2DayOfYearOld>();
factory.register_alternative_function<FunctionDayOfWeekOld>();
factory.register_alternative_function<FunctionDayOfWeekV2Old>();
factory.register_alternative_function<FunctionDateTimeV2DayOfWeekOld>();
factory.register_alternative_function<FunctionDayOfMonthOld>();
factory.register_alternative_function<FunctionDayOfMonthV2Old>();
factory.register_alternative_function<FunctionDateTimeV2DayOfMonthOld>();
factory.register_alternative_function<FunctionWeekDayOld>();
factory.register_alternative_function<FunctionWeekDayV2Old>();
factory.register_alternative_function<FunctionDateTimeV2WeekDayOld>();
}
} // namespace doris::vectorized

View File

@ -23,22 +23,22 @@
namespace doris::vectorized {
using FunctionYear = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<Int64>>;
using FunctionYearV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<UInt32>>;
using FunctionQuarter = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<Int64>>;
using FunctionQuarterV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<UInt32>>;
using FunctionMonth = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<Int64>>;
using FunctionMonthV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<UInt32>>;
using FunctionDay = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<Int64>>;
using FunctionDayV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<UInt32>>;
using FunctionWeek = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<Int64>>;
using FunctionWeekV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<UInt32>>;
using FunctionHour = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<Int64>>;
using FunctionHourV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<UInt32>>;
using FunctionMinute = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<Int64>>;
using FunctionMinuteV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<UInt32>>;
using FunctionSecond = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<Int64>>;
using FunctionSecondV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<UInt32>>;
using FunctionYear = FunctionDateOrDateTimeToSomething<DataTypeInt16, ToYearImpl<Int64>>;
using FunctionYearV2 = FunctionDateOrDateTimeToSomething<DataTypeInt16, ToYearImpl<UInt32>>;
using FunctionQuarter = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToQuarterImpl<Int64>>;
using FunctionQuarterV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToQuarterImpl<UInt32>>;
using FunctionMonth = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMonthImpl<Int64>>;
using FunctionMonthV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMonthImpl<UInt32>>;
using FunctionDay = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToDayImpl<Int64>>;
using FunctionDayV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToDayImpl<UInt32>>;
using FunctionWeek = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToWeekOneArgImpl<Int64>>;
using FunctionWeekV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToWeekOneArgImpl<UInt32>>;
using FunctionHour = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToHourImpl<Int64>>;
using FunctionHourV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToHourImpl<UInt32>>;
using FunctionMinute = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMinuteImpl<Int64>>;
using FunctionMinuteV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMinuteImpl<UInt32>>;
using FunctionSecond = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToSecondImpl<Int64>>;
using FunctionSecondV2 = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToSecondImpl<UInt32>>;
using FunctionToDays = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDaysImpl<Int64>>;
using FunctionToDaysV2 = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDaysImpl<UInt32>>;
using FunctionToDate = FunctionDateOrDateTimeToSomething<DataTypeDateTime, ToDateImpl<Int64>>;
@ -46,19 +46,19 @@ using FunctionToDateV2 = FunctionDateOrDateTimeToSomething<DataTypeDateV2, ToDat
using FunctionDate = FunctionDateOrDateTimeToSomething<DataTypeDateTime, DateImpl<Int64>>;
using FunctionDateV2 = FunctionDateOrDateTimeToSomething<DataTypeDateV2, DateImpl<UInt32>>;
using FunctionDateTimeV2Year = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<UInt64>>;
using FunctionDateTimeV2Year = FunctionDateOrDateTimeToSomething<DataTypeInt16, ToYearImpl<UInt64>>;
using FunctionDateTimeV2Quarter =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, ToQuarterImpl<UInt64>>;
using FunctionDateTimeV2Month =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<UInt64>>;
using FunctionDateTimeV2Day = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMonthImpl<UInt64>>;
using FunctionDateTimeV2Day = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToDayImpl<UInt64>>;
using FunctionDateTimeV2Week =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<UInt64>>;
using FunctionDateTimeV2Hour = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, ToWeekOneArgImpl<UInt64>>;
using FunctionDateTimeV2Hour = FunctionDateOrDateTimeToSomething<DataTypeInt8, ToHourImpl<UInt64>>;
using FunctionDateTimeV2Minute =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, ToMinuteImpl<UInt64>>;
using FunctionDateTimeV2Second =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<UInt64>>;
FunctionDateOrDateTimeToSomething<DataTypeInt8, ToSecondImpl<UInt64>>;
using FunctionDateTimeV2ToDays =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDaysImpl<UInt64>>;
using FunctionDateTimeV2ToDate =
@ -69,6 +69,42 @@ using FunctionTimeStamp = FunctionDateOrDateTimeToSomething<DataTypeDateTime, Ti
using FunctionTimeStampV2 =
FunctionDateOrDateTimeToSomething<DataTypeDateTimeV2, TimeStampImpl<UInt64>>;
/// @TEMPORARY: for be_exec_version=2
using FunctionYearOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<Int64>>;
using FunctionYearV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<UInt32>>;
using FunctionQuarterOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<Int64>>;
using FunctionQuarterV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<UInt32>>;
using FunctionMonthOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<Int64>>;
using FunctionMonthV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<UInt32>>;
using FunctionWeekOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<Int64>>;
using FunctionWeekV2Old =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<UInt32>>;
using FunctionDayOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<Int64>>;
using FunctionDayV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<UInt32>>;
using FunctionHourOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<Int64>>;
using FunctionHourV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<UInt32>>;
using FunctionMinuteOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<Int64>>;
using FunctionMinuteV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<UInt32>>;
using FunctionSecondOld = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<Int64>>;
using FunctionSecondV2Old = FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<UInt32>>;
using FunctionDateTimeV2YearOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToYearImpl<UInt64>>;
using FunctionDateTimeV2QuarterOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToQuarterImpl<UInt64>>;
using FunctionDateTimeV2MonthOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMonthImpl<UInt64>>;
using FunctionDateTimeV2WeekOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToWeekOneArgImpl<UInt64>>;
using FunctionDateTimeV2DayOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToDayImpl<UInt64>>;
using FunctionDateTimeV2HourOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToHourImpl<UInt64>>;
using FunctionDateTimeV2MinuteOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToMinuteImpl<UInt64>>;
using FunctionDateTimeV2SecondOld =
FunctionDateOrDateTimeToSomething<DataTypeInt32, ToSecondImpl<UInt64>>;
void register_function_to_time_function(SimpleFunctionFactory& factory) {
factory.register_function<FunctionSecond>();
factory.register_function<FunctionMinute>();
@ -107,6 +143,32 @@ void register_function_to_time_function(SimpleFunctionFactory& factory) {
factory.register_function<FunctionDateTimeV2Date>();
factory.register_alias("date", "datev2");
factory.register_alias("to_date", "to_datev2");
/// @TEMPORARY: for be_exec_version=2
factory.register_alternative_function<FunctionYearOld>();
factory.register_alternative_function<FunctionQuarterOld>();
factory.register_alternative_function<FunctionMonthOld>();
factory.register_alternative_function<FunctionDayOld>();
factory.register_alternative_function<FunctionWeekOld>();
factory.register_alternative_function<FunctionHourOld>();
factory.register_alternative_function<FunctionMinuteOld>();
factory.register_alternative_function<FunctionSecondOld>();
factory.register_alternative_function<FunctionYearV2Old>();
factory.register_alternative_function<FunctionQuarterV2Old>();
factory.register_alternative_function<FunctionMonthV2Old>();
factory.register_alternative_function<FunctionWeekV2Old>();
factory.register_alternative_function<FunctionDayV2Old>();
factory.register_alternative_function<FunctionHourV2Old>();
factory.register_alternative_function<FunctionMinuteV2Old>();
factory.register_alternative_function<FunctionSecondV2Old>();
factory.register_alternative_function<FunctionDateTimeV2YearOld>();
factory.register_alternative_function<FunctionDateTimeV2QuarterOld>();
factory.register_alternative_function<FunctionDateTimeV2MonthOld>();
factory.register_alternative_function<FunctionDateTimeV2WeekOld>();
factory.register_alternative_function<FunctionDateTimeV2DayOld>();
factory.register_alternative_function<FunctionDateTimeV2HourOld>();
factory.register_alternative_function<FunctionDateTimeV2MinuteOld>();
factory.register_alternative_function<FunctionDateTimeV2SecondOld>();
}
} // namespace doris::vectorized

View File

@ -32,11 +32,11 @@ TEST(VTimestampFunctionsTest, day_of_week_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, 7},
DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, int8_t {7}},
{{std::string("2020-00-01 00:00:00")}, Null()},
{{std::string("2020-01-00 00:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, day_of_month_test) {
@ -45,10 +45,10 @@ TEST(VTimestampFunctionsTest, day_of_month_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()},
{{std::string("2020-01-01 00:00:00")}, 1},
{{std::string("2020-02-29 00:00:00")}, 29}};
{{std::string("2020-01-01 00:00:00")}, int8_t {1}},
{{std::string("2020-02-29 00:00:00")}, int8_t {29}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, day_of_year_test) {
@ -58,9 +58,9 @@ TEST(VTimestampFunctionsTest, day_of_year_test) {
DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()},
{{std::string("2020-01-00 00:00:00")}, Null()},
{{std::string("2020-02-29 00:00:00")}, 60}};
{{std::string("2020-02-29 00:00:00")}, int16_t {60}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, week_of_year_test) {
@ -70,9 +70,9 @@ TEST(VTimestampFunctionsTest, week_of_year_test) {
DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()},
{{std::string("2020-01-00 00:00:00")}, Null()},
{{std::string("2020-02-29 00:00:00")}, 9}};
{{std::string("2020-02-29 00:00:00")}, int8_t {9}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, year_test) {
@ -80,11 +80,11 @@ TEST(VTimestampFunctionsTest, year_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 2021},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int16_t {2021}},
{{std::string("2021-01-00 00:00:00")}, Null()},
{{std::string("2025-05-01 00:00:00")}, 2025}};
{{std::string("2025-05-01 00:00:00")}, int16_t {2025}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, quarter_test) {
@ -92,12 +92,12 @@ TEST(VTimestampFunctionsTest, quarter_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-10-23 00:00:00")}, 4}};
{{std::string("2025-10-23 00:00:00")}, int8_t {4}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, month_test) {
@ -105,12 +105,12 @@ TEST(VTimestampFunctionsTest, month_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-05-23 00:00:00")}, 5}};
{{std::string("2025-05-23 00:00:00")}, int8_t {5}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, day_test) {
@ -118,12 +118,12 @@ TEST(VTimestampFunctionsTest, day_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-05-23 00:00:00")}, 23}};
{{std::string("2025-05-23 00:00:00")}, int8_t {23}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, hour_test) {
@ -131,12 +131,12 @@ TEST(VTimestampFunctionsTest, hour_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 23:59:59")}, 23},
{{std::string("2021-01-13 16:56:00")}, 16},
DataSet data_set = {{{std::string("2021-01-01 23:59:59")}, int8_t {23}},
{{std::string("2021-01-13 16:56:00")}, int8_t {16}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 24:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, minute_test) {
@ -144,12 +144,12 @@ TEST(VTimestampFunctionsTest, minute_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 23:59:50")}, 59},
{{std::string("2021-01-13 16:20:00")}, 20},
DataSet data_set = {{{std::string("2021-01-01 23:59:50")}, int8_t {59}},
{{std::string("2021-01-13 16:20:00")}, int8_t {20}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 24:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, second_test) {
@ -157,12 +157,12 @@ TEST(VTimestampFunctionsTest, second_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2021-01-01 23:50:59")}, 59},
{{std::string("2021-01-13 16:20:00")}, 0},
DataSet data_set = {{{std::string("2021-01-01 23:50:59")}, int8_t {59}},
{{std::string("2021-01-13 16:20:00")}, int8_t {0}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 24:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, from_unix_test) {
@ -478,18 +478,18 @@ TEST(VTimestampFunctionsTest, week_test) {
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("1989-03-21 06:00:00")}, 12},
DataSet data_set = {{{std::string("1989-03-21 06:00:00")}, int8_t {12}},
{{std::string("")}, Null()},
{{std::string("9999-12-12 00:00:00")}, 50}};
{{std::string("9999-12-12 00:00:00")}, int8_t {50}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
InputTypeSet new_input_types = {TypeIndex::Date};
DataSet new_data_set = {{{std::string("1989-03-21")}, 12},
DataSet new_data_set = {{{std::string("1989-03-21")}, int8_t {12}},
{{std::string("")}, Null()},
{{std::string("9999-12-12")}, 50}};
{{std::string("9999-12-12")}, int8_t {50}}};
check_function<DataTypeInt32, true>(func_name, new_input_types, new_data_set);
check_function<DataTypeInt8, true>(func_name, new_input_types, new_data_set);
}
TEST(VTimestampFunctionsTest, yearweek_test) {
@ -548,21 +548,21 @@ TEST(VTimestampFunctionsTest, weekday_test) {
{
InputTypeSet input_types = {TypeIndex::DateTime};
DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, 5},
{{std::string("2019-06-25")}, 1},
DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, int8_t {5}},
{{std::string("2019-06-25")}, int8_t {1}},
{{std::string("2020-00-01 00:00:00")}, Null()},
{{std::string("2020-01-00 00:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
InputTypeSet input_types = {TypeIndex::Date};
DataSet data_set = {{{std::string("2001-02-03")}, 5},
{{std::string("2019-06-25")}, 1},
DataSet data_set = {{{std::string("2001-02-03")}, int8_t {5}},
{{std::string("2019-06-25")}, int8_t {1}},
{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
TEST(VTimestampFunctionsTest, day_of_week_v2_test) {
@ -571,26 +571,26 @@ TEST(VTimestampFunctionsTest, day_of_week_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2001-02-03")}, 7},
DataSet data_set = {{{std::string("2001-02-03")}, int8_t {7}},
{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2001-02-03 01:00:00")}, 7},
{{std::string("2001-02-03 01:00:00.213")}, 7},
{{std::string("2001-02-03 01:00:00.123213")}, 7},
{{std::string("2001-02-03 01:00:00.123123213")}, 7},
DataSet data_set = {{{std::string("2001-02-03 01:00:00")}, int8_t {7}},
{{std::string("2001-02-03 01:00:00.213")}, int8_t {7}},
{{std::string("2001-02-03 01:00:00.123213")}, int8_t {7}},
{{std::string("2001-02-03 01:00:00.123123213")}, int8_t {7}},
{{std::string("2001-02-03 25:00:00.123123213")}, Null()},
{{std::string("2001-02-03 01:61:00.123123213")}, Null()},
{{std::string("2001-02-03 01:00:61.123123213")}, Null()},
{{std::string("2020-00-01 01:00:00")}, Null()},
{{std::string("2020-01-00 01:00:00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -601,19 +601,19 @@ TEST(VTimestampFunctionsTest, day_of_month_v2_test) {
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-01")}, 1},
{{std::string("2020-02-29")}, 29}};
{{std::string("2020-01-01")}, int8_t {1}},
{{std::string("2020-02-29")}, int8_t {29}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()},
{{std::string("2020-01-01 01:00:00")}, 1},
{{std::string("2020-02-29 01:00:00.123123")}, 29}};
{{std::string("2020-01-01 01:00:00")}, int8_t {1}},
{{std::string("2020-02-29 01:00:00.123123")}, int8_t {29}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -625,18 +625,18 @@ TEST(VTimestampFunctionsTest, day_of_year_v2_test) {
DataSet data_set = {{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-00")}, Null()},
{{std::string("2020-02-29")}, 60}};
{{std::string("2020-02-29")}, int16_t {60}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()},
{{std::string("2020-01-00 01:00:00")}, Null()},
{{std::string("2020-02-29 01:00:00.1232")}, 60}};
{{std::string("2020-02-29 01:00:00.1232")}, int16_t {60}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
}
@ -648,19 +648,19 @@ TEST(VTimestampFunctionsTest, week_of_year_v2_test) {
DataSet data_set = {{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-00")}, Null()},
{{std::string("2020-02-29")}, 9}};
{{std::string("2020-02-29")}, int8_t {9}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()},
{{std::string("2020-01-00 01:00:00")}, Null()},
{{std::string("2020-02-29 01:00:00")}, 9},
{{std::string("2020-02-29 01:00:00.12312")}, 9}};
{{std::string("2020-02-29 01:00:00")}, int8_t {9}},
{{std::string("2020-02-29 01:00:00.12312")}, int8_t {9}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -670,20 +670,20 @@ TEST(VTimestampFunctionsTest, year_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 2021},
DataSet data_set = {{{std::string("2021-01-01")}, int16_t {2021}},
{{std::string("2021-01-00")}, Null()},
{{std::string("2025-05-01")}, 2025}};
{{std::string("2025-05-01")}, int16_t {2025}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 01:00:00")}, 2021},
DataSet data_set = {{{std::string("2021-01-01 01:00:00")}, int16_t {2021}},
{{std::string("2021-01-00 01:00:00")}, Null()},
{{std::string("2025-05-01 01:00:00.123")}, 2025}};
{{std::string("2025-05-01 01:00:00.123")}, int16_t {2025}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt16, true>(func_name, input_types, data_set);
}
}
@ -693,22 +693,22 @@ TEST(VTimestampFunctionsTest, quarter_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 1},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32")}, Null()},
{{std::string("2025-10-23")}, 4}};
{{std::string("2025-10-23")}, int8_t {4}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-10-23 00:00:00")}, 4}};
{{std::string("2025-10-23 00:00:00")}, int8_t {4}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -718,22 +718,22 @@ TEST(VTimestampFunctionsTest, month_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 1},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32")}, Null()},
{{std::string("2025-05-23")}, 5}};
{{std::string("2025-05-23")}, int8_t {5}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-05-23 00:00:00")}, 5}};
{{std::string("2025-05-23 00:00:00")}, int8_t {5}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -743,22 +743,22 @@ TEST(VTimestampFunctionsTest, day_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 1},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32")}, Null()},
{{std::string("2025-05-23")}, 23}};
{{std::string("2025-05-23")}, int8_t {23}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2021-01-32 00:00:00")}, Null()},
{{std::string("2025-05-23 00:00:00")}, 23}};
{{std::string("2025-05-23 00:00:00")}, int8_t {23}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -768,21 +768,21 @@ TEST(VTimestampFunctionsTest, hour_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 0},
{{std::string("2021-01-13")}, 0},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}},
{{std::string("2021-01-13")}, int8_t {0}},
{{std::string("")}, Null()},
{{std::string("2025-05-23")}, 0}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
{{std::string("2025-05-23")}, int8_t {0}}};
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, 0},
{{std::string("2021-01-13 01:00:00.123")}, 1},
DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, int8_t {0}},
{{std::string("2021-01-13 01:00:00.123")}, int8_t {1}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 23:00:00.123")}, 23},
{{std::string("2025-05-23 23:00:00.123")}, int8_t {23}},
{{std::string("2025-05-23 25:00:00.123")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -792,23 +792,23 @@ TEST(VTimestampFunctionsTest, minute_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 0},
{{std::string("2021-01-13")}, 0},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}},
{{std::string("2021-01-13")}, int8_t {0}},
{{std::string("")}, Null()},
{{std::string("2025-05-23")}, 0}};
{{std::string("2025-05-23")}, int8_t {0}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, 0},
{{std::string("2021-01-13 00:11:00.123")}, 11},
DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, int8_t {0}},
{{std::string("2021-01-13 00:11:00.123")}, int8_t {11}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 00:22:22.123")}, 22},
{{std::string("2025-05-23 00:22:22.123")}, int8_t {22}},
{{std::string("2025-05-23 00:60:22.123")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -818,23 +818,23 @@ TEST(VTimestampFunctionsTest, second_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2021-01-01")}, 0},
{{std::string("2021-01-13")}, 0},
DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}},
{{std::string("2021-01-13")}, int8_t {0}},
{{std::string("")}, Null()},
{{std::string("2025-05-23")}, 0}};
{{std::string("2025-05-23")}, int8_t {0}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2021-01-01 00:00:01.123")}, 1},
{{std::string("2021-01-13 00:00:02.123")}, 2},
DataSet data_set = {{{std::string("2021-01-01 00:00:01.123")}, int8_t {1}},
{{std::string("2021-01-13 00:00:02.123")}, int8_t {2}},
{{std::string("")}, Null()},
{{std::string("2025-05-23 00:00:63.123")}, Null()},
{{std::string("2025-05-23 00:00:00.123")}, 0}};
{{std::string("2025-05-23 00:00:00.123")}, int8_t {0}}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}
@ -1295,19 +1295,19 @@ TEST(VTimestampFunctionsTest, week_v2_test) {
{
InputTypeSet new_input_types = {TypeIndex::DateV2};
DataSet new_data_set = {{{std::string("1989-03-21")}, 12},
DataSet new_data_set = {{{std::string("1989-03-21")}, int8_t {12}},
{{std::string("")}, Null()},
{{std::string("9999-12-12")}, 50}};
{{std::string("9999-12-12")}, int8_t {50}}};
check_function<DataTypeInt32, true>(func_name, new_input_types, new_data_set);
check_function<DataTypeInt8, true>(func_name, new_input_types, new_data_set);
}
{
InputTypeSet new_input_types = {TypeIndex::DateTimeV2};
DataSet new_data_set = {{{std::string("1989-03-21 00:00:11.123")}, 12},
DataSet new_data_set = {{{std::string("1989-03-21 00:00:11.123")}, int8_t {12}},
{{std::string("")}, Null()},
{{std::string("9999-12-12 00:00:11.123")}, 50}};
{{std::string("9999-12-12 00:00:11.123")}, int8_t {50}}};
check_function<DataTypeInt32, true>(func_name, new_input_types, new_data_set);
check_function<DataTypeInt8, true>(func_name, new_input_types, new_data_set);
}
}
@ -1367,22 +1367,22 @@ TEST(VTimestampFunctionsTest, weekday_v2_test) {
{
InputTypeSet input_types = {TypeIndex::DateV2};
DataSet data_set = {{{std::string("2001-02-03")}, 5},
{{std::string("2019-06-25")}, 1},
DataSet data_set = {{{std::string("2001-02-03")}, int8_t {5}},
{{std::string("2019-06-25")}, int8_t {1}},
{{std::string("2020-00-01")}, Null()},
{{std::string("2020-01-00")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
{
InputTypeSet input_types = {TypeIndex::DateTimeV2};
DataSet data_set = {{{std::string("2001-02-03 00:00:11.123")}, 5},
{{std::string("2019-06-25 00:00:11.123")}, 1},
DataSet data_set = {{{std::string("2001-02-03 00:00:11.123")}, int8_t {5}},
{{std::string("2019-06-25 00:00:11.123")}, int8_t {1}},
{{std::string("2020-00-01 00:00:11.123")}, Null()},
{{std::string("2020-01-00 00:00:11.123")}, Null()}};
check_function<DataTypeInt32, true>(func_name, input_types, data_set);
check_function<DataTypeInt8, true>(func_name, input_types, data_set);
}
}

View File

@ -1807,7 +1807,7 @@ public class Config extends ConfigBase {
* Max data version of backends serialize block.
*/
@ConfField(mutable = false)
public static int max_be_exec_version = 1;
public static int max_be_exec_version = 2;
/**
* Min data version of backends serialize block.

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class DayOfMonth extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class DayOfWeek extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.SmallIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class DayOfYear extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Hour extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Minute extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Month extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Quarter extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Second extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,6 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -39,12 +40,12 @@ public class Week extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.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.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class WeekOfYear extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.TinyIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Weekday extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE)
);
/**

View File

@ -26,7 +26,7 @@ import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.SmallIntType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -40,9 +40,9 @@ public class Year extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
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.SYSTEM_DEFAULT)
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateV2Type.INSTANCE),
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeType.INSTANCE),
FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**

View File

@ -77,7 +77,7 @@ public class FEFunctions {
return new IntLiteral(datediff, Type.INT);
}
@FEFunction(name = "dayofweek", argTypes = {"DATETIME"}, returnType = "INT")
@FEFunction(name = "dayofweek", argTypes = {"DATETIME"}, returnType = "TINYINT")
public static IntLiteral dayOfWeek(LiteralExpr date) throws AnalysisException {
// use zellar algorithm.
long year = ((DateLiteral) date).getYear();
@ -197,17 +197,17 @@ public class FEFunctions {
return secondsAdd(date, new IntLiteral(-(int) second.getLongValue()));
}
@FEFunction(name = "year", argTypes = { "DATETIME" }, returnType = "INT")
@FEFunction(name = "year", argTypes = { "DATETIME" }, returnType = "SMALLINT")
public static IntLiteral year(LiteralExpr arg) throws AnalysisException {
return new IntLiteral(((DateLiteral) arg).getYear(), Type.INT);
}
@FEFunction(name = "month", argTypes = { "DATETIME" }, returnType = "INT")
@FEFunction(name = "month", argTypes = { "DATETIME" }, returnType = "TINYINT")
public static IntLiteral month(LiteralExpr arg) throws AnalysisException {
return new IntLiteral(((DateLiteral) arg).getMonth(), Type.INT);
}
@FEFunction(name = "day", argTypes = { "DATETIME" }, returnType = "INT")
@FEFunction(name = "day", argTypes = { "DATETIME" }, returnType = "TINYINT")
public static IntLiteral day(LiteralExpr arg) throws AnalysisException {
return new IntLiteral(((DateLiteral) arg).getDay(), Type.INT);
}
@ -292,7 +292,7 @@ public class FEFunctions {
Type.DATETIME);
}
@FEFunction(name = "hour", argTypes = {"DATETIME"}, returnType = "INT")
@FEFunction(name = "hour", argTypes = {"DATETIME"}, returnType = "TINYINT")
public static IntLiteral hour(LiteralExpr arg) throws AnalysisException {
if (arg instanceof DateLiteral) {
return new IntLiteral(((DateLiteral) arg).getHour());
@ -300,7 +300,7 @@ public class FEFunctions {
return null;
}
@FEFunction(name = "minute", argTypes = {"DATETIME"}, returnType = "INT")
@FEFunction(name = "minute", argTypes = {"DATETIME"}, returnType = "TINYINT")
public static IntLiteral minute(LiteralExpr arg) throws AnalysisException {
if (arg instanceof DateLiteral) {
return new IntLiteral(((DateLiteral) arg).getMinute());
@ -308,7 +308,7 @@ public class FEFunctions {
return null;
}
@FEFunction(name = "second", argTypes = {"DATETIME"}, returnType = "INT")
@FEFunction(name = "second", argTypes = {"DATETIME"}, returnType = "TINYINT")
public static IntLiteral second(LiteralExpr arg) throws AnalysisException {
if (arg instanceof DateLiteral) {
return new IntLiteral(((DateLiteral) arg).getSecond());

View File

@ -22,6 +22,7 @@ import org.apache.doris.analysis.DescriptorTable;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.SlotRef;
import org.apache.doris.catalog.Column;
import org.apache.doris.common.Config;
import org.apache.doris.thrift.TAlterMaterializedViewParam;
import org.apache.doris.thrift.TAlterTabletReqV2;
import org.apache.doris.thrift.TAlterTabletType;
@ -112,6 +113,7 @@ public class AlterReplicaTask extends AgentTask {
public TAlterTabletReqV2 toThrift() {
TAlterTabletReqV2 req = new TAlterTabletReqV2(baseTabletId, signature, baseSchemaHash, newSchemaHash);
req.setAlterVersion(version);
req.setBeExecVersion(Config.be_exec_version);
switch (jobType) {
case ROLLUP:
req.setAlterTabletType(TAlterTabletType.ROLLUP);

View File

@ -835,21 +835,21 @@ visible_functions = [
[['date_trunc'], 'DATETIMEV2', ['DATETIMEV2', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['year'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['month'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['quarter'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['dayofweek'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['weekday'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['day', 'dayofmonth'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['dayofyear'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['weekofyear'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['year'], 'SMALLINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['month'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['quarter'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['dayofweek'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['weekday'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['day', 'dayofmonth'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['dayofyear'], 'SMALLINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['weekofyear'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['yearweek'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['yearweek'], 'INT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'],
[['week'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['week'], 'INT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'],
[['hour'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['minute'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['second'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['week'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['week'], 'TINYINT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'],
[['hour'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['minute'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['second'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'],
[['makedate'], 'DATE', ['INT', 'INT'], 'ALWAYS_NULLABLE'],
[['years_add'], 'DATETIME', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'],
@ -953,37 +953,37 @@ visible_functions = [
[['to_days'], 'INT', ['DATEV2'], ''],
[['time_to_sec'], 'INT', ['TIME'], ''],
[['year'], 'INT', ['DATETIMEV2'], ''],
[['month'], 'INT', ['DATETIMEV2'], ''],
[['quarter'], 'INT', ['DATETIMEV2'], ''],
[['dayofweek'], 'INT', ['DATETIMEV2'], ''],
[['weekday'], 'INT', ['DATETIMEV2'], ''],
[['day', 'dayofmonth'], 'INT', ['DATETIMEV2'], ''],
[['dayofyear'], 'INT', ['DATETIMEV2'], ''],
[['weekofyear'], 'INT', ['DATETIMEV2'], ''],
[['year'], 'SMALLINT', ['DATETIMEV2'], ''],
[['month'], 'TINYINT', ['DATETIMEV2'], ''],
[['quarter'], 'TINYINT', ['DATETIMEV2'], ''],
[['dayofweek'], 'TINYINT', ['DATETIMEV2'], ''],
[['weekday'], 'TINYINT', ['DATETIMEV2'], ''],
[['day', 'dayofmonth'], 'TINYINT', ['DATETIMEV2'], ''],
[['dayofyear'], 'SMALLINT', ['DATETIMEV2'], ''],
[['weekofyear'], 'TINYINT', ['DATETIMEV2'], ''],
[['yearweek'], 'INT', ['DATETIMEV2'], ''],
[['yearweek'], 'INT', ['DATETIMEV2', 'INT'], ''],
[['week'], 'INT', ['DATETIMEV2'], ''],
[['week'], 'INT', ['DATETIMEV2', 'INT'], ''],
[['hour'], 'INT', ['DATETIMEV2'], ''],
[['minute'], 'INT', ['DATETIMEV2'], ''],
[['second'], 'INT', ['DATETIMEV2'], ''],
[['week'], 'TINYINT', ['DATETIMEV2'], ''],
[['week'], 'TINYINT', ['DATETIMEV2', 'INT'], ''],
[['hour'], 'TINYINT', ['DATETIMEV2'], ''],
[['minute'], 'TINYINT', ['DATETIMEV2'], ''],
[['second'], 'TINYINT', ['DATETIMEV2'], ''],
[['year'], 'INT', ['DATEV2'], ''],
[['month'], 'INT', ['DATEV2'], ''],
[['quarter'], 'INT', ['DATEV2'], ''],
[['dayofweek'], 'INT', ['DATEV2'], ''],
[['weekday'], 'INT', ['DATEV2'], ''],
[['day', 'dayofmonth'], 'INT', ['DATEV2'], ''],
[['dayofyear'], 'INT', ['DATEV2'], ''],
[['weekofyear'], 'INT', ['DATEV2'], ''],
[['year'], 'SMALLINT', ['DATEV2'], ''],
[['month'], 'TINYINT', ['DATEV2'], ''],
[['quarter'], 'TINYINT', ['DATEV2'], ''],
[['dayofweek'], 'TINYINT', ['DATEV2'], ''],
[['weekday'], 'TINYINT', ['DATEV2'], ''],
[['day', 'dayofmonth'], 'TINYINT', ['DATEV2'], ''],
[['dayofyear'], 'SMALLINT', ['DATEV2'], ''],
[['weekofyear'], 'TINYINT', ['DATEV2'], ''],
[['yearweek'], 'INT', ['DATEV2'], ''],
[['yearweek'], 'INT', ['DATEV2', 'INT'], ''],
[['week'], 'INT', ['DATEV2'], ''],
[['week'], 'INT', ['DATEV2', 'INT'], ''],
[['hour'], 'INT', ['DATEV2'], ''],
[['minute'], 'INT', ['DATEV2'], ''],
[['second'], 'INT', ['DATEV2'], ''],
[['week'], 'TINYINT', ['DATEV2'], ''],
[['week'], 'TINYINT', ['DATEV2', 'INT'], ''],
[['hour'], 'TINYINT', ['DATEV2'], ''],
[['minute'], 'TINYINT', ['DATEV2'], ''],
[['second'], 'TINYINT', ['DATEV2'], ''],
[['years_add'], 'DATETIMEV2', ['DATETIMEV2', 'INT'], ''],
[['years_sub'], 'DATETIMEV2', ['DATETIMEV2', 'INT'], ''],

View File

@ -166,6 +166,7 @@ struct TAlterTabletReqV2 {
8: optional TAlterTabletType alter_tablet_type = TAlterTabletType.SCHEMA_CHANGE
9: optional Descriptors.TDescriptorTable desc_tbl
10: optional list<Descriptors.TColumn> columns
11: optional i32 be_exec_version = 0
}
struct TAlterInvertedIndexReq {