Skip to content

Commit b6e2d25

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

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

extensions/json.yaml

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

0 commit comments

Comments
 (0)