Add more default rows to SnapType.TABLE

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.
image
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.

2 Likes

@ptaylor any suggestions ?

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.

1 Like

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);
2 Likes

Thanks @ptaylor, that worked perfectly.