Support for PG array_to_string() - concat elements of an array to string / text with a delimiter
See original GitHub issueUse case: Support for PG array_to_string() function in CrateDB.
This now can be done as workaround with an UDF for TEXT:
CREATE OR REPLACE function array_to_string(array(TEXT),TEXT)
RETURNS TEXT
LANGUAGE JAVASCRIPT
AS 'function array_to_string(arr, delimiter) { return Array.prototype.join.call(arr, delimiter);}';
SELECT array_to_string(['a','b','c'],',');
Feature description:
There is an array_to_string() function that concats elements with a delimiter (optionally replace NULL
values
From PostgreSQL
array_to_string ( array anyarray, delimiter text [, null_string text ] ) → text Converts each array element to its text representation, and concatenates those separated by the delimiter string. If null_string is given and is not NULL, then NULL array entries are represented by that string; otherwise, they are omitted. array_to_string(ARRAY[1, 2, 3, NULL, 5], ‘,’, '') → 1,2,3,,5
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Array.prototype.join() - JavaScript - MDN Web Docs - Mozilla
The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated...
Read more >Documentation: 9.1: Array Functions and Operators - PostgreSQL
Function Return Type Example Result
array_append (anyarray, anyelement) anyarray array_append(ARRAY, 3)
array_cat (anyarray, anyarray) anyarray array_cat(ARRAY, ARRAY)
array_ndims (anyarray) int array_ndims(ARRAY) 2
Read more >PostgreSQL ARRAY_TO_STRING()function - w3resource
ARRAY_TO_STRING() function. This function is used to concatenate array elements using supplied delimiter and optional null string. Syntax:
Read more >PostgreSQL Array to String - Linux Hint
In this example, we will simply try to concatenate the elements of a character array by executing the following query: # SELECT array_to_string(ARRAY['aqsa',...
Read more >Java String Array to String - DigitalOcean
So how to convert String array to String in java. We can use Arrays.toString method that invoke the toString() method on individual elements...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@BaurzhanSakhariev
array_to_string() would be a scalar function, similar to #10662 i.e. basically an extensions to the other aggregations in there
array_to_string
would be a scalar function It really would be the counterpart to string_to_array()One would have to unnest the array to use
string_agg()
first, which might not work with different length arrays in a recordset