adding a test for logicla plan

This commit is contained in:
simon petit 2024-12-13 14:05:15 +00:00
parent 82460a22fd
commit df350c7730
3 changed files with 43 additions and 4 deletions

View File

@ -2,6 +2,10 @@
(name test_ast)
(libraries parser lexer ast alcotest))
(test
(name test_logical_plan)
(libraries ast logical_plan alcotest))
(test
(name test_parquet)
(libraries parquet)

View File

@ -4,11 +4,8 @@ let parse query =
let lexbuf = Lexing.from_string query in
Parser.main Lexer.read_token lexbuf
let equal_ast ast1 ast2 =
ast1 = ast2
let query_testable =
Alcotest.testable Ast.pp_query equal_ast
Alcotest.testable Ast.pp_query (=)
let test_simple_select () =
let query = "SELECT a, b FROM t" in

38
test/test_logical_plan.ml Normal file
View File

@ -0,0 +1,38 @@
open Logical_plan
let logical_plan_testable =
let pp_format fmt plan =
Format.fprintf fmt "%s" (Logical_plan.pp_logical_plan plan)
in
Alcotest.testable pp_format (=)
let test_simple_select () =
let ast1 =
Ast.Select(
[
Ast.Column(
Ast.StringLiteral("string"),
None
)
],
Ast.TableExpression(
None,
None,
None
)
)
in
let plan1 = ast_to_logical ast1 in
let plan2 =
Project(Scan("table"), "string")
in
Alcotest.(check logical_plan_testable) "ok" plan1 plan2
let simple_select_set = [ ("Equals", `Quick, test_simple_select) ]
let () =
Alcotest.run "Logical plan tests"
[
("Simple Selects", simple_select_set)
]