Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Dec 25, 2024
1 parent 5b06770 commit cf1f1a3
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 2 deletions.
4 changes: 3 additions & 1 deletion be/src/vec/functions/function_date_or_datetime_computation.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ struct AddQuartersImpl {
return date_time_add<TimeUnit::MONTH, ArgType, ReturnType>(t, 3 * delta, is_null);
}

static DataTypes get_variadic_argument_types() { return {std::make_shared<DataTypeInt32>()}; }
static DataTypes get_variadic_argument_types() {
return {std::make_shared<ArgType>(), std::make_shared<DataTypeInt32>()};
}
};

template <typename Transform, typename DateType>
Expand Down
163 changes: 163 additions & 0 deletions regression-test/data/query_p0/sql_functions/test_years_add.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !empty_nullable --

-- !empty_not_nullable --

-- !empty_partial_nullable --

-- !nullable --
\N
\N
\N
\N
\N
\N
\N
\N
\N
1999-12-31T23:59:59
2000-12-31T23:59:59
2001-12-31T23:59:59
2004-12-31T23:59:59
2019-01-01T00:00
2019-02-28T00:00
2020-01-01T00:00
2020-02-29T00:00
2021-01-01T00:00
2021-02-28T00:00
2022-06-15T12:30:45
2023-06-15T12:30:45
2024-01-01T00:00
2024-02-29T00:00
2024-06-15T12:30:45
2027-06-15T12:30:45

-- !not_nullable --
1998-12-31T00:00
1999-12-31T00:00
1999-12-31T23:59:59
2000-12-31T00:00
2000-12-31T23:59:59
2001-12-31T23:59:59
2003-12-31T00:00
2004-12-31T23:59:59
2019-01-01T00:00
2019-02-28T00:00
2020-01-01T00:00
2020-02-29T00:00
2021-01-01T00:00
2021-02-28T00:00
2022-06-15T12:30:45
2023-06-15T12:30:45
2024-01-01T00:00
2024-02-29T00:00
2024-06-15T12:30:45
2027-06-15T12:30:45
2099-12-31T00:00
2100-12-31T23:59:59
2120-01-01T00:00
2120-02-29T00:00
2123-06-15T12:30:45

-- !partial_nullable --
\N
\N
\N
\N
\N
1998-12-31T00:00
1999-12-31T00:00
1999-12-31T23:59:59
2000-12-31T00:00
2000-12-31T23:59:59
2001-12-31T23:59:59
2003-12-31T00:00
2004-12-31T23:59:59
2019-01-01T00:00
2019-02-28T00:00
2020-01-01T00:00
2020-02-29T00:00
2021-01-01T00:00
2021-02-28T00:00
2022-06-15T12:30:45
2023-06-15T12:30:45
2024-01-01T00:00
2024-02-29T00:00
2024-06-15T12:30:45
2027-06-15T12:30:45

-- !nullable_no_null --
1998-12-31T00:00
1999-12-31T00:00
1999-12-31T23:59:59
2000-12-31T00:00
2000-12-31T23:59:59
2001-12-31T23:59:59
2003-12-31T00:00
2004-12-31T23:59:59
2019-01-01T00:00
2019-02-28T00:00
2020-01-01T00:00
2020-02-29T00:00
2021-01-01T00:00
2021-02-28T00:00
2022-06-15T12:30:45
2023-06-15T12:30:45
2024-01-01T00:00
2024-02-29T00:00
2024-06-15T12:30:45
2027-06-15T12:30:45
2099-12-31T00:00
2100-12-31T23:59:59
2120-01-01T00:00
2120-02-29T00:00
2123-06-15T12:30:45

-- !const_nullable --
\N
\N
\N
\N
\N

-- !partial_const_nullable --
\N
\N
\N
\N
\N

-- !const_not_nullable --
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00

-- !const_other_nullable --
\N
2019-01-01T00:00
2020-01-01T00:00
2021-01-01T00:00
2024-01-01T00:00

-- !const_other_not_nullable --
2000-12-31T00:00
2001-12-31T23:59:59
2021-01-01T00:00
2021-02-28T00:00
2024-06-15T12:30:45

-- !const_nullable_no_null --
2021-01-01T00:00

-- !const_nullable_no_null_multirows --
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00
2021-01-01T00:00

-- !const_partial_nullable_no_null --
2021-01-01T00:00

Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,70 @@ suite("test_quarters_add") {
/// special grammar
qt_datediff1 "select date_sub('2020-12-12', interval 1 quarter)"
qt_datediff2 "select date_add('2020-12-12', interval 1 quarter)"
//TODO: after #45265 merged add some exception test.

// Exception test cases for boundary conditions on BE
sql "set debug_skip_fold_constant=true;"
test {
sql """select quarters_add('9999-12-31', 1) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add('0000-01-01', -1) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add('2023-01-01', 40000) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add('2023-01-01', -40000) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

// Exception test cases for nullable scenarios
test {
sql """select quarters_add(nullable('9999-12-31'), 1) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add('9999-12-31', nullable(1)) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add(nullable('0000-01-01'), nullable(-1)) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add(nullable('2023-01-01'), nullable(40000)) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}

test {
sql """select quarters_add(nullable('2023-01-01'), nullable(-40000)) from hits_two_args_quar_add;"""
check { result, exception, startTime, endTime ->
assertTrue(exception != null)
}
}
}
Loading

0 comments on commit cf1f1a3

Please sign in to comment.