Skip to content

Commit

Permalink
Fix to_date function short circuit execute
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinyhZou committed Jun 11, 2024
1 parent ec3e92e commit 1f4294e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
5 changes: 1 addition & 4 deletions cpp-ch/local-engine/Functions/FunctionGetDateData.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,14 @@ class FunctionGetDateData : public DB::IFunction
FunctionGetDateData() = default;
~FunctionGetDateData() override = default;

DB::ColumnPtr executeImpl(const DB::ColumnsWithTypeAndName & arguments, const DB::DataTypePtr & result_type, size_t) const override
DB::ColumnPtr executeImpl(const DB::ColumnsWithTypeAndName & arguments, const DB::DataTypePtr &, size_t) const override
{
if (arguments.size() != 1)
throw DB::Exception(DB::ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {}'s arguments number must be 1.", getName());

const DB::ColumnWithTypeAndName arg1 = arguments[0];
const auto * src_col = checkAndGetColumn<DB::ColumnString>(arg1.column.get());
size_t size = src_col->size();

if (!result_type->isNullable())
throw DB::Exception(DB::ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Function {}'s return type must be nullable", getName());

using ColVecTo = ColumnVector<T>;
typename ColVecTo::MutablePtr result_column = ColVecTo::create(size, 0);
Expand Down
3 changes: 0 additions & 3 deletions cpp-ch/local-engine/Functions/SparkFunctionToDateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ class SparkFunctionConvertToDateTime : public IFunction
if (arguments.size() != 1 && arguments.size() != 2)
throw DB::Exception(DB::ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {}'s arguments number must be 1 or 2.", name);

if (!result_type->isNullable())
throw DB::Exception(DB::ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Function {}'s return type must be nullable", name);

if (!isDateTime64(removeNullable(result_type)))
throw DB::Exception(DB::ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Function {}'s return type must be datetime.", name);

Expand Down

0 comments on commit 1f4294e

Please sign in to comment.