MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / register_builtin_functions

Method register_builtin_functions

graphlite/src/ast/validator.rs:155–625  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

153 }
154
155 fn register_builtin_functions(&mut self) {
156 use crate::ast::TypeSpec as GqlType;
157
158 // Temporal functions
159 self.function_signatures.insert(
160 "DATETIME".to_string(),
161 FunctionSignature {
162 argument_types: vec![GqlType::String { max_length: None }],
163 return_type: GqlType::ZonedDateTime { precision: None },
164 variadic: false,
165 },
166 );
167
168 self.function_signatures.insert(
169 "NOW".to_string(),
170 FunctionSignature {
171 argument_types: vec![],
172 return_type: GqlType::ZonedDateTime { precision: None },
173 variadic: false,
174 },
175 );
176
177 // DURATION function has two variants:
178 // 1. DURATION(string) - ISO duration string
179 // 2. DURATION(number, string) - number and temporal unit
180 // We'll use the first variant as the primary signature
181 self.function_signatures.insert(
182 "DURATION".to_string(),
183 FunctionSignature {
184 argument_types: vec![GqlType::String { max_length: None }],
185 return_type: GqlType::Duration { precision: None },
186 variadic: false,
187 },
188 );
189
190 // Alternative signature for DURATION(number, unit)
191 self.function_signatures.insert(
192 "DURATION_NUMERIC".to_string(),
193 FunctionSignature {
194 argument_types: vec![GqlType::Double, GqlType::String { max_length: None }],
195 return_type: GqlType::Duration { precision: None },
196 variadic: false,
197 },
198 );
199
200 self.function_signatures.insert(
201 "TIME_WINDOW".to_string(),
202 FunctionSignature {
203 argument_types: vec![
204 GqlType::ZonedDateTime { precision: None },
205 GqlType::ZonedDateTime { precision: None },
206 ],
207 return_type: GqlType::Duration { precision: None }, // Time windows are duration-based
208 variadic: false,
209 },
210 );
211
212 // Aggregation functions (support both lowercase and uppercase)

Callers 1

newMethod · 0.45

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected