Skip to content

Commit 6c6a85e

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

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

extensions/json.yaml

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

0 commit comments

Comments
 (0)