cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Uniformize document schema

Fabien
New Contributor II

Hello!

I am trying to uniformize document schema, I was not able to achieve it using a mapper or a JSon formatter snap.

For instance, if I have this input (using JSonGenerator)

[
    {
        "num" : 1

    },
    {
        "msg" : "Hello, World", "num" : 2
    }
]

I want this output:

[
    {
        "msg" : null, "num" : 1
    },
    {
        "msg" : "Hello, World", "num" : 2
    }
]

I need to use this feature in a generic pipeline, thus I cannot use explicitly the keys (โ€˜numโ€™ or โ€˜msgโ€™)

I need to have all the keys in the first document because I am using Snowflake Bulk Insert downsteam and the generated โ€˜Merge Intoโ€™ command that is executed in Snowflake only take the first document keys unfortunately (same behavior with a csv parser for instance, but this is not documented for Snowflake Bulk Insert)

Has anyone an idea to achieve this ?

thank you

1 ACCEPTED SOLUTION

alchemiz
Contributor III

Hi @Fabien,

Good day, see attached PoC pipeline

image

canvas_01_2023_03_12.slp (12.6 KB)

Hope this helps

Thanks,
EmEm

View solution in original post

2 REPLIES 2

alchemiz
Contributor III

Hi @Fabien,

Good day, see attached PoC pipeline

image

canvas_01_2023_03_12.slp (12.6 KB)

Hope this helps

Thanks,
EmEm

Fabien
New Contributor II

Wow! thank you a lot @alchemiz ! Thatโ€™s brillant !

I am using a โ€˜Gateโ€™ Snap to gather the document in one and thus I can use the logic you built in the mappers and it works A1 !

Have a nice week !