(
&self,
function: SQLFunction,
schema: &DFSchema,
planner_context: &mut PlannerContext,
)
| 228 | |
| 229 | impl<S: ContextProvider> SqlToRel<'_, S> { |
| 230 | pub(super) fn sql_function_to_expr( |
| 231 | &self, |
| 232 | function: SQLFunction, |
| 233 | schema: &DFSchema, |
| 234 | planner_context: &mut PlannerContext, |
| 235 | ) -> Result<Expr> { |
| 236 | let function_args = FunctionArgs::try_new(function)?; |
| 237 | let FunctionArgs { |
| 238 | name: object_name, |
| 239 | args, |
| 240 | order_by, |
| 241 | over, |
| 242 | filter, |
| 243 | null_treatment, |
| 244 | distinct, |
| 245 | within_group, |
| 246 | function_without_parentheses, |
| 247 | } = function_args; |
| 248 | |
| 249 | if over.is_some() && !within_group.is_empty() { |
| 250 | return plan_err!( |
| 251 | "OVER and WITHIN GROUP clause cannot be used together. \ |
| 252 | OVER is for window functions, whereas WITHIN GROUP is for ordered set aggregate functions" |
| 253 | ); |
| 254 | } |
| 255 | |
| 256 | if !order_by.is_empty() && !within_group.is_empty() { |
| 257 | return plan_err!( |
| 258 | "ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function" |
| 259 | ); |
| 260 | } |
| 261 | |
| 262 | // If function is a window function (it has an OVER clause), |
| 263 | // it shouldn't have ordering requirement as function argument |
| 264 | // required ordering should be defined in OVER clause. |
| 265 | let is_function_window = over.is_some(); |
| 266 | let sql_parser_span = object_name.0[0].span(); |
| 267 | let name = if object_name.0.len() > 1 { |
| 268 | // DF doesn't handle compound identifiers |
| 269 | // (e.g. "foo.bar") for function names yet |
| 270 | object_name.to_string() |
| 271 | } else { |
| 272 | match object_name.0[0].as_ident() { |
| 273 | Some(ident) => crate::utils::normalize_ident(ident.clone()), |
| 274 | None => { |
| 275 | return plan_err!( |
| 276 | "Expected an identifier in function name, but found {:?}", |
| 277 | object_name.0[0] |
| 278 | ); |
| 279 | } |
| 280 | } |
| 281 | }; |
| 282 | |
| 283 | // handle make_map and map functions |
| 284 | // make_map always uses plan_make_map: make_map(k1, v1, k2, v2, ...) |
| 285 | // map has 2 syntaxes: |
| 286 | // 1. map([keys], [values]) - two arrays that get zipped |
| 287 | // 2. map(k1, v1, k2, v2, ...) - variadic pairs (uses plan_make_map) |
no test coverage detected