cancel
Showing results for 
Search instead for 
Did you mean: 

Add more default rows to SnapType.TABLE

j_angelevski
Contributor III

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.

image
I’ve searched the documentation but I didn’t find anything about this particular problem.

1 ACCEPTED SOLUTION

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

View solution in original post

4 REPLIES 4

j_angelevski
Contributor III

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

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

j_angelevski
Contributor III

Thanks @ptaylor, that worked perfectly.