04-01-2021 03:06 AM
Hello,
I am developing a custom snap and I would like to know if it’s possible to add more default rows to a table. For example the Mapper snap has one default row when we open it.
I want something similar to the Snowflake SCD2 snap, when we open the snap it has 4 default rows.
I’ve searched the documentation but I didn’t find anything about this particular problem.
Solved! Go to Solution.
04-05-2021 11:49 AM
To elaborate, you’d set the defaultValue to DEFAULT_TABLE_VALUES defined something like this:
private static final Map<String, Object> MEANING_ENTRY1 = ImmutableMap.of("value", DEFAULT_MEANING_0);
private static final Map<String, Object> MEANING_ENTRY2 = ImmutableMap.of("value", DEFAULT_MEANING_1);
private static final Map<String, Object> MEANING_ENTRY3 = ImmutableMap.of("value", DEFAULT_MEANING_2);
private static final Map<String, Object> MEANING_ENTRY4 = ImmutableMap.of("value", DEFAULT_MEANING_3);
private static final Map<String, Object> VALUE_ENTRY3 = ImmutableMap.of("expression", true, "value", DEFAULT_VALUE_2);
private static final Map<String, Object> VALUE_ENTRY4 = ImmutableMap.of("expression", true, "value", DEFAULT_VALUE_2);
private static final Map<String, Object> ROW1 = ImmutableMap.of("meaning", MEANING_ENTRY1);
private static final Map<String, Object> ROW2 = ImmutableMap.of("meaning", MEANING_ENTRY2);
private static final Map<String, Object> ROW3 = ImmutableMap.of("meaning", MEANING_ENTRY3, "value", VALUE_ENTRY3);
private static final Map<String, Object> ROW4 = ImmutableMap.of("meaning", MEANING_ENTRY4, "value", VALUE_ENTRY4);
private static final List<Object> DEFAULT_TABLE_VALUES = ImmutableList.of(ROW1, ROW2, ROW3, ROW4);
04-05-2021 05:22 AM
@ptaylor any suggestions ?
04-05-2021 11:35 AM
It is, using the defaultValue of the TABLE property. It’s a bit verbose. But I’m curious why you’d prefer this odd table row approach rather than just having distinct settings at the top level? Frankly I don’t really understand why that approach was taken in that snap.
04-05-2021 11:49 AM
To elaborate, you’d set the defaultValue to DEFAULT_TABLE_VALUES defined something like this:
private static final Map<String, Object> MEANING_ENTRY1 = ImmutableMap.of("value", DEFAULT_MEANING_0);
private static final Map<String, Object> MEANING_ENTRY2 = ImmutableMap.of("value", DEFAULT_MEANING_1);
private static final Map<String, Object> MEANING_ENTRY3 = ImmutableMap.of("value", DEFAULT_MEANING_2);
private static final Map<String, Object> MEANING_ENTRY4 = ImmutableMap.of("value", DEFAULT_MEANING_3);
private static final Map<String, Object> VALUE_ENTRY3 = ImmutableMap.of("expression", true, "value", DEFAULT_VALUE_2);
private static final Map<String, Object> VALUE_ENTRY4 = ImmutableMap.of("expression", true, "value", DEFAULT_VALUE_2);
private static final Map<String, Object> ROW1 = ImmutableMap.of("meaning", MEANING_ENTRY1);
private static final Map<String, Object> ROW2 = ImmutableMap.of("meaning", MEANING_ENTRY2);
private static final Map<String, Object> ROW3 = ImmutableMap.of("meaning", MEANING_ENTRY3, "value", VALUE_ENTRY3);
private static final Map<String, Object> ROW4 = ImmutableMap.of("meaning", MEANING_ENTRY4, "value", VALUE_ENTRY4);
private static final List<Object> DEFAULT_TABLE_VALUES = ImmutableList.of(ROW1, ROW2, ROW3, ROW4);
04-06-2021 01:26 AM
Thanks @ptaylor, that worked perfectly.