zhztheplayer commented on a change in pull request #1070: [CALCITE-2808]Add the
JSON_LENGTH function
URL: https://github.com/apache/calcite/pull/1070#discussion_r261668726
##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -2755,6 +2755,31 @@ private static Integer getJsonDepth(Object o) {
return depth;
}
+ public static Integer jsonLength(Object input) {
+ final PathContext context = (PathContext) input;
+ final Integer result;
+ try {
+ Object value = context.pathReturned;
Review comment:
`context` may carries an error (typically when user passes a "strict"
jsonpath expression). Let's add a fail-fast condition to exclude that.
E.g.
```java
if (context.exc != null) {
throw toUnchecked(context.exc);
}
try {
...
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services