Expand my Community achievements bar.

SOLVED

MAP Complex datatype

Avatar

Level 2

Hello Experts,

 

I want to add value to field which is defined as MAP datatype (Complex type)

 

VijayLa_0-1717088541436.png

 

 

I am giving the following as calculated field as shown in screenshot below.

ID_SPECIFIC_SMS_FLAG - 'n'

 

but the field IdSpecific is not updated with 'n'; it shows as null . Please assist me.

VijayLa_1-1717088581413.png

 

 

Thanks,

Viji.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

yes you are correct you can't change the type of standard fields only, however the schema is not predefined you can create your own new fields as per the requirement check this tutorial on how to add new fields in a schema, i would recommend creating a new field which is best suited for your requirement(an enum would be better if you just want to save "y" or "n") then use data prep functions to alter your data accordingly for the new field 

 

Now again the map data type is used to store key value pairs in a field a common example of map type field is Identity map refer to this document for more details on map type fields.

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @VijayLa

as per the description of to_map function it will take comma separated strings and create key value pairs for example if you provide to_map("first","value1","second","value2") you'll get first:value1 and second:value2

it seems to be some syntax error hence you are getting the null results.

could you provide some more context on the variables you are using in your map function.

Avatar

Level 2

Hi @Ankit_Chaudhary 

 

Thanks for the details. My Objective is to populate the IDSpecific field with a value of either 'y' or 'n'. My source is snowflake View. When I attempt to map directly from snowflake view field to Id Specific field, it throwed the below error

The source field with the leaf schema type STRING cannot be mapped to the destination field of type MAP. Please use the correct source schema type that corresponds to the destination field type and try again.

 

Please suggest a best method to populate the value in Id Specific field.

 

Thanks,

Vijay

Avatar

Community Advisor

Hi @VijayLa 

I guess If you are trying to put string values "y" or "n" in the idSpecific field you don't have to make a it map type field as map is a special type field used to store key value pairs for strings you can use logical functions during data prep using iif function  

 

Hope this will help let me know if I am missing something

Avatar

Level 2

Hi @Ankit_Chaudhary 

The schema is pre defined. I don't think we can change the datatype of the Schema .

Its known limitation.

 

can you think of a work around in this situation?

 

Also, can you give me some examples of values stored for MAP datatype.

 

Thanks,

Vijay.

Avatar

Correct answer by
Community Advisor

yes you are correct you can't change the type of standard fields only, however the schema is not predefined you can create your own new fields as per the requirement check this tutorial on how to add new fields in a schema, i would recommend creating a new field which is best suited for your requirement(an enum would be better if you just want to save "y" or "n") then use data prep functions to alter your data accordingly for the new field 

 

Now again the map data type is used to store key value pairs in a field a common example of map type field is Identity map refer to this document for more details on map type fields.