alamb opened a new issue, #8518:
URL: https://github.com/apache/arrow-datafusion/issues/8518
### Describe the bug
When I call a function like `random()` twice I expect to get different
values, but I only get a single value
### To Reproduce
```sql
❯ select random() r1, random() r2;
+--------------------+--------------------+
| r1 | r2 |
+--------------------+--------------------+
| 0.5798857099939392 | 0.5798857099939392 |
+--------------------+--------------------+
1 row in set. Query took 0.002 seconds.
```
### Expected behavior
I expect the values from the two different calls to `random()` to be
different
### Additional context
The explain plan shows what is wrong:
```sql
❯ explain select random() r1, random() r2;
+---------------+--------------------------------------------------------------------+
| plan_type | plan
|
+---------------+--------------------------------------------------------------------+
| logical_plan | Projection: random() AS random() AS r1, random() AS
random() AS r2 |
| | Projection: random() AS random()
|
| | EmptyRelation
|
| physical_plan | ProjectionExec: expr=[random()@0 as r1, random()@0 as r2]
|
| | ProjectionExec: expr=[random()]
|
| | PlaceholderRowExec
|
| |
|
+---------------+--------------------------------------------------------------------+
```
And explain verbose shows the problem is introduced in logical_plan after
`common_sub_expression_eliminate`:
```sql
❯ explain verbose select random() r1, random() r2;
+------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
| plan_type | plan
|
+------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
| initial_logical_plan | Projection:
random() AS r1, random() AS r2
|
| |
EmptyRelation
|
| logical_plan after inline_table_scan | SAME TEXT AS
ABOVE
|
....
|
| logical_plan after eliminate_cross_join | SAME TEXT AS
ABOVE
|
| logical_plan after common_sub_expression_eliminate | Projection:
random() AS random() AS r1, random() AS random() AS r2
|
| | Projection:
random() AS random()
|
| |
EmptyRelation
```
--
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]