Compare commits

..

5 Commits

Author SHA1 Message Date
517dfc465f wip 2025-05-05 15:36:05 +00:00
fb29391b17 renaming file 2025-05-05 15:36:01 +00:00
e61ab45990 adding csv test 2025-05-05 15:35:49 +00:00
f6c083ac43 small comment 2025-05-05 15:35:35 +00:00
ccd86519ff adding mock csv + ren 2025-05-05 15:35:09 +00:00
8 changed files with 49 additions and 2 deletions

View File

@ -80,6 +80,8 @@ and sign =
| Times
| Divide
(* pp = pretty print *)
let rec pp_query fmt ast =
match ast with
| Select(cols, table_exp) -> Format.fprintf fmt "%s" (String.cat "SELECT " (pp_columns cols) ^ pp_table_expression table_exp)

View File

@ -215,6 +215,7 @@ column_reference:
set_function_specification:
| aggregate_function { $1 }
(* | grouping_function { $1 } *)
(*********************************)

View File

@ -6,8 +6,14 @@
(name test_logical_plan)
(libraries ast logical_plan alcotest))
(test
(name test_csv)
(libraries csv ast logical_plan alcotest)
(deps
(file ./files/csv/data.csv)))
(test
(name test_parquet)
(libraries parquet)
(deps
(file ./files/parquet/mock_data.parquet)))
(file ./files/parquet/data.parquet)))

11
test/files/csv/data.csv Normal file
View File

@ -0,0 +1,11 @@
id,name,age,email,city
1,Alice,30,alice@example.com,New York
2,Bob,25,bob@example.com,Los Angeles
3,Charlie,35,charlie@example.com,Chicago
4,David,28,david@example.com,Houston
5,Eve,29,eve@example.com,Phoenix
6,Frank,40,frank@example.com,Philadelphia
7,Grace,32,grace@example.com,San Antonio
8,Heidi,27,heidi@example.com,San Diego
9,Ivan,31,ivan@example.com,Dallas
10,Judy,34,judy@example.com,San Jose
1 id name age email city
2 1 Alice 30 alice@example.com New York
3 2 Bob 25 bob@example.com Los Angeles
4 3 Charlie 35 charlie@example.com Chicago
5 4 David 28 david@example.com Houston
6 5 Eve 29 eve@example.com Phoenix
7 6 Frank 40 frank@example.com Philadelphia
8 7 Grace 32 grace@example.com San Antonio
9 8 Heidi 27 heidi@example.com San Diego
10 9 Ivan 31 ivan@example.com Dallas
11 10 Judy 34 judy@example.com San Jose

View File

@ -411,6 +411,10 @@ let test_aggregates () =
let ast1 =
Select(
[
Column(
Ref("function"),
None
)
],
TableExpression(
Some(

23
test/test_csv.ml Normal file
View File

@ -0,0 +1,23 @@
open Csv
open Alcotest
(* Function to read CSV file *)
let read_csv filename =
let ic = open_in filename in
let csv = Csv.load_in ic in
csv
(* Test to check if the CSV file is read correctly *)
let test_read_csv () =
let csv_data = read_csv "files/csv/data.csv" in
let nb_columns = Csv.columns csv_data in
check int "Number of columns" nb_columns 5
(* Run the test *)
let () =
run "CSV Tests" [
"Read CSV", [
test_case "Read and validate CSV" `Quick test_read_csv
]
]

View File

@ -1,7 +1,7 @@
open Parquet
let () =
let path = "files/parquet/mock_data.parquet" in
let path = "files/parquet/data.parquet" in
let ic = open_in path in
assert(parquet_check_prefix ic = true);
assert(parquet_check_suffix ic = true)