Omega359 commented on code in PR #13637:
URL: https://github.com/apache/datafusion/pull/13637#discussion_r1873535480
##########
datafusion-examples/examples/advanced_udf.rs:
##########
@@ -215,9 +265,29 @@ async fn main() -> Result<()> {
// print the results
df.show().await?;
- // You can also invoke both pow(2, 10) and its alias my_pow(a, b) using
SQL
- let sql_df = ctx.sql("SELECT pow(2, 10), my_pow(a, b) FROM t").await?;
- sql_df.show().await?;
+ // You can also invoke both pow(2, 10) and its alias my_pow(a, b) using SQL
+ ctx.sql("SELECT pow(2, 10), my_pow(a, b) FROM t")
+ .await?
+ .show()
+ .await?;
+
+ // You can also invoke pow_in_place by passing a constant base and a
+ // column `a` as the exponent . If there is only a single
+ // reference to `a` the code works well
+ ctx.sql("SELECT pow(2, a) FROM t").await?.show().await?;
+
+ // However, if there are multiple references to `a` in the evaluation
+ // the array storage can not be reused
+ let err = ctx
+ .sql("SELECT pow(2, a), pow(3, a) FROM t")
+ .await?
+ .show()
+ .await
+ .unwrap_err();
+ assert_eq!(
+ err.to_string(),
+ "Execution error: Could not reuse array for pow_in_place"
+ );
Review Comment:
Went to test if this will work currently, found a bug in existing code :)
```sql
> SELECT pow(2, a), pow(3, a) FROM t;
Arrow error: Arithmetic overflow: Overflow happened on: 3 ^ 41
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]