simplifying
This commit is contained in:
parent
df350c7730
commit
5a048a62ac
@ -1,31 +1,17 @@
|
|||||||
type logical_plan =
|
type logical_plan =
|
||||||
|
| Project of logical_plan * string
|
||||||
| Scan of string (* Table name *)
|
| Scan of string (* Table name *)
|
||||||
| Filter of logical_plan * condition
|
| Filter of logical_plan
|
||||||
| Join of logical_plan * Ast.join_type * logical_plan
|
| Join of logical_plan * Ast.join_type * logical_plan
|
||||||
and condition =
|
| Group of logical_plan * string list
|
||||||
| Condition of string
|
|
||||||
|
|
||||||
let rec generate_from_clause tables =
|
let ast_to_logical ast =
|
||||||
match tables with
|
|
||||||
| [Ast.Table(name)] -> Scan(name)
|
|
||||||
| [Ast.Join(left, j_type, right, _)] ->
|
|
||||||
Join(
|
|
||||||
generate_from_clause [left],
|
|
||||||
j_type,
|
|
||||||
generate_from_clause [right]
|
|
||||||
)
|
|
||||||
| _ -> failwith "Unsupported table structure"
|
|
||||||
|
|
||||||
|
|
||||||
let generate_logical_plan ast =
|
|
||||||
match ast with
|
match ast with
|
||||||
| Ast.Query(Select(_, Some(tables), _)) ->
|
| Ast.Select(_, _) -> Project(Scan("table"), "ok")
|
||||||
let base_plan = generate_from_clause tables in
|
| _ -> failwith "Query not supported yet"
|
||||||
base_plan
|
|
||||||
| Ast.Query(Select(_, None, _)) -> failwith "not supported"
|
|
||||||
|
|
||||||
(*let evaluate_plan plan =
|
let rec pp_logical_plan plan =
|
||||||
match plan with
|
match plan with
|
||||||
| Scan(table) ->
|
| Project(plan2, name) -> pp_logical_plan plan2 ^ name
|
||||||
| _ -> failwith "Unsupported plan"
|
| _ -> "Not supported"
|
||||||
*)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user