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