Compare commits
3 Commits
656554048a
...
93970e6ddc
Author | SHA1 | Date | |
---|---|---|---|
93970e6ddc | |||
5ee4c6f2c2 | |||
d09897cd52 |
@ -1,5 +1,4 @@
|
||||
type query =
|
||||
(*| Select of column list * table list option * filter option*)
|
||||
| Select of column list * table_expression
|
||||
| CreateSchema of string
|
||||
| CreateTable of table_scope option * table
|
||||
@ -163,8 +162,8 @@ and pp_predicate pred =
|
||||
| Comparison(op, exp) -> pp_operator op ^ pp_expression exp
|
||||
| Between(exp1, exp2) -> "BETWEEN " ^ pp_expression exp1 ^ " AND " ^pp_expression exp2
|
||||
| NotBetween(exp1, exp2) -> "NOT BETWEEN " ^ pp_expression exp1 ^ " AND " ^pp_expression exp2
|
||||
(*| Like(exp) -> "LIKE " ^ pp_expression exp
|
||||
| NotLike(exp) -> " NOT LIKE " ^ pp_expression exp*)
|
||||
| Like(exp) -> "LIKE " ^ pp_expression exp
|
||||
(*| NotLike(exp) -> " NOT LIKE " ^ pp_expression exp*)
|
||||
| _ -> failwith "Predicate not supported"
|
||||
|
||||
and pp_operator op =
|
||||
|
@ -1,5 +1,5 @@
|
||||
type logical_plan =
|
||||
| Project of logical_plan * string list
|
||||
| Project of logical_plan option * string list
|
||||
| Scan of string (* Table name *)
|
||||
| Filter of logical_plan
|
||||
| Join of logical_plan * Ast.join_type * logical_plan
|
||||
@ -7,9 +7,14 @@ type logical_plan =
|
||||
|
||||
let rec ast_to_logical ast =
|
||||
match ast with
|
||||
| Ast.Select(cols, _) -> Project(Scan("table"), (columns_to_logical cols))
|
||||
| Ast.Select(cols, table_exp) -> Project((table_expression_to_logical table_exp), (columns_to_logical cols))
|
||||
| _ -> failwith "Query not supported yet"
|
||||
|
||||
and table_expression_to_logical table_exp =
|
||||
match table_exp with
|
||||
| Ast.TableExpression(Some(tables), None, None) -> tables_to_logical tables
|
||||
| _ -> failwith "Table expression not supported yet"
|
||||
|
||||
and columns_to_logical columns =
|
||||
let rec aux cols acc =
|
||||
match cols with
|
||||
@ -26,9 +31,19 @@ and expression_to_logical exp =
|
||||
| Ast.Ref(s) -> s
|
||||
| _ -> failwith "Expression not supported yet"
|
||||
|
||||
and tables_to_logical tables =
|
||||
let rec aux t =
|
||||
match t with
|
||||
| [] -> None
|
||||
| [Ast.Table(table_name)] -> Some(Scan(table_name))
|
||||
| _ -> failwith "tables not supported"
|
||||
in
|
||||
match tables with
|
||||
| None -> None
|
||||
| Some(t) -> aux t
|
||||
|
||||
|
||||
let rec pp_logical_plan plan =
|
||||
match plan with
|
||||
| Project(plan2, name) -> pp_logical_plan plan2 ^ (String.concat ";" name)
|
||||
| _ -> "Not supported"
|
||||
|
||||
|
@ -57,8 +57,8 @@ greater_than_or_equals_operator:
|
||||
|
||||
(* 5.3 LITERAL *)
|
||||
literal :
|
||||
| signed_numeric_literal { $1 }
|
||||
| general_literal { $1 }
|
||||
(* | signed_numeric_literal { $1 }*)
|
||||
|
||||
unsigned_literal:
|
||||
| unsigned_numeric_literal { $1 }
|
||||
@ -71,10 +71,11 @@ general_literal:
|
||||
character_string_literal:
|
||||
| QUOTE IDENT QUOTE { StringLiteral($2) }
|
||||
|
||||
|
||||
(*
|
||||
signed_numeric_literal:
|
||||
| sign unsigned_numeric_literal { Signed($1,$2) }
|
||||
| unsigned_numeric_literal { $1 }
|
||||
*)
|
||||
|
||||
unsigned_numeric_literal :
|
||||
| exact_numeric_literal { $1 }
|
||||
|
Loading…
Reference in New Issue
Block a user