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
15use std::sync::Arc;
16pub mod json_get;
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, JsonGetString};
24use json_is::{
25    JsonIsArray, JsonIsBool, JsonIsFloat, JsonIsInt, JsonIsNull, JsonIsObject, JsonIsString,
26};
27use json_to_string::JsonToStringFunction;
28use parse_json::ParseJsonFunction;
29
30use crate::function_registry::FunctionRegistry;
31
32pub(crate) struct JsonFunction;
33
34impl JsonFunction {
35    pub fn register(registry: &FunctionRegistry) {
36        registry.register(Arc::new(JsonToStringFunction));
37        registry.register(Arc::new(ParseJsonFunction));
38
39        registry.register(Arc::new(JsonGetInt));
40        registry.register(Arc::new(JsonGetFloat));
41        registry.register(Arc::new(JsonGetString));
42        registry.register(Arc::new(JsonGetBool));
43
44        registry.register(Arc::new(JsonIsNull));
45        registry.register(Arc::new(JsonIsInt));
46        registry.register(Arc::new(JsonIsFloat));
47        registry.register(Arc::new(JsonIsString));
48        registry.register(Arc::new(JsonIsBool));
49        registry.register(Arc::new(JsonIsArray));
50        registry.register(Arc::new(JsonIsObject));
51
52        registry.register(Arc::new(json_path_exists::JsonPathExistsFunction));
53        registry.register(Arc::new(json_path_match::JsonPathMatchFunction));
54    }
55}