Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-918949: Add row index information to all exceptions #590

Merged
merged 45 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
eeb56c0
fix issue
sfc-gh-tzhang Dec 7, 2022
911c63f
encryption
sfc-gh-tzhang Feb 17, 2023
b0a33d9
fix format
sfc-gh-tzhang Feb 17, 2023
ff14184
add tests
sfc-gh-tzhang Feb 22, 2023
55fdb59
update
sfc-gh-tzhang Feb 22, 2023
b202a17
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Mar 10, 2023
47dabfc
Merge branch 'master' into tzhang-si-encryption
sfc-gh-tzhang Mar 28, 2023
b9e8d33
Merge branch 'tzhang-si-encryption' into tzhang-si-fixes
sfc-gh-tzhang Mar 28, 2023
c1e6dae
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Apr 6, 2023
94d2d05
perf fixes
sfc-gh-tzhang Apr 6, 2023
e8da46b
update example
sfc-gh-tzhang Apr 6, 2023
fdedb23
remove utf8
sfc-gh-tzhang Apr 7, 2023
1190275
Revert "remove utf8"
sfc-gh-tzhang Apr 7, 2023
96db639
fix
sfc-gh-tzhang Apr 7, 2023
bc0db14
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Apr 7, 2023
e4ef922
fix tests
sfc-gh-tzhang Apr 8, 2023
d267165
Merge branch 'tzhang-si-fixes' of github.com:snowflakedb/snowflake-in…
sfc-gh-tzhang Apr 8, 2023
2160a36
fix tests
sfc-gh-tzhang Apr 8, 2023
4146bfb
use dynamic scaling thread pool
sfc-gh-tzhang Apr 11, 2023
528af31
merge master
sfc-gh-tzhang Apr 11, 2023
0344b70
file format
sfc-gh-tzhang Apr 11, 2023
6abd0d2
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang May 15, 2023
65e16f4
fix
sfc-gh-tzhang May 17, 2023
025958c
update max chunk size
sfc-gh-tzhang May 17, 2023
e43c354
fix schema issue
sfc-gh-tzhang May 18, 2023
4847388
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang May 18, 2023
e016947
fix
sfc-gh-tzhang May 18, 2023
12f9eb2
address comment
sfc-gh-tzhang May 18, 2023
699bb41
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Jun 2, 2023
ab0620f
save progress
sfc-gh-tzhang Jun 4, 2023
eaa729a
add tests
sfc-gh-tzhang Jun 5, 2023
d5abc25
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Jun 5, 2023
f17ba1b
fix tests
sfc-gh-tzhang Jun 6, 2023
114a4d3
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Jun 7, 2023
e925d83
address comments
sfc-gh-tzhang Jun 7, 2023
efec4e9
fix naming
sfc-gh-tzhang Jun 8, 2023
d334b76
merge master
sfc-gh-tzhang Jul 12, 2023
65b75b1
fix
sfc-gh-tzhang Jul 12, 2023
e96688c
fix
sfc-gh-tzhang Jul 12, 2023
4401ed9
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Sep 20, 2023
efa8e4e
add row index
sfc-gh-tzhang Sep 20, 2023
aea5519
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Sep 22, 2023
22fe148
update message
sfc-gh-tzhang Sep 27, 2023
f0dd91d
remove star import
sfc-gh-tzhang Sep 27, 2023
b7f23d7
Merge branch 'master' into tzhang-si-fixes
sfc-gh-tzhang Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Set<String> verifyInputColumns(
throw new SFException(
ErrorCode.INVALID_FORMAT_ROW,
"Extra columns: " + extraCols,
"Columns not present in the table shouldn't be specified.");
"Columns not present in the table shouldn't be specified. Row Index:%d");
}

// Check for missing columns in the row
Expand All @@ -278,7 +278,7 @@ Set<String> verifyInputColumns(
throw new SFException(
ErrorCode.INVALID_FORMAT_ROW,
"Missing columns: " + missingCols,
"Values for all non-nullable columns must be specified.");
"Values for all non-nullable columns must be specified. Row Index:%d");
}

