Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-3.0: [fix](function) fixed some nested type func's param type which is not suitable and make result wrong #44923 #45296

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

github-actions[bot]
Copy link
Contributor

Cherry-picked from #44923

… suitable and make result wrong (#44923)

nereids funcs signature for some nested type func's param type defined
not right which will make result wrong such as
```
mysql> SELECT array_position([1,258],257),array_position([2],258);
+-------------------------------+-------------------------------------------+
| array_position([1, 258], 257) | array_position([2], cast(258 as TINYINT)) |
+-------------------------------+-------------------------------------------+
|                             0 |                                         1 |
+-------------------------------+-------------------------------------------+
1 row in set (0.14 sec)

mysql> select array_apply([258], '>' , 257), array_apply([1,2,3], '>', 258);
+------------------------------+---------------------------------------------------+
| array_apply([258], '>', 257) | array_apply([1, 2, 3], '>', cast(258 as TINYINT)) |
+------------------------------+---------------------------------------------------+
| [258]                        | [3]                                               |
+------------------------------+---------------------------------------------------+
1 row in set (0.11 sec)

mysql>  select array_contains([258], 257), array_contains([1,2,3], 258);
+----------------------------+-------------------------------------------------+
| array_contains([258], 257) | array_contains([1, 2, 3], cast(258 as TINYINT)) |
+----------------------------+-------------------------------------------------+
|                          0 |                                               1 |
+----------------------------+-------------------------------------------------+
1 row in set (0.12 sec)

mysql>
mysql> select array_pushfront([258], 257), array_pushfront([1,2,3], 258);
+-----------------------------+--------------------------------------------------+
| array_pushfront([258], 257) | array_pushfront([1, 2, 3], cast(258 as TINYINT)) |
+-----------------------------+--------------------------------------------------+
| [257, 258]                  | [2, 1, 2, 3]                                     |
+-----------------------------+--------------------------------------------------+
1 row in set (0.12 sec)

mysql> select array_pushback([1,258], 257), array_pushback([1,2,3], 258);
+-------------------------------+-------------------------------------------------+
| array_pushback([1, 258], 257) | array_pushback([1, 2, 3], cast(258 as TINYINT)) |
+-------------------------------+-------------------------------------------------+
| [1, 258, 257]                 | [1, 2, 3, 2]                                    |
+-------------------------------+-------------------------------------------------+
1 row in set (0.10 sec)

mysql> select array_remove([1,258], 257), array_remove([1,2,3], 258);
+-----------------------------+-----------------------------------------------+
| array_remove([1, 258], 257) | array_remove([1, 2, 3], cast(258 as TINYINT)) |
+-----------------------------+-----------------------------------------------+
| [1, 258]                    | [1, 3]                                        |
+-----------------------------+-----------------------------------------------+
1 row in set (0.12 sec)
mysql> select map_contains_key(map(1,258), 257), map_contains_key(map(1,2), 258);
+-----------------------------------------------------+---------------------------------------------------+
| map_contains_key(map(1, 258), cast(257 as TINYINT)) | map_contains_key(map(1, 2), cast(258 as TINYINT)) |
+-----------------------------------------------------+---------------------------------------------------+
|                                                   1 |                                                 0 |
+-----------------------------------------------------+---------------------------------------------------+
1 row in set (0.12 sec)

mysql> select map_contains_key(map(1,258), 257), map_contains_key(map(1,3), 258);
+-----------------------------------------------------+---------------------------------------------------+
| map_contains_key(map(1, 258), cast(257 as TINYINT)) | map_contains_key(map(1, 3), cast(258 as TINYINT)) |
+-----------------------------------------------------+---------------------------------------------------+
|                                                   1 |                                                 0 |
+-----------------------------------------------------+---------------------------------------------------+
1 row in set (0.11 sec)

mysql> select map_contains_key(map(1,258), 257), map_contains_key(map(3,1), 258);
+-----------------------------------------------------+---------------------------------------------------+
| map_contains_key(map(1, 258), cast(257 as TINYINT)) | map_contains_key(map(3, 1), cast(258 as TINYINT)) |
+-----------------------------------------------------+---------------------------------------------------+
|                                                   1 |                                                 0 |
+-----------------------------------------------------+---------------------------------------------------+
```
but true result is 
```
mysql> SELECT array_position([1,258],257),array_position([2],258);
+-------------------------------+---------------------------------------------------+
| array_position([1, 258], 257) | array_position(cast([2] as ARRAY<SMALLINT>), 258) |
+-------------------------------+---------------------------------------------------+
|                             0 |                                                 0 |
+-------------------------------+---------------------------------------------------+
1 row in set (0.73 sec)

mysql> select array_apply([258], '>' , 257), array_apply([1,2,3], '>', 258);
+------------------------------+-----------------------------------------------------------+
| array_apply([258], '>', 257) | array_apply(cast([1, 2, 3] as ARRAY<SMALLINT>), '>', 258) |
+------------------------------+-----------------------------------------------------------+
| [258]                        | []                                                        |
+------------------------------+-----------------------------------------------------------+
1 row in set (0.10 sec)

mysql> select array_contains([258], 257), array_contains([1,2,3], 258);
+----------------------------+---------------------------------------------------------+
| array_contains([258], 257) | array_contains(cast([1, 2, 3] as ARRAY<SMALLINT>), 258) |
+----------------------------+---------------------------------------------------------+
|                          0 |                                                       0 |
+----------------------------+---------------------------------------------------------+
1 row in set (0.09 sec)

mysql> select array_pushfront([258], 257), array_pushfront([1,2,3], 258);
+-----------------------------+----------------------------------------------------------+
| array_pushfront([258], 257) | array_pushfront(cast([1, 2, 3] as ARRAY<SMALLINT>), 258) |
+-----------------------------+----------------------------------------------------------+
| [257, 258]                  | [258, 1, 2, 3]                                           |
+-----------------------------+----------------------------------------------------------+
1 row in set (0.11 sec)

mysql> select array_remove([1,258], 257), array_remove([1,2,3], 258);
+-----------------------------+-------------------------------------------------------+
| array_remove([1, 258], 257) | array_remove(cast([1, 2, 3] as ARRAY<SMALLINT>), 258) |
+-----------------------------+-------------------------------------------------------+
| [1, 258]                    | [1, 2, 3]                                             |
+-----------------------------+-------------------------------------------------------+
1 row in set (0.09 sec)

mysql> select countequal([1,258], 257), array_count_equal([1,2,3], 258);
ERROR 1105 (HY000): errCode = 2, detailMessage = Can not found function 'array_count_equal'
mysql> select countequal([1,258], 257), countequal([1,2,3], 258);
+---------------------------+-----------------------------------------------------+
| countequal([1, 258], 257) | countequal(cast([1, 2, 3] as ARRAY<SMALLINT>), 258) |
+---------------------------+-----------------------------------------------------+
|                         0 |                                                   0 |
+---------------------------+-----------------------------------------------------+
1 row in set (0.08 sec)

mysql> select map_contains_key(map(1,258), 257), map_contains_key(map(2,1), 258);
+--------------------------------------------------------------------+-----------------------------------------------------------------+
| map_contains_key(cast(map(1, 258) as MAP<SMALLINT,SMALLINT>), 257) | map_contains_key(cast(map(2, 1) as MAP<SMALLINT,TINYINT>), 258) |
+--------------------------------------------------------------------+-----------------------------------------------------------------+
|                                                                  0 |                                                               0 |
+--------------------------------------------------------------------+-----------------------------------------------------------------+
1 row in set (0.09 sec)

mysql> select map_contains_value(map(1,1), 257), map_contains_value(map(1,2), 258);
+-------------------------------------------------------------------+-------------------------------------------------------------------+
| map_contains_value(cast(map(1, 1) as MAP<TINYINT,SMALLINT>), 257) | map_contains_value(cast(map(1, 2) as MAP<TINYINT,SMALLINT>), 258) |
+-------------------------------------------------------------------+-------------------------------------------------------------------+
|                                                                 0 |                                                                 0 |
+--------------------------------------------------
```
@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Dec 11, 2024
@doris-robot
Copy link

run buildall

Copy link
Contributor Author

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

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 23, 2024
Copy link
Contributor Author

PR approved by anyone and no changes requested.

@morrySnow morrySnow merged commit d8413bb into branch-3.0 Dec 23, 2024
24 of 26 checks passed
@github-actions github-actions bot deleted the auto-pick-44923-branch-3.0 branch December 23, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants