You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/04/22 10:17:13 UTC

[GitHub] [incubator-doris] cambyzju opened a new pull request, #9170: [feature-wip](array-type) array_contains support more nested data types

cambyzju opened a new pull request, #9170:
URL: https://github.com/apache/incubator-doris/pull/9170

   # Proposed changes
   
   Issue Number: close #7570
   
   ## Problem Summary:
   1. array_contains and array_position support more nested data types;
   2. refractor FunctionArrayIndex;
   3. array functions support all const arguments, such as:
   > select array_position([33333,1,2],2);
   ```
   +---------------------------------------+
   | array_position(ARRAY(33333, 1, 2), 2) |
   +---------------------------------------+
   |                                     3 |
   +---------------------------------------+
   ```
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (Yes/No/I Don't know)
   5. Has unit tests been added: (Yes/No/No Need)
   6. Has document been added or modified: (Yes/No/No Need)
   7. Does it need to update dependencies: (Yes/No)
   8. Are there any changes that cannot be rolled back: (Yes/No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a diff in pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
HappenLee commented on code in PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#discussion_r857062167


##########
gensrc/script/doris_builtins_functions.py:
##########
@@ -117,67 +117,45 @@
     [['array'], 'ARRAY', ['ARRAY', '...'], '', '', '', '', ''],
     [['array'], 'ARRAY', ['MAP', '...'], '', '', '', '', ''],
     [['array'], 'ARRAY', ['STRUCT', '...'], '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['MAP', 'VARCHAR'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['MAP', 'INT'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['STRUCT', 'INT'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['STRUCT', 'VARCHAR'],  '', '', '', '', ''],
 
-    [['element_at', '%element_extract%'], 'TINYINT', ['ARRAY_TINYINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'TINYINT', ['ARRAY_TINYINT', 'INT'], '', 
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'SMALLINT', ['ARRAY_SMALLINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'SMALLINT', ['ARRAY_SMALLINT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'INT', ['ARRAY_INT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'INT', ['ARRAY_INT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'BIGINT', ['ARRAY_BIGINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'BIGINT', ['ARRAY_BIGINT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'VARCHAR', ['ARRAY_VARCHAR', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'VARCHAR', ['ARRAY_VARCHAR', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'STRING', ['ARRAY_STRING', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'STRING', ['ARRAY_STRING', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
 
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'TINYINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'SMALLINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'INT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'BIGINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'VARCHAR'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'STRING'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-
-    [['array_position'], 'BIGINT', ['ARRAY', 'TINYINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'SMALLINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'INT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'BIGINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'VARCHAR'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'STRING'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_TINYINT', 'TINYINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_SMALLINT', 'SMALLINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_INT', 'INT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_BIGINT', 'BIGINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_LARGEINT', 'LARGEINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DATETIME', 'DATETIME'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DATE', 'DATE'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_FLOAT', 'FLOAT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DOUBLE', 'DOUBLE'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DECIMALV2', 'DECIMALV2'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_VARCHAR', 'VARCHAR'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_STRING', 'STRING'], '', '', '', 'vec', ''],
+
+    [['array_position'], 'BIGINT', ['ARRAY_TINYINT', 'TINYINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_SMALLINT', 'SMALLINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_INT', 'INT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_BIGINT', 'BIGINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_LARGEINT', 'LARGEINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DATETIME', 'DATETIME'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DATE', 'DATE'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_FLOAT', 'FLOAT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DOUBLE', 'DOUBLE'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DECIMALV2', 'DECIMALV2'], '', '', '', 'vec', ''],

Review Comment:
   the return result type of `array_position` of 'element_at' param type should be same



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a diff in pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
HappenLee commented on code in PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#discussion_r867301048


##########
be/src/vec/functions/array/function_array_element.h:
##########
@@ -181,7 +183,8 @@ class FunctionArrayElement : public IFunction {
                                     const DataTypePtr& result_type, size_t input_rows_count,
                                     const UInt8* src_null_map, UInt8* dst_null_map) {
         // check array nested column type and get data
-        auto array_column = check_and_get_column<ColumnArray>(*arguments[0].column);
+        auto left_column = arguments[0].column->convert_to_full_column_if_const();
+        const auto array_column = check_and_get_column<ColumnArray>(*left_column);
         DCHECK(array_column != nullptr);

Review Comment:
   if can sure array_column is `ColumnArray`, not need to call `check_and_get_column`, use `reinterpret_cast`?



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] cambyzju commented on a diff in pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
cambyzju commented on code in PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#discussion_r867318408


##########
be/src/vec/functions/array/function_array_element.h:
##########
@@ -181,7 +183,8 @@ class FunctionArrayElement : public IFunction {
                                     const DataTypePtr& result_type, size_t input_rows_count,
                                     const UInt8* src_null_map, UInt8* dst_null_map) {
         // check array nested column type and get data
-        auto array_column = check_and_get_column<ColumnArray>(*arguments[0].column);
+        auto left_column = arguments[0].column->convert_to_full_column_if_const();
+        const auto array_column = check_and_get_column<ColumnArray>(*left_column);
         DCHECK(array_column != nullptr);

Review Comment:
   done



##########
be/src/vec/functions/array/function_array_index.h:
##########
@@ -213,24 +139,131 @@ class FunctionArrayIndex : public IFunction {
             }
             dst_data[row] = res;
         }
-        block.replace_by_position(result, std::move(dst));
-        return true;
+        return dst;
+    }
+
+    template <typename NestedColumnType>
+    ColumnPtr _execute_number_expanded(const ColumnArray::Offsets& offsets,
+                                       const UInt8* nested_null_map, const IColumn& nested_column,
+                                       const IColumn& right_column) {
+        if (check_column<ColumnUInt8>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnUInt8>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt8>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt8>(offsets, nested_null_map,
+                                                                 nested_column, right_column);
+        } else if (check_column<ColumnInt16>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt16>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt32>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt32>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt64>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt64>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt128>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt128>(offsets, nested_null_map,
+                                                                   nested_column, right_column);
+        } else if (check_column<ColumnFloat32>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnFloat32>(offsets, nested_null_map,
+                                                                    nested_column, right_column);
+        } else if (check_column<ColumnFloat64>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnFloat64>(offsets, nested_null_map,
+                                                                    nested_column, right_column);
+        } else if (right_column.is_date_type()) {
+            return _execute_number<NestedColumnType, ColumnDate>(offsets, nested_null_map,
+                                                                 nested_column, right_column);
+        } else if (right_column.is_datetime_type()) {
+            return _execute_number<NestedColumnType, ColumnDateTime>(offsets, nested_null_map,
+                                                                     nested_column, right_column);
+        } else if (check_column<ColumnDecimal128>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnDecimal128>(offsets, nested_null_map,
+                                                                       nested_column, right_column);
+        }
+        return nullptr;
     }
 
     Status _execute_non_nullable(Block& block, const ColumnNumbers& arguments, size_t result,
                                  size_t input_rows_count) {
-        WhichDataType right_type(block.get_by_position(arguments[1]).type);
-        if ((right_type.is_string() &&
-             _execute_string(block, arguments, result, input_rows_count)) ||
-            _execute_number<NUMBER_TPL_PACK>(block, arguments, result, input_rows_count)) {
+        // extract array offsets and nested data
+        auto left_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        const auto array_column = check_and_get_column<ColumnArray>(*left_column);

Review Comment:
   done



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#issuecomment-1123549916

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee merged pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
HappenLee merged PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#issuecomment-1123549948

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] cambyzju commented on a diff in pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
cambyzju commented on code in PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#discussion_r857100176


##########
gensrc/script/doris_builtins_functions.py:
##########
@@ -117,67 +117,45 @@
     [['array'], 'ARRAY', ['ARRAY', '...'], '', '', '', '', ''],
     [['array'], 'ARRAY', ['MAP', '...'], '', '', '', '', ''],
     [['array'], 'ARRAY', ['STRUCT', '...'], '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['MAP', 'VARCHAR'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['MAP', 'INT'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['STRUCT', 'INT'],  '', '', '', '', ''],
-    [['%element_extract%'], 'VARCHAR', ['STRUCT', 'VARCHAR'],  '', '', '', '', ''],
 
-    [['element_at', '%element_extract%'], 'TINYINT', ['ARRAY_TINYINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'TINYINT', ['ARRAY_TINYINT', 'INT'], '', 
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'SMALLINT', ['ARRAY_SMALLINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'SMALLINT', ['ARRAY_SMALLINT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'INT', ['ARRAY_INT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'INT', ['ARRAY_INT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'BIGINT', ['ARRAY_BIGINT', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'BIGINT', ['ARRAY_BIGINT', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'VARCHAR', ['ARRAY_VARCHAR', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'VARCHAR', ['ARRAY_VARCHAR', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
-    [['element_at', '%element_extract%'], 'STRING', ['ARRAY_STRING', 'INT'],
-        '_ZN5doris10vectorized20FunctionArrayElement12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
+    [['element_at', '%element_extract%'], 'STRING', ['ARRAY_STRING', 'INT'], '',
         '', '', 'vec', 'ALWAYS_NULLABLE'],
 
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'TINYINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'SMALLINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'INT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'BIGINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'VARCHAR'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_contains'], 'BOOLEAN', ['ARRAY', 'STRING'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayContainsActionENS0_17NameArrayContainsEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-
-    [['array_position'], 'BIGINT', ['ARRAY', 'TINYINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'SMALLINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'INT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'BIGINT'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'VARCHAR'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
-    [['array_position'], 'BIGINT', ['ARRAY', 'STRING'],
-        '_ZN5doris10vectorized18FunctionArrayIndexINS0_19ArrayPositionActionENS0_17NameArrayPositionEE12execute_implEPN9doris_udf15FunctionContextERNS0_5BlockERKSt6vectorImSaImEEmm',
-        '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_TINYINT', 'TINYINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_SMALLINT', 'SMALLINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_INT', 'INT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_BIGINT', 'BIGINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_LARGEINT', 'LARGEINT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DATETIME', 'DATETIME'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DATE', 'DATE'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_FLOAT', 'FLOAT'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DOUBLE', 'DOUBLE'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_DECIMALV2', 'DECIMALV2'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_VARCHAR', 'VARCHAR'], '', '', '', 'vec', ''],
+    [['array_contains'], 'BOOLEAN', ['ARRAY_STRING', 'STRING'], '', '', '', 'vec', ''],
+
+    [['array_position'], 'BIGINT', ['ARRAY_TINYINT', 'TINYINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_SMALLINT', 'SMALLINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_INT', 'INT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_BIGINT', 'BIGINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_LARGEINT', 'LARGEINT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DATETIME', 'DATETIME'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DATE', 'DATE'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_FLOAT', 'FLOAT'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DOUBLE', 'DOUBLE'], '', '', '', 'vec', ''],
+    [['array_position'], 'BIGINT', ['ARRAY_DECIMALV2', 'DECIMALV2'], '', '', '', 'vec', ''],

Review Comment:
   done
   
   element_at param type has changed to BIGINT, keep the same with the result type of array_position.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a diff in pull request #9170: [feature-wip](array-type) array_contains support more nested data types

Posted by GitBox <gi...@apache.org>.
HappenLee commented on code in PR #9170:
URL: https://github.com/apache/incubator-doris/pull/9170#discussion_r867309791


##########
be/src/vec/functions/array/function_array_index.h:
##########
@@ -213,24 +139,131 @@ class FunctionArrayIndex : public IFunction {
             }
             dst_data[row] = res;
         }
-        block.replace_by_position(result, std::move(dst));
-        return true;
+        return dst;
+    }
+
+    template <typename NestedColumnType>
+    ColumnPtr _execute_number_expanded(const ColumnArray::Offsets& offsets,
+                                       const UInt8* nested_null_map, const IColumn& nested_column,
+                                       const IColumn& right_column) {
+        if (check_column<ColumnUInt8>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnUInt8>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt8>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt8>(offsets, nested_null_map,
+                                                                 nested_column, right_column);
+        } else if (check_column<ColumnInt16>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt16>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt32>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt32>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt64>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt64>(offsets, nested_null_map,
+                                                                  nested_column, right_column);
+        } else if (check_column<ColumnInt128>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnInt128>(offsets, nested_null_map,
+                                                                   nested_column, right_column);
+        } else if (check_column<ColumnFloat32>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnFloat32>(offsets, nested_null_map,
+                                                                    nested_column, right_column);
+        } else if (check_column<ColumnFloat64>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnFloat64>(offsets, nested_null_map,
+                                                                    nested_column, right_column);
+        } else if (right_column.is_date_type()) {
+            return _execute_number<NestedColumnType, ColumnDate>(offsets, nested_null_map,
+                                                                 nested_column, right_column);
+        } else if (right_column.is_datetime_type()) {
+            return _execute_number<NestedColumnType, ColumnDateTime>(offsets, nested_null_map,
+                                                                     nested_column, right_column);
+        } else if (check_column<ColumnDecimal128>(right_column)) {
+            return _execute_number<NestedColumnType, ColumnDecimal128>(offsets, nested_null_map,
+                                                                       nested_column, right_column);
+        }
+        return nullptr;
     }
 
     Status _execute_non_nullable(Block& block, const ColumnNumbers& arguments, size_t result,
                                  size_t input_rows_count) {
-        WhichDataType right_type(block.get_by_position(arguments[1]).type);
-        if ((right_type.is_string() &&
-             _execute_string(block, arguments, result, input_rows_count)) ||
-            _execute_number<NUMBER_TPL_PACK>(block, arguments, result, input_rows_count)) {
+        // extract array offsets and nested data
+        auto left_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        const auto array_column = check_and_get_column<ColumnArray>(*left_column);

Review Comment:
   same to up



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org