Comments (7)
I agree with both, but both are vestiges of older SQL systems and duckdb makes an effort to be compatible with those.
from duckdb.
This is as expected. You're calling concat_ws(x, y)
and are getting y::VARCHAR
. You seem to think you're calling concat_ws(x, y[0], ..., y[n])
from duckdb.
To get what you want, you could use list_reduce(list(...), (x, y) -> concat_ws(', ', x, y))
although I feel like there might be a more elegant solution. As far as I'm aware there is no unpacking operator (like Python's star operator) though.
from duckdb.
Perhaps array_to_string()
from duckdb.
@cmdlineluser Ah, nice. TIL:
- All aggregate functions can be used on lists via
list_aggregate(listValue, '<NAMEOFAGGREGATEFUNCTION>', <MOREARGSTOAGGREGATEFUNCTION>)
. For most aggregate functions this is also available under the shorthandlist_<NAMEOFAGGREGATEFUNCTION>
. See https://duckdb.org/docs/sql/functions/nested#list-aggregates - There is a regular aggregate function called
string_agg(..., sep)
. See https://duckdb.org/docs/sql/aggregates.html. It's one of the aggregates that has a list shorthand:list_string_agg(..., sep)
(like all aggregate functions it can also be called vialist_aggregate(..., 'string_agg', sep)
on lists) - For some reason,
list_string_agg
is also available asarray_to_string
from duckdb.
Thanks all for prompt explanations and suggestions. I ended up using string_agg
, which works.
I don't think I like to variadic concat_ws
and would prefer concat_ws(sep, list)
with SQL engine complaining if the second argument is not a list. Also automatic coercion to string is error-prone.
from duckdb.
I see. Then it's working as intended I guess.
from duckdb.
Related Issues (20)
- `CAST( 'yes' AS BOOLEAN)` fails HOT 3
- No facility to parse formatted Number Strings to Numeric/Double/Decimal HOT 2
- MemoryError: std::bad_alloc HOT 4
- `Round()` and `Round_Even()` return different type HOT 1
- ORDER BY with nested list type gives wrong result
- Support brotli compression for Parquet files HOT 1
- Convert Column Type Failed HOT 2
- `REGEXP_REPLACE` replaces only the first match without any option for all matches HOT 2
- Shadowing of variable names in Python HOT 1
- Querying empty Polars dataframe produces internal error
- CURRENT_TIMESTAMP + INTERVAL 1 DAY fails HOT 5
- French stemmer doesn't work using FTS? HOT 3
- Boolean implicitly cast to integer in UNION clause
- Issue with Comparing TIMESTAMP WITH TIME ZONE and DATE
- Intermittent indefinitely hanging query [Python API]
- tests/fast/test_memory_leaks.py::TestMemoryLeaks::test_fetchmany - assert 5767168 <= 5000000
- CREATE AS SELECT segmentation faults HOT 1
- Python: Package pytz not included HOT 5
- Inconsistent date offsets with timezone handling HOT 16
- No comma separator writing list to csv in python HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckdb.