qlong commented on code in PR #15384:
URL: https://github.com/apache/iceberg/pull/15384#discussion_r3030784312
##########
api/src/main/java/org/apache/iceberg/expressions/PathUtil.java:
##########
@@ -83,6 +84,26 @@ public static String toNormalizedPath(Iterable<String>
fields) {
.collect(Collectors.joining(""));
}
+ /**
+ * Converts a normalized path (e.g. $['a']['b']) to dot notation (e.g.
$.a.b). Used when unbinding
+ * BoundExtract so the result can be passed to Expressions.extract().
+ */
+ static String toDotNotation(String normalizedPath) {
+ Preconditions.checkArgument(
+ normalizedPath != null && normalizedPath.startsWith(ROOT),
+ "Invalid normalized path: %s",
+ normalizedPath);
+ List<String> fields = Lists.newArrayList();
+ Matcher matcher =
Pattern.compile("\\['([^']*)'\\]").matcher(normalizedPath);
+ while (matcher.find()) {
+ fields.add(matcher.group(1));
+ }
+ if (fields.isEmpty()) {
+ return ROOT;
+ }
+ return ROOT + "." + String.join(".", fields);
Review Comment:
added support of bracket style path, so we can support $['user.name']. Got
rid of toDotNotation completely as suggested .
##########
api/src/main/java/org/apache/iceberg/expressions/PathUtil.java:
##########
@@ -83,6 +84,26 @@ public static String toNormalizedPath(Iterable<String>
fields) {
.collect(Collectors.joining(""));
}
+ /**
+ * Converts a normalized path (e.g. $['a']['b']) to dot notation (e.g.
$.a.b). Used when unbinding
+ * BoundExtract so the result can be passed to Expressions.extract().
+ */
+ static String toDotNotation(String normalizedPath) {
+ Preconditions.checkArgument(
+ normalizedPath != null && normalizedPath.startsWith(ROOT),
+ "Invalid normalized path: %s",
+ normalizedPath);
+ List<String> fields = Lists.newArrayList();
+ Matcher matcher =
Pattern.compile("\\['([^']*)'\\]").matcher(normalizedPath);
Review Comment:
done.
--
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]