hannes / duckdb-rfuns

R functions for duckdb
MIT License
14 stars 0 forks source link

Add string concatenation #104

Open krlmlr opened 1 month ago

krlmlr commented 1 month ago
romainfrancois commented 4 weeks ago

R paste0? takes ... that can be either vectors or constants, through the wonders of recycling. What should be handle here ?

I can prepare a PR for a paste that would handle two columns as a first stepping stone. Anything else would not bind and then go back to R.

krlmlr commented 2 weeks ago

I think constants are fine too.

concat() in duckdb has variadic arguments, can we implement in a similar way?

https://duckdb.org/docs/sql/functions/char#concatstring-

krlmlr commented 2 weeks ago

How does paste() convert non-string arguments internally? Can we issue a bind error with invalid types?

romainfrancois commented 4 days ago

https://github.com/duckdb/duckdb/blob/c3ca3607c221d315f38227b8bf58e68746c59083/src/function/scalar/string/concat.cpp

Looks like concat() uses things like D_ASSERT(input.GetType().InternalType() == PhysicalType::VARCHAR); to assert all its arguments are strings.

I suppose we could handle a variadic number of string vectors and constants and otherwise throw a bind error, and so let R handle it. I'm wondering though if this might be a feature of duckplyr, that would just map paste and poaste0 to concat.

krlmlr commented 4 days ago

Does duckdb support variadic macros? We'd need that for this idea. Otherwise we can forward in the C++ code in this repo?