zclllyybb commented on code in PR #57253:
URL: https://github.com/apache/doris/pull/57253#discussion_r2462993477
##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -580,10 +617,72 @@ class FunctionDateOrDateTimeComputation : public
IFunction {
// vector-const
if (const auto* nest_col1_const =
check_and_get_column<ColumnConst>(*nest_col1)) {
rconst = true;
- const auto col1_inside_const =
- assert_cast<const
IntervalColumnType&>(nest_col1_const->get_data_column());
- Op::vector_constant(sources->get_data(), res_col->get_data(),
- col1_inside_const.get_data()[0], nullmap0,
nullmap1);
+ if constexpr (Transform::IntervalPRealType == TYPE_STRING) {
Review Comment:
the specific calculation logic shouldn't put here. should in `Op`.
##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -580,10 +617,72 @@ class FunctionDateOrDateTimeComputation : public
IFunction {
// vector-const
if (const auto* nest_col1_const =
check_and_get_column<ColumnConst>(*nest_col1)) {
rconst = true;
- const auto col1_inside_const =
- assert_cast<const
IntervalColumnType&>(nest_col1_const->get_data_column());
- Op::vector_constant(sources->get_data(), res_col->get_data(),
- col1_inside_const.get_data()[0], nullmap0,
nullmap1);
+ if constexpr (Transform::IntervalPRealType == TYPE_STRING) {
+ StringRef time_str =
nest_col1_const->get_data_at(0).trim();
Review Comment:
ignore this
##########
be/src/vec/functions/function_date_or_datetime_computation_v2.cpp:
##########
@@ -26,6 +26,7 @@ using FunctionAddWeeksV2 =
FunctionDateOrDateTimeComputation<AddWeeksImpl<TYPE_D
using FunctionAddMonthsV2 =
FunctionDateOrDateTimeComputation<AddMonthsImpl<TYPE_DATEV2>>;
using FunctionAddQuartersV2 =
FunctionDateOrDateTimeComputation<AddQuartersImpl<TYPE_DATEV2>>;
using FunctionAddYearsV2 =
FunctionDateOrDateTimeComputation<AddYearsImpl<TYPE_DATEV2>>;
+using FunctionAddDaySecondV2 =
FunctionDateOrDateTimeComputation<AddDaySecondImpl<TYPE_DATEV2>>;
Review Comment:
you dont have this signature, please remove
##########
regression-test/suites/query_p0/sql_functions/datetime_functions/test_dateadd_with_other_timeunit.groovy:
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import java.text.SimpleDateFormat
+
+suite("test_dateadd_with_other_timeunit") {
+ def tableName = "test_date_add_with_other_timeunit"
+
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tableName} (
+ test_datetime datetime NULL COMMENT "",
+ test_date date NULL COMMENT ""
+ ) ENGINE=OLAP
+ DUPLICATE KEY(test_datetime)
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH(test_datetime) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ )
+ """
+ sql """ insert into ${tableName} values ("2019-08-01 13:21:03",
"2025-09-08") """
+
+ qt_sql """ select date_add("2019-08-01 13:21:03", INTERVAL "1 1:1:1"
DAY_SECOND); """
Review Comment:
also use `testFoldConst` to ensure consistency of execution result in BE and
FE
##########
be/src/vec/functions/function_date_or_datetime_computation.h:
##########
@@ -124,11 +127,34 @@ ADD_TIME_FUNCTION_IMPL(AddWeeksImpl, weeks_add, WEEK);
ADD_TIME_FUNCTION_IMPL(AddMonthsImpl, months_add, MONTH);
ADD_TIME_FUNCTION_IMPL(AddYearsImpl, years_add, YEAR);
+template <PrimitiveType PType>
+struct AddDaySecondImpl {
+ static constexpr PrimitiveType ArgPType = PType;
+ static constexpr PrimitiveType ReturnType = PType;
+ static constexpr PrimitiveType IntervalPType = PrimitiveType ::TYPE_INT;
+ static constexpr PrimitiveType IntervalPRealType = TYPE_STRING;
Review Comment:
this problem is easy to resolve——add requires clause to functions in
DateTimeOp to specific if it should exist depending on template argument.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]