@Override
  public GenericRow transform(GenericRow record) {
    try {
      GenericRow originalRow = _fieldsToUnnest.isEmpty() ? null : record.copy(_fieldsToUnnest);
      flattenMap(record, new ArrayList<>(record.getFieldToValueMap().keySet()));
      for (String field : _fieldsToUnnest) {
        unnestCollection(record, field);
      }
      Object unnestedRows = record.getValue(GenericRow.MULTIPLE_RECORDS_KEY);
      if (originalRow != null && unnestedRows instanceof Collection) {
        for (GenericRow unnestedRow : (Collection<GenericRow>) unnestedRows) {
          for (String field : _fieldsToUnnest) {
            unnestedRow.putValue(field, originalRow.getValue(field));
          }
        }
      }

      renamePrefixes(record);
    } catch (Exception e) {
      if (!_continueOnError) {
        throw new RuntimeException("Caught exception while transforming complex types", e);
      } else {
        LOGGER.debug("Caught exception while transforming complex types for record: {}", record.toString(), e);
        record.putValue(GenericRow.INCOMPLETE_RECORD_KEY, true);
      }
    }
    return record;
  }
@Test
  public void testPrefixesToRename() {
    HashMap<String, String> prefixesToRename = new HashMap<>();
    prefixesToRename.put("map1.", "");
    prefixesToRename.put("map2", "test");
    ComplexTypeTransformer transformer = new ComplexTypeTransformer(new ArrayList<>(), ".",
        DEFAULT_COLLECTION_TO_JSON_MODE, prefixesToRename, null);

    // test flatten root-level tuples
    GenericRow genericRow = new GenericRow();
    genericRow.putValue("a", 1L);
    Map<String, Object> map1 = new HashMap<>();
    genericRow.putValue("map1", map1);
    map1.put("b", "v");
    Map<String, Object> innerMap1 = new HashMap<>();
    innerMap1.put("aa", 2);
    innerMap1.put("bb", "u");
    map1.put("im1", innerMap1);
    Map<String, Object> map2 = new HashMap<>();
    map2.put("c", 3);
    genericRow.putValue("map2", map2);

    transformer.transform(genericRow);
    Assert.assertEquals(genericRow.getValue("a"), 1L);
    Assert.assertEquals(genericRow.getValue("b"), "v");
    Assert.assertEquals(genericRow.getValue("im1.aa"), 2);
    Assert.assertEquals(genericRow.getValue("im1.bb"), "u");
    Assert.assertEquals(genericRow.getValue("test.c"), 3);
  }