#pragma once #include namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; } /// See CustomWeekTransforms.h template class FunctionCustomWeekToSomething : public IFunctionCustomWeek { public: static FunctionPtr create(ContextPtr) { return std::make_shared(); } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { this->checkArguments(arguments, /*is_result_type_date_or_date32*/ false, Transform::value_may_be_string); return std::make_shared(); } DataTypePtr getReturnTypeForDefaultImplementationForDynamic() const override { return std::make_shared(); } ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override { const IDataType * from_type = arguments[0].type.get(); WhichDataType which(from_type); if (which.isDate()) return CustomWeekTransformImpl::execute(arguments, result_type, input_rows_count, Transform{}); if (which.isDate32()) return CustomWeekTransformImpl::execute(arguments, result_type, input_rows_count, Transform{}); if (which.isDateTime()) return CustomWeekTransformImpl::execute(arguments, result_type, input_rows_count, Transform{}); if (which.isDateTime64()) return CustomWeekTransformImpl::execute( arguments, result_type, input_rows_count, TransformDateTime64{assert_cast(from_type)->getScale()}); if (Transform::value_may_be_string && which.isString()) return CustomWeekTransformImpl::execute(arguments, result_type, input_rows_count, Transform{}); throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument of function {}", arguments[0].type->getName(), this->getName()); } }; }