return inputColNamesMap.keySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,10 @@ static TimestampWrapper validateAndParseTimestamp(
if (offsetDateTime.getYear() < 1 || offsetDateTime.getYear() > 9999) {
throw new SFException(
ErrorCode.INVALID_VALUE_ROW,
"Timestamp out of representable inclusive range of years between 1 and 9999");
String.format(
"Timestamp out of representable inclusive range of years between 1 and 9999, Row"
+ " Index:%d",
insertRowIndex));
}
return new TimestampWrapper(offsetDateTime, scale);
}
Expand Down Expand Up @@ -588,7 +591,10 @@ static int validateAndParseDate(String columnName, Object input, long insertRowI
if (offsetDateTime.getYear() < -9999 || offsetDateTime.getYear() > 9999) {
throw new SFException(
ErrorCode.INVALID_VALUE_ROW,
"Date out of representable inclusive range of years between -9999 and 9999");
String.format(
"Date out of representable inclusive range of years between -9999 and 9999, Row"
+ " Index:%d",
insertRowIndex));
}

return Math.toIntExact(offsetDateTime.toLocalDate().toEpochDay());
Expand Down Expand Up @@ -814,7 +820,7 @@ static void checkValueInRange(
throw new SFException(
ErrorCode.INVALID_FORMAT_ROW,
String.format(
"Number out of representable exclusive range of (-1e%s..1e%s), Row Index:%s",
"Number out of representable exclusive range of (-1e%s..1e%s), Row Index:%d",
precision - scale, precision - scale, insertRowIndex));
}
}
Expand Down Expand Up @@ -859,7 +865,7 @@ private static SFException typeNotAllowedException(
ErrorCode.INVALID_FORMAT_ROW,
String.format(
"Object of type %s cannot be ingested into Snowflake column %s of type %s, Row"
+ " Index:%s",
+ " Index:%d",
javaType.getName(), columnName, snowflakeType, insertRowIndex),
String.format(
String.format("Allowed Java types: %s", String.join(", ", allowedJavaTypes))));
Expand All @@ -882,7 +888,7 @@ private static SFException valueFormatNotAllowedException(
return new SFException(
ErrorCode.INVALID_VALUE_ROW,
String.format(
"Value cannot be ingested into Snowflake column %s of type %s, Row Index: %s, reason:"
"Value cannot be ingested into Snowflake column %s of type %s, Row Index:%d, reason:"
+ " %s",
columnName, snowflakeType, rowIndex, reason));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private float addRow(
throw new SFException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, is it worth having a list of longs that we store in a SFException that can be accessed via something like getRowIndexes? This will reduce the need to parse an error message which is error prone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already doing that with CONTINUE, this is for ABORT where we thrown an exception directly

ErrorCode.MAX_ROW_SIZE_EXCEEDED,
String.format(
"rowSizeInBytes=%.3f maxAllowedRowSizeInBytes=%d",
size, clientBufferParameters.getMaxAllowedRowSizeInBytes()));
"rowSizeInBytes=%.3f, maxAllowedRowSizeInBytes=%d, Row Index=%d",
size, clientBufferParameters.getMaxAllowedRowSizeInBytes(), insertRowsCurrIndex));
}

