hhh
hhh

Reputation: 52840

String concatenation in AWS Glue Athena?

I need to find a string concatenation function in AWS Glue inside GROUP BY, so far tried

SELECT CONCAT('wo', 'rd');

for which I need concatenation inside GROUP BY, written in meta language:

SELECT CONCAT(field_word WITH SEPARATOR '>' ORDER BY Order1) FROM myData GROUP BY ID;

SELECT STRING_AGG(field_word WITH SEPARATOR '>' ORDER BY Order1) FROM myData GROUP BY ID;

but the earlier do not work.

How can I concatenate strings inside AWS Glue athena?

Upvotes: 0

Views: 10392

Answers (1)

Piotr Findeisen
Piotr Findeisen

Reputation: 20730

You can combine array_agg with array_join:

presto> SELECT array_join(array_agg(e), ',', 'NULL')
     -> FROM (VALUES 'wo', 'rd') t(e);
 _col0
-------
 wo,rd
(1 row)

Upvotes: 2

Related Questions