csun5285 commented on code in PR #68612:
URL: https://github.com/apache/doris/pull/68612#discussion_r4142139125


##########
be/src/exprs/lambda_function/varray_sort_function.cpp:
##########
@@ -263,6 +275,45 @@ class ArraySortFunction : public LambdaFunction {
     }
 
 private:
+    // Returns whether the comparator result in the first row is -1. Any value 
other than -1, 0 or 1
+    // fails the query.
+    static bool _is_negative_comparator_result(const IColumn& column, 
PrimitiveType type) {
+        const IColumn* values = &column;
+        if (const auto* nullable = 
check_and_get_column<ColumnNullable>(&column)) {
+            if (nullable->is_null_at(0)) {
+                throw Exception(Status::InvalidArgument(
+                        "array_sort comparator returns NULL, but it must 
return -1, 0 or 1"));
+            }
+            values = &nullable->get_nested_column();
+        }
+        Int128 result = 0;
+        switch (type) {
+        case TYPE_TINYINT:
+            result = assert_cast<const ColumnInt8&>(*values).get_element(0);
+            break;
+        case TYPE_SMALLINT:
+            result = assert_cast<const ColumnInt16&>(*values).get_element(0);
+            break;
+        case TYPE_INT:
+            result = assert_cast<const ColumnInt32&>(*values).get_element(0);
+            break;
+        case TYPE_BIGINT:
+            result = assert_cast<const ColumnInt64&>(*values).get_element(0);
+            break;
+        case TYPE_LARGEINT:
+            result = assert_cast<const ColumnInt128&>(*values).get_element(0);
+            break;
+        default:
+            DORIS_CHECK(false) << "array_sort comparator must return -1, 0 or 
1";
+        }
+        if (result != -1 && result != 0 && result != 1) {
+            throw Exception(Status::InvalidArgument(

Review Comment:
   遵循文档来检查



-- 
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]

Reply via email to