question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for PG array_to_string() - concat elements of an array to string / text with a delimiter

See original GitHub issue

Use 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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
proddatacommented, Apr 20, 2021

@BaurzhanSakhariev

array_to_string() would be a scalar function, similar to #10662 i.e. basically an extensions to the other aggregations in there

1reaction
proddatacommented, Apr 20, 2021

Isn’t this string_agg ?

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

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found