Skip to content

Commit

Permalink
add more tests and error log
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ggeng committed Jan 15, 2025
1 parent 8eed776 commit ab63dfa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ private static String validateAndParseSemiStructured(
throw valueFormatNotAllowedException(
columnName, snowflakeType, "Not a valid JSON: duplicate field", insertRowIndex);
}
throw new SFException(e, ErrorCode.IO_ERROR, "Cannot create JSON Parser or JSON generator");
throw new SFException(
e,
ErrorCode.IO_ERROR,
String.format(
"Cannot create JSON Parser or JSON generator for column %s of type %s, rowIndex:%d",
columnName, snowflakeType, insertRowIndex));
}
// We return the minified string from the result writer
return resultWriter.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,9 @@ public void testValidateDuplicateKeys() {
expectError(
ErrorCode.INVALID_VALUE_ROW,
() -> validateAndParseObjectNew("COL", "{\"key\":1, \"key\":2}", 0));

expectError(
ErrorCode.INVALID_VALUE_ROW,
() -> validateAndParseObjectNew("COL", "{\"key\":1, \"key\":2}".getBytes(), 0));
() -> validateAndParseVariantNew("COL", "{\"key\":1, \"key\":2}", 0));

// nested JSON object with duplicate keys can not be ingested
expectError(
Expand All @@ -875,8 +874,15 @@ public void testValidateDuplicateKeys() {
expectError(
ErrorCode.INVALID_VALUE_ROW,
() ->
validateAndParseObjectNew(
"COL", "{\"key\":1, \"nested\":{\"key\":2, \"key\":3}}".getBytes(), 0));
validateAndParseVariantNew("COL", "{\"key\":1, \"nested\":{\"key\":2, \"key\":3}}", 0));

// array of objects with duplicate keys can not be ingested
expectError(
ErrorCode.INVALID_VALUE_ROW,
() -> validateAndParseArrayNew("COL", "[{\"key\":1, \"key\":2}]", 0));
expectError(
ErrorCode.INVALID_VALUE_ROW,
() -> validateAndParseVariantNew("COL", "[{\"key\":1, \"key\":2}]", 0));
}

@Test
Expand Down

0 comments on commit ab63dfa

Please sign in to comment.