How to add two maps of key to values(array) together in Presto?

I have this presto query that gives me this. enter image description here

but what I am looking for is this.

{"accountnumber":"A00000065","invoice":{"ids":["2c92c09a693316310169384472126a0d"], "numbers":["INV00000270"]}}

I have tried using the map_concat to no luck. enter image description here

https://prestodb.io/docs/current/functions/map.html

UPDATE: If I do the following it works.

map_concat(multimap_agg('number', invoice.invoicenumber), multimap_agg('id', invoice.id))

but if I change to

map_concat(multimap_agg('number', invoice.invoicenumber), multimap_agg('id', invoice.balance))

I get this error

line 1:23: Unexpected parameters (map(varchar(6),array(varchar)), map(varchar(2),array(decimal(18,6)))) for function map_concat. Expected: map_concat(map(K,V)) K, V

1 answer

  • answered 2019-11-14 16:10 Piotr Findeisen

    It should go in a comment, but that's too long. If it doesn't work, I'll delete the answer.

    try this:

    SELECT map_concat(multimap_agg('ids', invoice.id), multimap_agg('numbers', invoice.invoicenumber))
    FROM ...