diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-03-17 09:11:25 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-03-17 18:59:32 +0100 |
commit | 8b8b730d3ba98d6c9e4e6274844641043b5fefbb (patch) | |
tree | 4cb60dafa05b479d0ca287d501a51db88cecaaa4 /lib/configuration/cte.ml | |
parent | 7bfbb67d83011f3e1845dcb9e44c3b6a5e93a9da (diff) |
Moved the syntax module in its own library
Diffstat (limited to 'lib/configuration/cte.ml')
-rw-r--r-- | lib/configuration/cte.ml | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/lib/configuration/cte.ml b/lib/configuration/cte.ml deleted file mode 100644 index ff43d6d..0000000 --- a/lib/configuration/cte.ml +++ /dev/null @@ -1,53 +0,0 @@ -open StdLabels -module Path = ImportDataTypes.Path -module Expression = ImportExpression.T - -type t = { - filters : Path.t Expression.t list; - group : Path.t Expression.t option; -} - -(** Ensure the group criteria in window functions match the global group by - criteria. - - Traverse the configuration tree until finding a group window. *) - -(** Check if the expression contains a group function *) -let matchWindowGroup : 'a ImportExpression.T.t -> bool = - fun expression -> - let exception Found in - let open ImportExpression.T in - let rec f = function - | Empty | Literal _ | Integer _ | Path _ -> () - | Expr e -> f e - | Concat pp | Function' (_, pp) | Function (_, pp) | Nvl pp | Join (_, pp) - -> List.iter ~f pp - | Window (_, _, _) -> raise Found - | BOperator (_, arg1, arg2) -> - f arg1; - f arg2 - | GEquality (_, arg1, args) -> - f arg1; - List.iter ~f args - in - try - f expression; - false - with - | Found -> true - -(** Transform a list of expression into a list of CTE to evaluate. *) -let of_filters : Path.t Expression.t list -> t list = - fun filters -> - let last_group, prev = - List.fold_left filters - ~init:({ filters = []; group = None }, []) - ~f:(fun (cte, acc) expr -> - begin - if matchWindowGroup expr then - ( { filters = []; group = None }, - { cte with group = Some expr } :: acc ) - else ({ cte with filters = expr :: cte.filters }, acc) - end) - in - List.rev (last_group :: prev) |