duongcongtoai commented on code in PR #10148:
URL: https://github.com/apache/datafusion/pull/10148#discussion_r1581476454


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -177,7 +177,18 @@ impl PhysicalExpr for ScalarFunctionExpr {
                 let fun = create_physical_fun(fun)?;
                 (fun)(&inputs)
             }
-            ScalarFunctionDefinition::UDF(ref fun) => fun.invoke(&inputs),
+            ScalarFunctionDefinition::UDF(ref fun) => {
+                let output = fun.invoke(&inputs)?;
+                let output_count = match &output {

Review Comment:
   Btw I also tested with Spark and Duckdb for their version of "typeof"
   Duckdb
   ```
   toai@ToaiPC:~/proj/rust/arrow-datafusion/datafusion/core/tests/data$ duckdb 
   v0.10.2 1601d94f94
   Enter ".help" for usage hints.
   Connected to a transient in-memory database.
   Use ".open FILENAME" to reopen on a persistent database.
   D select typeof(ints) from parquet_map.parquet
     ;
   ┌──────────────────────┐
   │     typeof(ints)     │
   │       varchar        │
   ├──────────────────────┤
   │ MAP(VARCHAR, BIGINT) │
   │ MAP(VARCHAR, BIGINT) │
   │ MAP(VARCHAR, BIGINT) │
   │ MAP(VARCHAR, BIGINT) │
   │ MAP(VARCHAR, BIGINT) │
   │ MAP(VARCHAR, BIGINT) │
   ```
   and Spark
   ```
   val data = Seq(
     ("Alice", Map("age" -> "25", "email" -> "al...@example.com")),
     ("Bob", Map("age" -> "30", "email" -> "b...@example.com")),
     ("Carol", Map("age" -> "35", "email" -> "ca...@example.com"))
   )
   val df = data.toDF("name", "attributes")
   val types = df.select($"name", typeof($"name").as("name_type"), 
$"attributes", typeof($"attributes").as("attributes_type"))
   types.show(false)
   +-----+---------+---------------------------------------+------------------+
   |name |name_type|attributes                             |attributes_type   |
   +-----+---------+---------------------------------------+------------------+
   |Alice|string   |{age -> 25, email -> al...@example.com}|map<string,string>|
   |Bob  |string   |{age -> 30, email -> b...@example.com}  |map<string,string>|
   |Carol|string   |{age -> 35, email -> ca...@example.com}|map<string,string>|
   +-----+---------+---------------------------------------+------------------+
   ```
   Look like they also respect number of input row
   



-- 
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