Skip to content

Commit 0f42cf1

Browse files
committed
add limit clause
1 parent e82ff74 commit 0f42cf1

File tree

8 files changed

+61
-108
lines changed

8 files changed

+61
-108
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.ipynb_checkpoints/
22

33
_build/
4+
_opam/
45

56
config-*sh
67
config.ini

bin/dune

+39-32
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@
3434
(pps ppx_sexp_conv ppx_let))
3535
(modules sample_tpch))
3636

37-
(executable
38-
(package castor)
39-
(public_name sql-to-castor)
40-
(name parse_sql)
41-
(libraries core core_unix.command_unix sqlgg castor yojson)
42-
(preprocess
43-
(pps ppx_sexp_conv ppx_let))
44-
(modules parse_sql))
37+
; (executable
38+
; (package castor)
39+
; (public_name sql-to-castor)
40+
; (name parse_sql)
41+
; (libraries core core_unix.command_unix sqlgg castor yojson)
42+
; (preprocess
43+
; (pps ppx_sexp_conv ppx_let))
44+
; (modules parse_sql))
4545

46-
(executable
47-
(package castor)
48-
(public_name cozy-to-castor)
49-
(name parse_cozy)
50-
(libraries core core_unix.command_unix castor)
51-
(preprocess
52-
(pps ppx_sexp_conv ppx_let))
53-
(modules parse_cozy))
46+
; (executable
47+
; (package castor)
48+
; (public_name cozy-to-castor)
49+
; (name parse_cozy)
50+
; (libraries core core_unix.command_unix castor)
51+
; (preprocess
52+
; (pps ppx_sexp_conv ppx_let))
53+
; (modules parse_cozy))
5454

5555
(executable
5656
(package castor)
@@ -61,23 +61,23 @@
6161
(pps ppx_sexp_conv ppx_let))
6262
(modules combine))
6363

64-
(executable
65-
(package castor)
66-
(name opt)
67-
(public_name opt.exe)
68-
(libraries core core_unix.command_unix castor logs logs.fmt fmt fmt.tty)
69-
(preprocess
70-
(pps ppx_sexp_conv ppx_let ppx_sexp_conv ppx_compare ppx_hash))
71-
(modules opt))
64+
; (executable
65+
; (package castor)
66+
; (name opt)
67+
; (public_name opt.exe)
68+
; (libraries core core_unix.command_unix castor logs logs.fmt fmt fmt.tty)
69+
; (preprocess
70+
; (pps ppx_sexp_conv ppx_let ppx_sexp_conv ppx_compare ppx_hash))
71+
; (modules opt))
7272

73-
(executable
74-
(package castor)
75-
(name xform)
76-
(public_name xform.exe)
77-
(libraries core core_unix.command_unix castor logs logs.fmt fmt fmt.tty)
78-
(preprocess
79-
(pps ppx_sexp_conv ppx_let ppx_sexp_conv ppx_compare ppx_hash))
80-
(modules xform))
73+
; (executable
74+
; (package castor)
75+
; (name xform)
76+
; (public_name xform.exe)
77+
; (libraries core core_unix.command_unix castor logs logs.fmt fmt fmt.tty)
78+
; (preprocess
79+
; (pps ppx_sexp_conv ppx_let ppx_sexp_conv ppx_compare ppx_hash))
80+
; (modules xform))
8181

8282
(executable
8383
(package castor)
@@ -87,3 +87,10 @@
8787
(preprocess
8888
(pps ppx_sexp_conv ppx_let ppx_sexp_conv ppx_compare ppx_hash))
8989
(modules sql))
90+
91+
(executable
92+
(package castor)
93+
(public_name sql2code)
94+
(libraries core fmt iter sql2code)
95+
(preprocess (pps ppx_compare ppx_sexp_message ppx_sexp_conv ppx_let))
96+
(modules sql2code))

flake.nix

-55
This file was deleted.

lib/abslayout.ml

-19
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ module A = Constructors.Annot
99

1010
let pp = Abslayout_pp.pp
1111

