Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ using FunctionLocalTimestamp =
FunctionCurrentDateOrDateTime<CurrentDateTimeImpl<LocalTimestampFunctionName, false>>;

using FunctionNowWithPrecision =
FunctionCurrentDateOrDateTime<CurrentDateTimeImpl<NowFunctionName, true>, false>;
FunctionCurrentDateOrDateTime<CurrentDateTimeImpl<NowFunctionName, true>>;
using FunctionCurrentTimestampWithPrecision =
FunctionCurrentDateOrDateTime<CurrentDateTimeImpl<CurrentTimestampFunctionName, true>>;
using FunctionLocalTimeWithPrecision =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class FunctionDateOrDateTimeComputation : public IFunction {
}
};

template <typename FunctionImpl, bool DefaultNullable = true>
template <typename FunctionImpl>
class FunctionCurrentDateOrDateTime : public IFunction {
public:
static constexpr bool has_variadic_argument =
Expand All @@ -845,8 +845,6 @@ class FunctionCurrentDateOrDateTime : public IFunction {

size_t get_number_of_arguments() const override { return 0; }

bool use_default_implementation_for_nulls() const override { return DefaultNullable; }

DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
return std::make_shared<typename FunctionImpl::ReturnType>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.DateTimeWithPrecision;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic;
Expand All @@ -36,8 +35,7 @@
/**
* ScalarFunction 'now'. This class is generated by GenerateFunction.
*/
public class Now extends DateTimeWithPrecision
implements ExplicitlyCastableSignature, Nondeterministic, AlwaysNotNullable {
public class Now extends DateTimeWithPrecision implements ExplicitlyCastableSignature, Nondeterministic {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeType.INSTANCE).args(),
Expand Down Expand Up @@ -72,6 +70,18 @@ public Now withChildren(List<Expression> children) {
}
}

/**
* Depend on child.
*/
@Override
public boolean nullable() {
if (arity() == 0) {
return false;
}
Preconditions.checkArgument(children.size() == 1);
return child(0).nullable();
}

@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
Expand Down
4 changes: 2 additions & 2 deletions gensrc/script/doris_builtins_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@
[['from_unixtime'], 'VARCHAR', ['INT'], 'ALWAYS_NULLABLE'],
[['from_unixtime'], 'VARCHAR', ['INT', 'VARCHAR'], 'ALWAYS_NULLABLE'],
[['from_unixtime'], 'VARCHAR', ['INT', 'STRING'], 'ALWAYS_NULLABLE'],
[['now', 'current_timestamp', 'localtime', 'localtimestamp'], 'DATETIME', [], 'ALWAYS_NOT_NULLABLE'],
[['now', 'current_timestamp', 'localtime', 'localtimestamp'], 'DATETIMEV2', ['INT'], 'ALWAYS_NOT_NULLABLE'],
[['now', 'current_timestamp', 'localtime', 'localtimestamp'], 'DATETIME', [], 'DEPEND_ON_ARGUMENT'],
[['now', 'current_timestamp', 'localtime', 'localtimestamp'], 'DATETIMEV2', ['INT'], 'DEPEND_ON_ARGUMENT'],
[['curtime', 'current_time'], 'TIME', [], 'ALWAYS_NOT_NULLABLE'],
[['curdate', 'current_date'], 'DATE', [], 'ALWAYS_NOT_NULLABLE'],
[['utc_timestamp'], 'DATETIME', [], 'ALWAYS_NOT_NULLABLE'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ suite("test_date_function") {
// NOW
def now_result = sql """ select now() """
assertTrue(now_result[0].size() == 1)
def now_null_result = sql """ select now(null) """
assertTrue(now_null_result[0].size() == 1)

// SECOND
qt_sql """ select second('2018-12-31 23:59:59') """
Expand Down