StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
8.99k stars 1.81k forks source link

[BUG] Incorrect JSON array comparison when comparing small and large integers #44566

Open pbjc opened 6 months ago

pbjc commented 6 months ago

When comparing a JSON array containing a small integer with a JSON array containing a very large integer, the result is sometimes incorrect.

Steps to reproduce the behavior (Required)

select json_array(1) < json_array(9223372036854775807);

Expected behavior (Required)

mysql> select json_array(1) < json_array(9223372036854775807);
+-----------------------------------------------------+
| (json_array(1)) < (json_array(9223372036854775807)) |
+-----------------------------------------------------+
|                                                   1 |
+-----------------------------------------------------+

mysql> select json_array(1) < json_array(922337203685477580);
+-----------------------------------------------------+
| (json_array(1)) < (json_array(9223372036854775807)) |
+-----------------------------------------------------+
|                                                   1 |
+-----------------------------------------------------+

mysql> select json_array(1) < json_array(92233720368547758);
+-----------------------------------------------------+
| (json_array(1)) < (json_array(9223372036854775807)) |
+-----------------------------------------------------+
|                                                   1 |
+-----------------------------------------------------+

Real behavior (Required)

mysql> select json_array(1) < json_array(9223372036854775807);
+-----------------------------------------------------+
| (json_array(1)) < (json_array(9223372036854775807)) |
+-----------------------------------------------------+
|                                                   0 |
+-----------------------------------------------------+
1 row in set (0.07 sec)

mysql> select json_array(1) < json_array(922337203685477580);
+----------------------------------------------------+
| (json_array(1)) < (json_array(922337203685477580)) |
+----------------------------------------------------+
|                                                  0 |
+----------------------------------------------------+
1 row in set (0.06 sec)

mysql> select json_array(1) < json_array(92233720368547758);
+---------------------------------------------------+
| (json_array(1)) < (json_array(92233720368547758)) |
+---------------------------------------------------+
|                                                 1 |
+---------------------------------------------------+
1 row in set (0.06 sec)

StarRocks version (Required)

3.2.4-613f0b5

github-actions[bot] commented 3 weeks ago

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!

pbjc commented 3 weeks ago

Bump