out.accept(Arrays.asList(indexedRow));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,19 +676,19 @@ public void testTooLargeMultiByteSemiStructuredValues() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type VARIANT, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type VARIANT, Row Index:0, reason:"
+ " Variant too long: length=18874376 maxLength=16777152",
() -> validateAndParseVariant("COL", m, 0));
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type ARRAY, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type ARRAY, Row Index:0, reason:"
+ " Array too large. length=18874378 maxLength=16777152",
() -> validateAndParseArray("COL", m, 0));
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type OBJECT, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type OBJECT, Row Index:0, reason:"
+ " Object too large. length=18874376 maxLength=16777152",
() -> validateAndParseObject("COL", m, 0));
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type BOOLEAN, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type BOOLEAN, Row Index:0, reason:"
+ " Not a valid boolean, see"
+ " https://docs.snowflake.com/en/sql-reference/data-types-logical.html#conversion-to-boolean"
+ " for the list of supported formats",
Expand All @@ -1027,7 +1027,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type TIME, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type TIME, Row Index:0, reason:"
+ " Not a valid time, see"
+ " https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview for"
+ " the list of supported formats",
Expand All @@ -1043,7 +1043,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type DATE, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type DATE, Row Index:0, reason:"
+ " Not a valid value, see"
+ " https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview for"
+ " the list of supported formats",
Expand All @@ -1060,7 +1060,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index: 0,"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index:0,"
+ " reason: Not a valid value, see"
+ " https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview for"
+ " the list of supported formats",
Expand All @@ -1077,7 +1077,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index: 0,"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index:0,"
+ " reason: Not a valid value, see"
+ " https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview for"
+ " the list of supported formats",
Expand All @@ -1094,7 +1094,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index: 0,"
+ " cannot be ingested into Snowflake column COL of type TIMESTAMP, Row Index:0,"
+ " reason: Not a valid value, see"
+ " https://docs.snowflake.com/en/user-guide/data-load-snowpipe-streaming-overview for"
+ " the list of supported formats",
Expand All @@ -1110,7 +1110,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type NUMBER, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type NUMBER, Row Index:0, reason:"
+ " Not a valid number",
() -> validateAndParseBigDecimal("COL", "abc", 0));

Expand All @@ -1124,7 +1124,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type REAL, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type REAL, Row Index:0, reason:"
+ " Not a valid decimal number",
() -> validateAndParseReal("COL", "abc", 0));

Expand All @@ -1138,7 +1138,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type STRING, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type STRING, Row Index:0, reason:"
+ " String too long: length=3 characters maxLength=2 characters",
() -> validateAndParseString("COL", "abc", Optional.of(2), 0));

Expand All @@ -1152,13 +1152,13 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type BINARY, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type BINARY, Row Index:0, reason:"
+ " Binary too long: length=2 maxLength=1",
() -> validateAndParseBinary("COL", new byte[] {1, 2}, Optional.of(1), 0));
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type BINARY, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type BINARY, Row Index:0, reason:"
+ " Not a valid hex string",
() -> validateAndParseBinary("COL", "ghi", Optional.empty(), 0));

Expand All @@ -1173,7 +1173,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type VARIANT, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type VARIANT, Row Index:0, reason:"
+ " Not a valid JSON",
() -> validateAndParseVariant("COL", "][", 0));

Expand All @@ -1188,7 +1188,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type ARRAY, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type ARRAY, Row Index:0, reason:"
+ " Not a valid JSON",
() -> validateAndParseArray("COL", "][", 0));

Expand All @@ -1203,7 +1203,7 @@ public void testExceptionMessages() {
expectErrorCodeAndMessage(
ErrorCode.INVALID_VALUE_ROW,
"The given row cannot be converted to the internal format due to invalid value: Value"
+ " cannot be ingested into Snowflake column COL of type OBJECT, Row Index: 0, reason:"
+ " cannot be ingested into Snowflake column COL of type OBJECT, Row Index:0, reason:"
+ " Not a valid JSON",
() -> validateAndParseObject("COL", "}{", 0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void testRowIndexWithMultipleRowsWithError() {
.equalsIgnoreCase(
"The given row cannot be converted to the internal format due to invalid value:"
+ " Value cannot be ingested into Snowflake column COLCHAR of type STRING, Row"
+ " Index: 1, reason: String too long: length=22 characters maxLength=11"
+ " Index:1, reason: String too long: length=22 characters maxLength=11"
+ " characters"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ public void testInsertTooLargeRow() {
.collect(Collectors.toList());

String expectedMessage =
"The given row exceeds the maximum allowed row size rowSizeInBytes=67109128.000"
+ " maxAllowedRowSizeInBytes=67108864";
"The given row exceeds the maximum allowed row size rowSizeInBytes=67109128.000,"
+ " maxAllowedRowSizeInBytes=67108864, Row Index=0";

Map<String, Object> row = new HashMap<>();
schema.forEach(x -> row.put(x.getName(), byteArrayOneMb));
Expand Down