common_function/scalars/
json.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15pub mod json_get;
16mod json_get_rewriter;
17mod json_is;
18mod json_path_exists;
19mod json_path_match;
20mod json_to_string;
21mod parse_json;
22
23use json_get::{JsonGetBool, JsonGetFloat, JsonGetInt, JsonGetObject, JsonGetString};
24use json_get_rewriter::JsonGetRewriter;
25use json_is::{
26    JsonIsArray, JsonIsBool, JsonIsFloat, JsonIsInt, JsonIsNull, JsonIsObject, JsonIsString,
27};
28use json_to_string::JsonToStringFunction;
29use parse_json::ParseJsonFunction;
30
31use crate::function_registry::FunctionRegistry;
32use crate::scalars::json::json_get::JsonGetWithType;
33
34pub(crate) struct JsonFunction;
35
36impl JsonFunction {
37    pub fn register(registry: &FunctionRegistry) {
38        registry.register_scalar(JsonToStringFunction::default());
39        registry.register_scalar(ParseJsonFunction::default());
40
41        registry.register_scalar(JsonGetInt::default());
42        registry.register_scalar(JsonGetFloat::default());
43        registry.register_scalar(JsonGetString::default());
44        registry.register_scalar(JsonGetBool::default());
45        registry.register_scalar(JsonGetObject::default());
46        registry.register_scalar(JsonGetWithType::default());
47
48        registry.register_scalar(JsonIsNull::default());
49        registry.register_scalar(JsonIsInt::default());
50        registry.register_scalar(JsonIsFloat::default());
51        registry.register_scalar(JsonIsString::default());
52        registry.register_scalar(JsonIsBool::default());
53        registry.register_scalar(JsonIsArray::default());
54        registry.register_scalar(JsonIsObject::default());
55
56        registry.register_scalar(json_path_exists::JsonPathExistsFunction::default());
57        registry.register_scalar(json_path_match::JsonPathMatchFunction::default());
58
59        registry.register_function_rewrite(JsonGetRewriter);
60    }
61}