Compare commits

..

No commits in common. "93970e6ddc944a5d3c93436cf9961e0b4d9a823d" and "656554048ade4a5f74af2f97811696c2d1c69ab2" have entirely different histories.

3 changed files with 8 additions and 23 deletions

View File

@ -1,4 +1,5 @@
type query = type query =
(*| Select of column list * table list option * filter option*)
| Select of column list * table_expression | Select of column list * table_expression
| CreateSchema of string | CreateSchema of string
| CreateTable of table_scope option * table | CreateTable of table_scope option * table
@ -162,8 +163,8 @@ and pp_predicate pred =
| Comparison(op, exp) -> pp_operator op ^ pp_expression exp | Comparison(op, exp) -> pp_operator op ^ pp_expression exp
| Between(exp1, exp2) -> "BETWEEN " ^ pp_expression exp1 ^ " AND " ^pp_expression exp2 | Between(exp1, exp2) -> "BETWEEN " ^ pp_expression exp1 ^ " AND " ^pp_expression exp2
| NotBetween(exp1, exp2) -> "NOT 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 (*| Like(exp) -> "LIKE " ^ pp_expression exp
(*| NotLike(exp) -> " NOT LIKE " ^ pp_expression exp*) | NotLike(exp) -> " NOT LIKE " ^ pp_expression exp*)
| _ -> failwith "Predicate not supported" | _ -> failwith "Predicate not supported"
and pp_operator op = and pp_operator op =

View File

@ -1,5 +1,5 @@
type logical_plan = type logical_plan =
| Project of logical_plan option * string list | Project of logical_plan * string list
| Scan of string (* Table name *) | Scan of string (* Table name *)
| Filter of logical_plan | Filter of logical_plan
| Join of logical_plan * Ast.join_type * logical_plan | Join of logical_plan * Ast.join_type * logical_plan
@ -7,14 +7,9 @@ type logical_plan =
let rec ast_to_logical ast = let rec ast_to_logical ast =
match ast with match ast with
| Ast.Select(cols, table_exp) -> Project((table_expression_to_logical table_exp), (columns_to_logical cols)) | Ast.Select(cols, _) -> Project(Scan("table"), (columns_to_logical cols))
| _ -> failwith "Query not supported yet" | _ -> 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 = and columns_to_logical columns =
let rec aux cols acc = let rec aux cols acc =
match cols with match cols with
@ -31,19 +26,9 @@ and expression_to_logical exp =
| Ast.Ref(s) -> s | Ast.Ref(s) -> s
| _ -> failwith "Expression not supported yet" | _ -> 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 = let rec pp_logical_plan plan =
match plan with match plan with
| Project(plan2, name) -> pp_logical_plan plan2 ^ (String.concat ";" name) | Project(plan2, name) -> pp_logical_plan plan2 ^ (String.concat ";" name)
| _ -> "Not supported" | _ -> "Not supported"

View File

@ -57,8 +57,8 @@ greater_than_or_equals_operator:
(* 5.3 LITERAL *) (* 5.3 LITERAL *)
literal : literal :
| signed_numeric_literal { $1 }
| general_literal { $1 } | general_literal { $1 }
(* | signed_numeric_literal { $1 }*)
unsigned_literal: unsigned_literal:
| unsigned_numeric_literal { $1 } | unsigned_numeric_literal { $1 }
@ -71,11 +71,10 @@ general_literal:
character_string_literal: character_string_literal:
| QUOTE IDENT QUOTE { StringLiteral($2) } | QUOTE IDENT QUOTE { StringLiteral($2) }
(*
signed_numeric_literal: signed_numeric_literal:
| sign unsigned_numeric_literal { Signed($1,$2) } | sign unsigned_numeric_literal { Signed($1,$2) }
| unsigned_numeric_literal { $1 } | unsigned_numeric_literal { $1 }
*)
unsigned_numeric_literal : unsigned_numeric_literal :
| exact_numeric_literal { $1 } | exact_numeric_literal { $1 }