12-
let name r =
13-
match r.node with
14-
| Select _ -> "select"
15-
| Filter _ -> "filter"
16-
| DepJoin _ -> "depjoin"
17-
| Join _ -> "join"
18-
| GroupBy _ -> "group_by"
19-
| Dedup _ -> "dedup"
20-
| OrderBy _ -> "order_by"
21-
| Relation _ -> "scan"
22-
| AEmpty -> "empty"
23-
| AScalar _ -> "scalar"
24-
| AList _ -> "list"
25-
| ATuple _ -> "tuple"
26-
| AHashIdx _ -> "hash_idx"
27-
| AOrderedIdx _ -> "ordered_idx"
28-
| Range _ -> "range"
29-
| Call _ -> "call"
30-
3112
type error = [ `Parse_error of string * int * int ] [@@deriving sexp]
3213

3314
let pp_err f fmt = function

lib/abslayout.mli

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ include Comparator.S with type t := t
1212
module O : Comparable.Infix with type t := t
1313

1414
val pp : _ annot Fmt.t
15-
val name : t -> string
1615

1716
val names : t -> Set.M(Name).t
1817
(** The set of names in a `t`. *)

lib/ast.ml

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type ('p, 'r) query =
104104
| Dedup of 'r
105105
| Relation of Relation.t
106106
| Range of ('p * 'p)
107+
| Limit of int
107108
| AEmpty
108109
| AScalar of 'p scalar
109110
| AList of 'r list_

lib/visitors.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ module Iter = struct
252252
| `First q | `Exists q -> annot q
253253

254254
let query annot pred = function
255-
| Relation _ | AEmpty | Call _ -> ()
255+
| Relation _ | AEmpty | Call _ | Limit _ -> ()
256256
| Select (ps, q) | GroupBy (ps, _, q) ->
257257
List.iter ~f:(fun (p, _) -> pred p) (Select_list.to_list ps);
258258
annot q

lib/visitors_gen.ml

+19
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ class virtual ['self] base_endo =
281281
let r0 = self#visit_string env c0 in
282282
if c0 == r0 then this else Call r0
283283

284+
method visit_Limit env this c0 =
285+
let r0 = self#visit_int env c0 in
286+
if c0 == r0 then this else Limit r0
287+
284288
method visit_query env this =
285289
match this with
286290
| Select c0 as this -> self#visit_Select env this c0
@@ -299,6 +303,7 @@ class virtual ['self] base_endo =
299303
| AHashIdx c0 as this -> self#visit_AHashIdx env this c0
300304
| AOrderedIdx c0 as this -> self#visit_AOrderedIdx env this c0
301305
| Call c0 as this -> self#visit_Call env this c0
306+
| Limit c0 as this -> self#visit_Limit env this c0
302307

303308
method visit_annot env this =
304309
let r0 = self#visit_query env this.node in
@@ -574,6 +579,10 @@ class virtual ['self] base_map =
574579
let r0 = self#visit_string env c0 in
575580
Call r0
576581

582+
method visit_Limit env c0 =
583+
let r0 = self#visit_int env c0 in
584+
Limit r0
585+
577586
method visit_query env this =
578587
match this with
579588
| Select c0 -> self#visit_Select env c0
@@ -592,6 +601,7 @@ class virtual ['self] base_map =
592601
| AHashIdx c0 -> self#visit_AHashIdx env c0
593602
| AOrderedIdx c0 -> self#visit_AOrderedIdx env c0
594603
| Call c0 -> self#visit_Call env c0
604+
| Limit c0 -> self#visit_Limit env c0
595605

596606
method visit_annot env this =
597607
let r0 = self#visit_query env this.node in
@@ -863,6 +873,7 @@ class virtual ['self] base_iter =
863873
()
864874

865875
method visit_Call env c0 = self#visit_string env c0
876+
method visit_Limit env c0 = self#visit_int env c0
866877

867878
method visit_query env this =
868879
match this with
@@ -882,6 +893,7 @@ class virtual ['self] base_iter =
882893
| AHashIdx c0 -> self#visit_AHashIdx env c0
883894
| AOrderedIdx c0 -> self#visit_AOrderedIdx env c0
884895
| Call c0 -> self#visit_Call env c0
896+
| Limit c0 -> self#visit_Limit env c0
885897

886898
method visit_annot env this =
887899
let r0 = self#visit_query env this.node in
@@ -1153,6 +1165,7 @@ class virtual ['self] base_reduce =
11531165
s0
11541166

11551167
method visit_Call env c0 = self#visit_string env c0
1168+
method visit_Limit env c0 = self#visit_int env c0
11561169

11571170
method visit_query env this =
11581171
match this with
@@ -1172,6 +1185,7 @@ class virtual ['self] base_reduce =
11721185
| AHashIdx c0 -> self#visit_AHashIdx env c0
11731186
| AOrderedIdx c0 -> self#visit_AOrderedIdx env c0
11741187
| Call c0 -> self#visit_Call env c0
1188+
| Limit c0 -> self#visit_Limit env c0
11751189

11761190
method visit_annot env this =
11771191
let s0 = self#visit_query env this.node in
@@ -1452,6 +1466,10 @@ class virtual ['self] base_mapreduce =
14521466
let r0, s0 = self#visit_string env c0 in
14531467
(Call r0, s0)
14541468

1469+
method visit_Limit env c0 =
1470+
let r0, s0 = self#visit_int env c0 in
1471+
(Limit r0, s0)
1472+
14551473
method visit_query env this =
14561474
match this with
14571475
| Select c0 -> self#visit_Select env c0
@@ -1470,6 +1488,7 @@ class virtual ['self] base_mapreduce =
14701488
| AHashIdx c0 -> self#visit_AHashIdx env c0
14711489
| AOrderedIdx c0 -> self#visit_AOrderedIdx env c0
14721490
| Call c0 -> self#visit_Call env c0
1491+
| Limit c0 -> self#visit_Limit env c0
14731492

14741493
method visit_annot env this =
14751494
let r0, s0 = self#visit_query env this.node in

0 commit comments

Comments
 (0)