jonahgao commented on issue #10337:
URL: https://github.com/apache/datafusion/issues/10337#issuecomment-2096302497

   I worry that judging whether a query is non-deterministic may be not easy. 
Perhaps we can first leave this judgment to the user, only do this when the 
user specifies 
[Materialized](https://github.com/sqlparser-rs/sqlparser-rs/blob/a86c58b1c93960d50476713ff56e02bf94d41436/src/ast/query.rs#L452)
 and there are multiple references.
   
   DuckDB may have taken a similar approach.
   ```sh
   v0.10.3-dev779 d26007417b
   
   D with cte as (select random()) select * from cte union select * from cte;
   ┌────────────────────┐
   │      random()      │
   │       double       │
   ├────────────────────┤
   │ 0.9430218460038304 │
   │ 0.3114725165069103 │
   └────────────────────┘
   D with cte as materialized (select random()) select * from cte union select 
* from cte;
   ┌─────────────────────┐
   │      random()       │
   │       double        │
   ├─────────────────────┤
   │ 0.13616445031948388 │
   └─────────────────────┘
   ```


-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to