github-actions[bot] commented on code in PR #66943:
URL: https://github.com/apache/doris/pull/66943#discussion_r3860332877
##########
be/src/exprs/lambda_function/varray_sort_function.cpp:
##########
@@ -390,46 +391,23 @@ class ArraySortFunction : public LambdaFunction {
expr->children()[0]->node_type() ==
TExprNodeType::LAMBDA_FUNCTION_EXPR;
}
-#define DISPATCH_PRIMITIVE_TYPE(TYPE, COLUMN_CLASS) \
- case TYPE: \
- column_variant = &assert_cast<const COLUMN_CLASS&>(column); \
- break;
-
Status get_data_from_type(PrimitiveType pType, const IColumn& column,
ConstColumnVariant& column_variant) const {
- switch (pType) {
- DISPATCH_PRIMITIVE_TYPE(TYPE_BOOLEAN, ColumnUInt8)
- DISPATCH_PRIMITIVE_TYPE(TYPE_TINYINT, ColumnInt8)
- DISPATCH_PRIMITIVE_TYPE(TYPE_SMALLINT, ColumnInt16)
- DISPATCH_PRIMITIVE_TYPE(TYPE_INT, ColumnInt32)
- DISPATCH_PRIMITIVE_TYPE(TYPE_BIGINT, ColumnInt64)
- DISPATCH_PRIMITIVE_TYPE(TYPE_LARGEINT, ColumnInt128)
- DISPATCH_PRIMITIVE_TYPE(TYPE_FLOAT, ColumnFloat32)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DOUBLE, ColumnFloat64)
- DISPATCH_PRIMITIVE_TYPE(TYPE_CHAR, ColumnString)
- DISPATCH_PRIMITIVE_TYPE(TYPE_STRING, ColumnString)
- DISPATCH_PRIMITIVE_TYPE(TYPE_VARCHAR, ColumnString)
- DISPATCH_PRIMITIVE_TYPE(TYPE_VARBINARY, ColumnVarbinary)
- DISPATCH_PRIMITIVE_TYPE(TYPE_ARRAY, ColumnArray)
- DISPATCH_PRIMITIVE_TYPE(TYPE_IPV4, ColumnIPv4)
- DISPATCH_PRIMITIVE_TYPE(TYPE_IPV6, ColumnIPv6)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DECIMAL32, ColumnDecimal32)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DECIMAL64, ColumnDecimal64)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DECIMAL128I, ColumnDecimal128V3)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DECIMALV2, ColumnDecimal128V2)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DECIMAL256, ColumnDecimal256)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DATE, ColumnDate)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DATETIME, ColumnDateTime)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DATEV2, ColumnDateV2)
- DISPATCH_PRIMITIVE_TYPE(TYPE_DATETIMEV2, ColumnDateTimeV2)
- DISPATCH_PRIMITIVE_TYPE(TYPE_TIMEV2, ColumnTimeV2)
- default:
- return Status::InternalError("Unsupported type in array_sort");
+ if (pType == TYPE_ARRAY) {
+ column_variant = &assert_cast<const ColumnArray&>(column);
+ return Status::OK();
}
- return Status::OK();
- }
-#undef DISPATCH_PRIMITIVE_TYPE
+ if (dispatch_switch_all(pType, [&](const auto& type) {
Review Comment:
`dispatch_switch_all` does not cover `TYPE_VARBINARY`, so this refactor
removes an existing supported path. FE allows a lambda `array_sort` over
`ARRAY<VARBINARY>`; for example, a two-element VARBINARY array with a
length-based comparator reached the base switch's `TYPE_VARBINARY ->
ColumnVarbinary` branch, while this version falls through to `Unsupported type
in array_sort` before sorting. Please preserve an explicit VARBINARY case (or
extend the common dispatcher) and add a regression so TIMESTAMPTZ support does
not break existing VARBINARY queries.
##########
regression-test/suites/datatype_p0/timestamptz/test_timestamptz_lambda_array_sort.groovy:
##########
@@ -0,0 +1,27 @@
+// 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.
+
+suite("test_timestamptz_lambda_array_sort") {
+ sql "set time_zone = '+08:00';"
+
+ qt_lambda_array_sort """
+ SELECT array_sort(
+ (`x`, `y`) -> CAST(0 AS TINYINT),
Review Comment:
This case catches the old unsupported-type error, but it does not exercise
the comparator: a one-element `std::sort` range need not invoke it, and this
lambda ignores both arguments. The test would still pass if copying TIMESTAMPTZ
values into the lambda block or comparing them were broken. Please use at least
two out-of-order values and a comparator that reads both `x` and `y` (ideally
also covering NULL and equivalent/different instants written with different
offsets) so the claimed lambda-sort behavior is actually verified.
--
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]