Closed dor-bernstein closed 2 weeks ago
Hey @dor-bernstein,
Thanks for reporting these issues. Could you provide more context regarding TRANSFORM
? From what I see, in both Spark 3 and DuckDB the signature is transform(expr, func)
:
spark-sql (default)> select transform(array(1, 2, 3));
[WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `transform` requires 2 parameters but the actual number is 1. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix.; line 1 pos 7
spark-sql (default)> select transform(array(1, 2, 3), x -> x + 1); [2,3,4] Time taken: 3.092 seconds, Fetched 1 row(s)
- DuckDB:
D select list_transform([1, 2, 3]); Error: Binder Error: No function matches the given name and argument types 'list_transform(INTEGER[])'. You might need to add explicit type casts. Candidate functions: list_transform(ANY[], LAMBDA) -> ANY[]
LINE 1: select list_transform([1, 2, 3]); ^ D select list_transform([1, 2, 3], x -> x + 1); ┌──────────────────────────────────────────────────────────┐ │ list_transform(main.list_value(1, 2, 3), (x -> (x + 1))) │ │ int32[] │ ├──────────────────────────────────────────────────────────┤ │ [2, 3, 4] │ └──────────────────────────────────────────────────────────┘
@VaggelisD The signature for transforming lists is LIST_TRANSFORM (https://duckdb.org/docs/sql/functions/lambda), while parse_one returns just TRANSFORM.
Many Thanks!
Sorry for the confusion, I meant that your example is showcasing an invalid use of Spark's TRANSFORM(expr, func)
as it doesn't have a lambda defined; Is this a typo?
Yes, sorry. I'm using TRANSFORM(expr, func) and parse_one returns TRANFORM(expr, translated_func), while it should be LIST_TRANSFORM(expr, translated_func)
There are a couple of mistakes when translating from Spark to DuckDB
Fully reproducible code snippet
The output is:
Which fails for three different reasons: