stevenzwu commented on code in PR #16586:
URL: https://github.com/apache/iceberg/pull/16586#discussion_r3318823965
##########
core/src/main/java/org/apache/iceberg/util/JsonUtil.java:
##########
@@ -272,11 +272,18 @@ public static String[] getStringArray(JsonNode node) {
ArrayNode arrayNode = (ArrayNode) node;
String[] arr = new String[arrayNode.size()];
for (int i = 0; i < arr.length; i++) {
- arr[i] = arrayNode.get(i).asText();
+ JsonNode element = arrayNode.get(i);
+ Preconditions.checkArgument(
+ element.isTextual(), "Cannot parse string from non-text value: %s",
element);
+ arr[i] = element.asText();
}
return arr;
}
+ public static String[] getStringArray(String property, JsonNode node) {
+ return getStringList(property, node).toArray(new String[0]);
Review Comment:
`toArray` is the same pattern as the existing code
```
public static int[] getIntArrayOrNull(String property, JsonNode node) {
if (!node.has(property) || node.get(property).isNull()) {
return null;
}
return ArrayUtil.toIntArray(getIntegerList(property, node));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]