Skip to content

Commit 3cb0673

Browse files
committed
feat: add simple extension for JSON
1 parent 23913f5 commit 3cb0673

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

extensions/json.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
%YAML 1.2
2+
---
3+
urn: extension:io.substrait:json
4+
types:
5+
- name: json
6+
description: >-
7+
A JSON type representing arbitrary JSON values (objects, arrays,
8+
strings, numbers, booleans, or null).
9+
10+
scalar_functions:
11+
- name: "parse_json"
12+
description: >-
13+
Parse a JSON string into a JSON value.
14+
impls:
15+
- args:
16+
- name: json_string
17+
value: string
18+
options:
19+
on_error:
20+
description: Controls behavior when input is not valid JSON
21+
values: [ ERROR, "NULL" ]
22+
return: u!json?
23+
24+
- name: "to_string"
25+
description: "Convert a JSON value to its string representation"
26+
impls:
27+
- args:
28+
- name: json_value
29+
value: u!json
30+
return: string
31+
32+
- name: "json_extract"
33+
description: >-
34+
Extract a value from JSON using a JSONPath expression.
35+
JSONPath expressions should follow RFC 9535 (https://datatracker.ietf.org/doc/html/rfc9535).
36+
impls:
37+
- args:
38+
- name: json_value
39+
value: u!json
40+
- name: path
41+
value: string
42+
options:
43+
on_invalid_path:
44+
description: Controls behavior when the JSONPath expression is syntactically invalid
45+
values: [ ERROR, "NULL", UNDEFINED ]
46+
on_path_not_found:
47+
description: Controls behavior when the path does not exist in the JSON document
48+
values: [ ERROR, "NULL" ]
49+
return: u!json?
50+
51+
- name: "is_json_valid"
52+
description: >-
53+
Returns true if the input string is valid JSON, false otherwise.
54+
This function does not parse the JSON, only validates syntax.
55+
impls:
56+
- args:
57+
- name: json_string
58+
value: string
59+
return: boolean

0 commit comments

Comments
 (0)