alf-shell 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +5 -2
- data/Gemfile.lock +29 -10
- data/bin/alf +2 -0
- data/doc/man/alf-explain.man +22 -0
- data/doc/man/alf-metadata.man +13 -0
- data/doc/man/alf-show.man +16 -0
- data/doc/man/alf.man +77 -0
- data/doc/man/allbut.man +39 -0
- data/doc/man/among.man +25 -0
- data/doc/man/avg.man +37 -0
- data/doc/man/between.man +24 -0
- data/doc/man/concat.man +55 -0
- data/doc/man/contradiction.man +26 -0
- data/doc/man/count.man +20 -0
- data/doc/man/eq.man +29 -0
- data/doc/man/extend.man +33 -0
- data/doc/man/frame.man +60 -0
- data/doc/man/group.man +51 -0
- data/doc/man/gt.man +30 -0
- data/doc/man/gte.man +30 -0
- data/doc/man/intersect.man +54 -0
- data/doc/man/join.man +84 -0
- data/doc/man/lt.man +30 -0
- data/doc/man/lte.man +30 -0
- data/doc/man/matching.man +73 -0
- data/doc/man/max.man +36 -0
- data/doc/man/min.man +36 -0
- data/doc/man/minus.man +54 -0
- data/doc/man/native.man +32 -0
- data/doc/man/neq.man +29 -0
- data/doc/man/not_matching.man +51 -0
- data/doc/man/page.man +60 -0
- data/doc/man/project.man +36 -0
- data/doc/man/rank.man +42 -0
- data/doc/man/rename.man +29 -0
- data/doc/man/restrict.man +38 -0
- data/doc/man/stddev.man +37 -0
- data/doc/man/sum.man +37 -0
- data/doc/man/summarize.man +45 -0
- data/doc/man/tautology.man +26 -0
- data/doc/man/ungroup.man +30 -0
- data/doc/man/union.man +55 -0
- data/doc/man/unwrap.man +37 -0
- data/doc/man/variance.man +37 -0
- data/doc/man/wrap.man +37 -0
- data/doc/txt/alf-explain.man +22 -0
- data/doc/txt/alf-metadata.man +16 -0
- data/doc/txt/alf-show.man +19 -0
- data/doc/txt/alf.man +80 -0
- data/doc/txt/allbut.txt +31 -0
- data/doc/txt/among.txt +20 -0
- data/doc/txt/avg.txt +22 -0
- data/doc/txt/between.txt +19 -0
- data/doc/txt/concat.txt +31 -0
- data/doc/txt/contradiction.txt +15 -0
- data/doc/txt/count.txt +14 -0
- data/doc/txt/eq.txt +19 -0
- data/doc/txt/extend.txt +29 -0
- data/doc/txt/frame.txt +48 -0
- data/doc/txt/group.txt +37 -0
- data/doc/txt/gt.txt +20 -0
- data/doc/txt/gte.txt +20 -0
- data/doc/txt/intersect.txt +42 -0
- data/doc/txt/join.txt +65 -0
- data/doc/txt/lt.txt +20 -0
- data/doc/txt/lte.txt +20 -0
- data/doc/txt/matching.txt +54 -0
- data/doc/txt/max.txt +21 -0
- data/doc/txt/min.txt +21 -0
- data/doc/txt/minus.txt +42 -0
- data/doc/txt/native.txt +27 -0
- data/doc/txt/neq.txt +19 -0
- data/doc/txt/not_matching.txt +39 -0
- data/doc/txt/page.txt +48 -0
- data/doc/txt/project.txt +28 -0
- data/doc/txt/rank.txt +34 -0
- data/doc/txt/rename.txt +25 -0
- data/doc/txt/restrict.txt +26 -0
- data/doc/txt/stddev.txt +22 -0
- data/doc/txt/sum.txt +22 -0
- data/doc/txt/summarize.txt +33 -0
- data/doc/txt/tautology.txt +15 -0
- data/doc/txt/ungroup.txt +26 -0
- data/doc/txt/union.txt +43 -0
- data/doc/txt/unwrap.txt +29 -0
- data/doc/txt/variance.txt +22 -0
- data/doc/txt/wrap.txt +29 -0
- data/lib/alf/shell.rb +2 -32
- data/lib/alf/shell/alfrc.rb +3 -0
- data/lib/alf/shell/command.rb +2 -18
- data/lib/alf/shell/command/explain.rb +37 -0
- data/lib/alf/shell/command/help.rb +3 -21
- data/lib/alf/shell/command/main.rb +20 -78
- data/lib/alf/shell/command/metadata.rb +32 -0
- data/lib/alf/shell/command/show.rb +17 -5
- data/lib/alf/shell/support.rb +21 -13
- data/lib/alf/shell/version.rb +1 -1
- data/spec/integration/explain/explain.cmd +1 -0
- data/spec/integration/explain/explain.stdout +11 -0
- data/spec/integration/show/group.alf +2 -0
- data/spec/integration/show/show_alf.cmd +1 -0
- data/spec/integration/{group/group_0.stdout → show/show_alf.stdout} +0 -0
- data/tasks/doc.rake +4 -0
- metadata +116 -178
- data/doc/commands/exec.md +0 -16
- data/doc/commands/help.md +0 -11
- data/doc/commands/main.md +0 -33
- data/doc/commands/show.md +0 -12
- data/doc/operators/non_relational/autonum.md +0 -23
- data/doc/operators/non_relational/clip.md +0 -31
- data/doc/operators/non_relational/coerce.md +0 -15
- data/doc/operators/non_relational/compact.md +0 -20
- data/doc/operators/non_relational/defaults.md +0 -32
- data/doc/operators/non_relational/generator.md +0 -20
- data/doc/operators/non_relational/sort.md +0 -24
- data/doc/operators/non_relational/type-safe.md +0 -20
- data/doc/operators/relational/extend.md +0 -18
- data/doc/operators/relational/frame.md +0 -26
- data/doc/operators/relational/group.md +0 -27
- data/doc/operators/relational/hierarchize.md +0 -14
- data/doc/operators/relational/infer-heading.md +0 -20
- data/doc/operators/relational/intersect.md +0 -13
- data/doc/operators/relational/join.md +0 -28
- data/doc/operators/relational/matching.md +0 -24
- data/doc/operators/relational/minus.md +0 -12
- data/doc/operators/relational/not-matching.md +0 -20
- data/doc/operators/relational/page.md +0 -31
- data/doc/operators/relational/project.md +0 -28
- data/doc/operators/relational/quota.md +0 -21
- data/doc/operators/relational/rank.md +0 -27
- data/doc/operators/relational/rename.md +0 -17
- data/doc/operators/relational/restrict.md +0 -25
- data/doc/operators/relational/summarize.md +0 -25
- data/doc/operators/relational/ungroup.md +0 -20
- data/doc/operators/relational/union.md +0 -14
- data/doc/operators/relational/unwrap.md +0 -20
- data/doc/operators/relational/wrap.md +0 -24
- data/lib/alf/shell/command/exec.rb +0 -16
- data/lib/alf/shell/doc_manager.rb +0 -84
- data/lib/alf/shell/ext/signature.rb +0 -45
- data/lib/alf/shell/from_argv.rb +0 -84
- data/lib/alf/shell/operator.rb +0 -63
- data/spec/integration/__database__/group.alf +0 -3
- data/spec/integration/alf/alf_e.cmd +0 -1
- data/spec/integration/alf/alf_e.stdout +0 -4
- data/spec/integration/alf/alf_help.cmd +0 -1
- data/spec/integration/alf/alf_help.stdout +0 -76
- data/spec/integration/alf/alf_r.cmd +0 -1
- data/spec/integration/alf/alf_r.stdout +0 -5
- data/spec/integration/autonum/autonum_0.cmd +0 -1
- data/spec/integration/autonum/autonum_0.stdout +0 -9
- data/spec/integration/autonum/autonum_1.cmd +0 -1
- data/spec/integration/autonum/autonum_1.stdout +0 -9
- data/spec/integration/clip/clip_0.cmd +0 -1
- data/spec/integration/clip/clip_0.stdout +0 -9
- data/spec/integration/clip/clip_1.cmd +0 -1
- data/spec/integration/clip/clip_1.stdout +0 -9
- data/spec/integration/coerce/coerce_1.cmd +0 -1
- data/spec/integration/coerce/coerce_1.stdout +0 -5
- data/spec/integration/compact/compact_0.cmd +0 -1
- data/spec/integration/compact/compact_0.stdout +0 -9
- data/spec/integration/defaults/defaults_0.cmd +0 -1
- data/spec/integration/defaults/defaults_0.stdout +0 -9
- data/spec/integration/defaults/defaults_1.cmd +0 -1
- data/spec/integration/defaults/defaults_1.stdout +0 -9
- data/spec/integration/defaults/defaults_2.cmd +0 -1
- data/spec/integration/defaults/defaults_2.stdout +0 -9
- data/spec/integration/extend/extend_0.cmd +0 -1
- data/spec/integration/extend/extend_0.stdout +0 -16
- data/spec/integration/frame/frame_0.cmd +0 -1
- data/spec/integration/frame/frame_0.stdout +0 -6
- data/spec/integration/generator/generator_1.cmd +0 -1
- data/spec/integration/generator/generator_1.stdout +0 -10
- data/spec/integration/generator/generator_2.cmd +0 -1
- data/spec/integration/generator/generator_2.stdout +0 -5
- data/spec/integration/generator/generator_3.cmd +0 -1
- data/spec/integration/generator/generator_3.stdout +0 -5
- data/spec/integration/group/group_0.cmd +0 -1
- data/spec/integration/group/group_1.cmd +0 -1
- data/spec/integration/group/group_1.stdout +0 -32
- data/spec/integration/help/help_1.cmd +0 -1
- data/spec/integration/help/help_1.stdout +0 -12
- data/spec/integration/intersect/intersect_0.cmd +0 -1
- data/spec/integration/intersect/intersect_0.stdout +0 -9
- data/spec/integration/join/join_0.cmd +0 -1
- data/spec/integration/join/join_0.stdout +0 -16
- data/spec/integration/matching/matching_0.cmd +0 -1
- data/spec/integration/matching/matching_0.stdout +0 -8
- data/spec/integration/minus/minus_0.cmd +0 -1
- data/spec/integration/minus/minus_0.stdout +0 -4
- data/spec/integration/not-matching/not-matching_0.cmd +0 -1
- data/spec/integration/not-matching/not-matching_0.stdout +0 -5
- data/spec/integration/page/page_0.cmd +0 -1
- data/spec/integration/page/page_0.stdout +0 -6
- data/spec/integration/project/project_0.cmd +0 -1
- data/spec/integration/project/project_0.stdout +0 -9
- data/spec/integration/project/project_1.cmd +0 -1
- data/spec/integration/project/project_1.stdout +0 -9
- data/spec/integration/quota/quota_0.cmd +0 -1
- data/spec/integration/quota/quota_0.stdout +0 -16
- data/spec/integration/rank/rank_1.cmd +0 -1
- data/spec/integration/rank/rank_1.stdout +0 -10
- data/spec/integration/rank/rank_2.cmd +0 -1
- data/spec/integration/rank/rank_2.stdout +0 -10
- data/spec/integration/rank/rank_3.cmd +0 -1
- data/spec/integration/rank/rank_3.stdout +0 -10
- data/spec/integration/rank/rank_4.cmd +0 -1
- data/spec/integration/rank/rank_4.stdout +0 -6
- data/spec/integration/rank/rank_5.cmd +0 -1
- data/spec/integration/rank/rank_5.stdout +0 -6
- data/spec/integration/rename/rename_0.cmd +0 -1
- data/spec/integration/rename/rename_0.stdout +0 -9
- data/spec/integration/restrict/restrict_0.cmd +0 -1
- data/spec/integration/restrict/restrict_0.stdout +0 -6
- data/spec/integration/restrict/restrict_1.cmd +0 -1
- data/spec/integration/restrict/restrict_1.stdout +0 -6
- data/spec/integration/sort/sort_0.cmd +0 -1
- data/spec/integration/sort/sort_0.stdout +0 -9
- data/spec/integration/sort/sort_1.cmd +0 -1
- data/spec/integration/sort/sort_1.stdout +0 -9
- data/spec/integration/sort/sort_2.cmd +0 -1
- data/spec/integration/sort/sort_2.stdout +0 -9
- data/spec/integration/sort/sort_3.cmd +0 -1
- data/spec/integration/sort/sort_3.stdout +0 -9
- data/spec/integration/summarize/summarize_0.cmd +0 -1
- data/spec/integration/summarize/summarize_0.stdout +0 -8
- data/spec/integration/union/union_0.cmd +0 -1
- data/spec/integration/union/union_0.stdout +0 -9
- data/spec/integration/unwrap/unwrap_0.cmd +0 -1
- data/spec/integration/unwrap/unwrap_0.stdout +0 -9
- data/spec/integration/wrap/wrap_0.cmd +0 -1
- data/spec/integration/wrap/wrap_0.stdout +0 -9
- data/spec/unit/doc_manager/dynamic.md +0 -1
- data/spec/unit/doc_manager/example.md +0 -1
- data/spec/unit/doc_manager/example_1.txt +0 -11
- data/spec/unit/doc_manager/static.md +0 -1
- data/spec/unit/doc_manager/test_call.rb +0 -41
- data/spec/unit/ext/signature/test_argv2args.rb +0 -82
- data/spec/unit/ext/signature/test_to_shell.rb +0 -103
- data/spec/unit/from_argv/test_to_attr_list.rb +0 -30
- data/spec/unit/from_argv/test_to_attr_name.rb +0 -27
- data/spec/unit/from_argv/test_to_boolean.rb +0 -32
- data/spec/unit/from_argv/test_to_heading.rb +0 -37
- data/spec/unit/from_argv/test_to_ordering.rb +0 -28
- data/spec/unit/from_argv/test_to_predicate.rb +0 -26
- data/spec/unit/from_argv/test_to_renaming.rb +0 -23
- data/spec/unit/from_argv/test_to_size.rb +0 -32
- data/spec/unit/from_argv/test_to_summarization.rb +0 -19
- data/spec/unit/from_argv/test_to_tuple_computation.rb +0 -18
- data/spec/unit/from_argv/test_to_tuple_expression.rb +0 -38
- data/spec/unit/main/test_class_methods.rb +0 -44
- data/spec/unit/operator/test_autonum.rb +0 -28
- data/spec/unit/operator/test_clip.rb +0 -29
- data/spec/unit/operator/test_coerce.rb +0 -22
- data/spec/unit/operator/test_compact.rb +0 -16
- data/spec/unit/operator/test_defaults.rb +0 -29
- data/spec/unit/operator/test_extend.rb +0 -21
- data/spec/unit/operator/test_generator.rb +0 -37
- data/spec/unit/operator/test_group.rb +0 -32
- data/spec/unit/operator/test_infer_heading.rb +0 -16
- data/spec/unit/operator/test_intersect.rb +0 -18
- data/spec/unit/operator/test_join.rb +0 -18
- data/spec/unit/operator/test_matching.rb +0 -18
- data/spec/unit/operator/test_minus.rb +0 -18
- data/spec/unit/operator/test_not_matching.rb +0 -18
- data/spec/unit/operator/test_project.rb +0 -38
- data/spec/unit/operator/test_quota.rb +0 -23
- data/spec/unit/operator/test_rank.rb +0 -30
- data/spec/unit/operator/test_rename.rb +0 -21
- data/spec/unit/operator/test_restrict.rb +0 -36
- data/spec/unit/operator/test_sort.rb +0 -49
- data/spec/unit/operator/test_summarize.rb +0 -30
- data/spec/unit/operator/test_ungroup.rb +0 -28
- data/spec/unit/operator/test_union.rb +0 -18
- data/spec/unit/operator/test_unwrap.rb +0 -28
- data/spec/unit/operator/test_wrap.rb +0 -30
data/doc/man/stddev.man
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.TH Stddev
|
|
2
|
+
.PP
|
|
3
|
+
Standard deviation
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
stddev(expr: AttrName|(Tuple->Numeric)) -> Aggregator
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
stddev(:qty)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
stddev{|t| t.qty * t.price }
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.PP
|
|
25
|
+
.RS
|
|
26
|
+
.nf
|
|
27
|
+
stddev(->(t){ t.qty * t.price })
|
|
28
|
+
.fi
|
|
29
|
+
.RE
|
|
30
|
+
.SH Description
|
|
31
|
+
.PP
|
|
32
|
+
Computes how much variation from the average exists.
|
|
33
|
+
.SH Implementation notes
|
|
34
|
+
.PP
|
|
35
|
+
This aggregate function should only be used with numeric types. As of
|
|
36
|
+
current Alf version, it does not aggregate empty sets correctly on
|
|
37
|
+
non\-numeric data types.
|
data/doc/man/sum.man
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.TH Sum
|
|
2
|
+
.PP
|
|
3
|
+
Arithmetic sum
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
sum(expr: AttrName|(Tuple->Numeric)) -> Aggregator
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
sum(:qty)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
sum{|t| t.qty * t.price }
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.PP
|
|
25
|
+
.RS
|
|
26
|
+
.nf
|
|
27
|
+
sum(->(t){ t.qty * t.price })
|
|
28
|
+
.fi
|
|
29
|
+
.RE
|
|
30
|
+
.SH Description
|
|
31
|
+
.PP
|
|
32
|
+
Computes \fB\fCv1 + v2 + ... + vn\fR\&.
|
|
33
|
+
.SH Implementation notes
|
|
34
|
+
.PP
|
|
35
|
+
This aggregate function should only be used with numeric types. As of
|
|
36
|
+
current Alf version, it does not aggregate empty sets correctly on
|
|
37
|
+
non\-numeric data types.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.TH Summarize
|
|
2
|
+
.PP
|
|
3
|
+
Aggregate and compute
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
summarize(operand: Relation, by: AttrList, aggs: Summarization) -> Relation
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
summarize(supplies, [:sid], total: sum(:qty))
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
summarize(supplies, [:sid], total: sum{|t| t.qty * 2 })
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.PP
|
|
25
|
+
.RS
|
|
26
|
+
.nf
|
|
27
|
+
summarize(supplies, [:pid, :qty], {total: sum{|t| t.qty * 2 }}, allbut: true)
|
|
28
|
+
.fi
|
|
29
|
+
.RE
|
|
30
|
+
.SH Description
|
|
31
|
+
.PP
|
|
32
|
+
Computes the relation obtained by taking the projection of \fB\fCoperand\fR
|
|
33
|
+
on \fB\fCby\fR attributes then extending each tuple \fB\fCt\fR with the result of
|
|
34
|
+
aggregations defined by \fB\fCaggs\fR on the tuples from \fB\fCoperand\fR matching \fB\fCt\fR\&.
|
|
35
|
+
.PP
|
|
36
|
+
In SQL terms, \fB\fCSELECT [by], [agg] FROM operand GROUP BY [by]\fR\&.
|
|
37
|
+
.SH Implementation notes
|
|
38
|
+
.PP
|
|
39
|
+
As of current Alf version, this operator cannot be translated to SQL code.
|
|
40
|
+
That means that all computations are done in ruby, which may seriously
|
|
41
|
+
hurt performance.
|
|
42
|
+
.PP
|
|
43
|
+
Similarly, as \fB\fCsummarize\fR tends to be a showstopper during compilation, it
|
|
44
|
+
is strongly recommanded to use it as high as possible in query expressions
|
|
45
|
+
trees so as to delegate the largest possible query parts to data engines.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.TH Tautology
|
|
2
|
+
.PP
|
|
3
|
+
TRUE
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
tautology() -> Predicate
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
true
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
tautology
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.SH Description
|
|
25
|
+
.PP
|
|
26
|
+
This predicate always return true. It is equivalent to \fB\fC->(t){ true }\fR\&.
|
data/doc/man/ungroup.man
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.TH Ungroup
|
|
2
|
+
.PP
|
|
3
|
+
Inverse of group
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
ungroup(operand: Relation, rva: AttrName) -> Relation
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
ungroup(group(suppliers, [:city], :suppliers, allbut: true), :suppliers)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.SH Description
|
|
19
|
+
.PP
|
|
20
|
+
Computes the relation obtained by ungrouping a relation\-valued attribute
|
|
21
|
+
\fB\fCrva\fR\&. Ungrouping \fB\fCrva\fR leads as many tuples as in \fB\fCrva\fR, each extended
|
|
22
|
+
with the other attributes of \fB\fCoperand\fR\&.
|
|
23
|
+
.PP
|
|
24
|
+
\fB\fCrva\fR must be a relation\-valued attribute. It should not itself contain
|
|
25
|
+
any attribute whose name clashes with an attribute of \fB\fCoperand\fR\&.
|
|
26
|
+
.SH Implementation notes
|
|
27
|
+
.PP
|
|
28
|
+
This operator does not compile to SQL so far. Contributions are welcome
|
|
29
|
+
to provide it with a SQL compilation for SQL DBMSs that support this kind
|
|
30
|
+
of feature (e.g. PostgreSQL with JSON data type)
|
data/doc/man/union.man
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.TH Union
|
|
2
|
+
.PP
|
|
3
|
+
Logical OR
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
union(left: Relation, right: Relation) -> Relation
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
union(project(suppliers, [:city]), project(parts, [:city]))
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.SH Description
|
|
19
|
+
.PP
|
|
20
|
+
Computes the relation as the set union of \fB\fCleft\fR and \fB\fCright\fR\&.
|
|
21
|
+
.PP
|
|
22
|
+
The \fB\fCleft\fR and \fB\fCright\fR relations must be union\-compatible, meaning that they
|
|
23
|
+
must have same heading (type inheritance is partly supported through ruby's
|
|
24
|
+
own type system, so that the actual behavior is slighlty more permissive).
|
|
25
|
+
.SH Implementation notes
|
|
26
|
+
.PP
|
|
27
|
+
Unlike SQL, this operator ALWAYS remove duplicates. There is no way, in
|
|
28
|
+
Alf, to compute \fIbags\fP of tuples and therefore no way to express something
|
|
29
|
+
such as SQL's UNION ALL.
|
|
30
|
+
.PP
|
|
31
|
+
The optimizer is not smart enough so far to discover when operands are
|
|
32
|
+
actually disjoint and duplicate removal not needed (e.g. the SQL compiler
|
|
33
|
+
never generates UNION ALL). Any patch improving this is welcome!
|
|
34
|
+
.PP
|
|
35
|
+
Similarly, it is sometimes idiomatic in Alf to use \fB\fCunion\fR as a logical OR,
|
|
36
|
+
as illustrated below. So far, the optimizer/compiler is not smart enough to
|
|
37
|
+
translate the former in the latter (which is likely to have a better query
|
|
38
|
+
plan, especially when using faithful SQL compilation and usual SQL DBMSs).
|
|
39
|
+
Any patch is welcome here too!
|
|
40
|
+
.PP
|
|
41
|
+
.RS
|
|
42
|
+
.nf
|
|
43
|
+
union(
|
|
44
|
+
restrict(suppliers, city: 'Paris'),
|
|
45
|
+
restrict(suppliers, city: 'London'))
|
|
46
|
+
.fi
|
|
47
|
+
.RE
|
|
48
|
+
.PP
|
|
49
|
+
is equivalent to
|
|
50
|
+
.PP
|
|
51
|
+
.RS
|
|
52
|
+
.nf
|
|
53
|
+
restrict(suppliers, eq(:city, 'Paris') | eq(:city, 'London'))
|
|
54
|
+
.fi
|
|
55
|
+
.RE
|
data/doc/man/unwrap.man
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.TH Unwrap
|
|
2
|
+
.PP
|
|
3
|
+
Inverse of wrap
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
unwrap(operand: Relation, tva: AttrName) -> Relation
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
unwrap(wrap(suppliers, [:city, :status], :extra), :extra)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.SH Description
|
|
19
|
+
.PP
|
|
20
|
+
Computes the relation obtained by unwrapping a tuple\-valued attribute \fB\fCtva\fR\&.
|
|
21
|
+
Unwrapping of \fB\fCtva\fR on an input tuple \fB\fCt\fR consists in removing \fB\fCtva\fR from
|
|
22
|
+
\fB\fCt\fR and extending the result with \fB\fCtva\fR\&'s own attributes:
|
|
23
|
+
.PP
|
|
24
|
+
.RS
|
|
25
|
+
.nf
|
|
26
|
+
Tuple(x: 1, tva: Tuple(y: 2, z: 3)) -> Tuple(x: 1, y: 2, z: 3)
|
|
27
|
+
.fi
|
|
28
|
+
.RE
|
|
29
|
+
.PP
|
|
30
|
+
\fB\fCtva\fR must be a tuple\-valued attribute. It should not itself contain any
|
|
31
|
+
attribute whose name clashes with an attribute of \fB\fCoperand\fR\&. In the examples
|
|
32
|
+
above, \fB\fCtva\fR may not contain an attribute called \fB\fCx\fR\&.
|
|
33
|
+
.SH Implementation notes
|
|
34
|
+
.PP
|
|
35
|
+
This operator does not compile to SQL so far. Contributions are welcome to
|
|
36
|
+
provide it with a SQL compilation for SQL DBMSs that support this kind of
|
|
37
|
+
feature (e.g. PostgreSQL with JSON data type)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.TH Variance
|
|
2
|
+
.PP
|
|
3
|
+
Variance
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
variance(expr: AttrName|(Tuple->Numeric)) -> Aggregator
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
variance(:qty)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
variance{|t| t.qty * t.price }
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.PP
|
|
25
|
+
.RS
|
|
26
|
+
.nf
|
|
27
|
+
variance(->(t){ t.qty * t.price })
|
|
28
|
+
.fi
|
|
29
|
+
.RE
|
|
30
|
+
.SH Description
|
|
31
|
+
.PP
|
|
32
|
+
Computes how far the set of input values is spread out.
|
|
33
|
+
.SH Implementation notes
|
|
34
|
+
.PP
|
|
35
|
+
This aggregate function should only be used with numeric types. As of
|
|
36
|
+
current Alf version, it does not aggregate empty sets correctly on
|
|
37
|
+
non\-numeric data types.
|
data/doc/man/wrap.man
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.TH Wrap
|
|
2
|
+
.PP
|
|
3
|
+
Tuple\-valued attribute
|
|
4
|
+
.SH Signature
|
|
5
|
+
.PP
|
|
6
|
+
.RS
|
|
7
|
+
.nf
|
|
8
|
+
wrap(operand: Relation, attributes: AttrList, as: AttrName) -> Relation
|
|
9
|
+
.fi
|
|
10
|
+
.RE
|
|
11
|
+
.SH Examples
|
|
12
|
+
.PP
|
|
13
|
+
.RS
|
|
14
|
+
.nf
|
|
15
|
+
wrap(suppliers, [:city, :status], :extra)
|
|
16
|
+
.fi
|
|
17
|
+
.RE
|
|
18
|
+
.PP
|
|
19
|
+
.RS
|
|
20
|
+
.nf
|
|
21
|
+
wrap(suppliers, [:city, :status], :extra, allbut: true)
|
|
22
|
+
.fi
|
|
23
|
+
.RE
|
|
24
|
+
.SH Description
|
|
25
|
+
.PP
|
|
26
|
+
Computes the relation obtained by removing \fB\fCattributes\fR and replacing them
|
|
27
|
+
by a single attribute (\fB\fCas\fR). The latter is a tuple\-valued attribute
|
|
28
|
+
obtained by projecting the input tuple on \fB\fCattributes\fR\&.
|
|
29
|
+
.PP
|
|
30
|
+
This operators supports an ALL BUT variant, through the \fB\fCallbut\fR option.
|
|
31
|
+
When set to true, the operator keeps specified attributes and wraps all the
|
|
32
|
+
remaining ones as a tuple\-valued attribute.
|
|
33
|
+
.SH Implementation notes
|
|
34
|
+
.PP
|
|
35
|
+
This operator does not compile to SQL so far. Contributions are welcome to
|
|
36
|
+
provide it with a SQL compilation for SQL DBMSs that support this kind of
|
|
37
|
+
feature (e.g. PostgreSQL with JSON data type)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# alf-explain
|
|
2
|
+
|
|
3
|
+
Show the logical (optimizer) and physical (compiler) plans of a query.
|
|
4
|
+
|
|
5
|
+
## Synopsis
|
|
6
|
+
|
|
7
|
+
`alf` explain *QUERY*
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
This command prints the logical and physical query plans for QUERY to
|
|
12
|
+
standard output:
|
|
13
|
+
|
|
14
|
+
* The logical plan is post-optimizer and allows checking that the latter
|
|
15
|
+
performs correctly.
|
|
16
|
+
* The physical plan provides information about compilation. In particular it
|
|
17
|
+
provides feedback about the effective delegation to underlying database
|
|
18
|
+
engines, as well as involved SQL queries.
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
`alf` `--examples` explain "restrict(suppliers, city: 'London')"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# alf-metadata
|
|
2
|
+
|
|
3
|
+
Show metadata about a query, such as heading and candidate keys.
|
|
4
|
+
|
|
5
|
+
## Synopsis
|
|
6
|
+
|
|
7
|
+
`alf` metadata *QUERY*
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
This command prints some metadata (e.g. heading, keys, etc.) about the
|
|
12
|
+
expression passed as first argument.
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
`alf` `--examples` metadata "restrict(suppliers, city: 'London')"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# alf-show
|
|
2
|
+
|
|
3
|
+
Evaluates a query and shows the result.
|
|
4
|
+
|
|
5
|
+
## Synopsis
|
|
6
|
+
|
|
7
|
+
`alf` [`--csv`|`--json`...] show *QUERY* -- [*ORDERING*]
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
Take a query argument and execute it against the current database (according
|
|
12
|
+
to options passed to the `alf` main command). Show the result on standard
|
|
13
|
+
output. The format (e.g. json) may be specified through `alf` main options.
|
|
14
|
+
|
|
15
|
+
When an ordering is specified, tuples are rendered in the order specified.
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
`alf` `--examples` show "restrict(suppliers, city: 'London')" -- name DESC
|
data/doc/txt/alf.man
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# alf
|
|
2
|
+
|
|
3
|
+
Relational algebra at your fingertips
|
|
4
|
+
|
|
5
|
+
## Synopsis
|
|
6
|
+
|
|
7
|
+
`alf` [`--version`] [`--help`]
|
|
8
|
+
|
|
9
|
+
`alf` *FILE.alf*
|
|
10
|
+
|
|
11
|
+
`alf` show *QUERY*
|
|
12
|
+
|
|
13
|
+
`alf` explain *QUERY*
|
|
14
|
+
|
|
15
|
+
`alf` help *OPERATOR*
|
|
16
|
+
|
|
17
|
+
## Options
|
|
18
|
+
|
|
19
|
+
`--rash`
|
|
20
|
+
Render output as ruby hashes
|
|
21
|
+
|
|
22
|
+
`--text`
|
|
23
|
+
Render output as a text table
|
|
24
|
+
|
|
25
|
+
`--yaml`
|
|
26
|
+
Render output in YAML
|
|
27
|
+
|
|
28
|
+
`--json`
|
|
29
|
+
Render output in JSON
|
|
30
|
+
|
|
31
|
+
`--csv`
|
|
32
|
+
Render output in CSV
|
|
33
|
+
|
|
34
|
+
`--examples`
|
|
35
|
+
Use the suppliers and parts example database
|
|
36
|
+
|
|
37
|
+
`--db=DB`
|
|
38
|
+
Set the database (adapter) to use. Recognized values can be
|
|
39
|
+
folders with recognized files, or an URL to a SQL database
|
|
40
|
+
(e.g. postgres://user:pass@host/database)
|
|
41
|
+
|
|
42
|
+
`--stdin=READER`
|
|
43
|
+
Specify the kind of reader when reading on standard input
|
|
44
|
+
(i.e. rash, csv, json, ruby, or yaml)
|
|
45
|
+
|
|
46
|
+
`-Idirectory`
|
|
47
|
+
Specify $LOAD_PATH directory (may be used more than once)
|
|
48
|
+
|
|
49
|
+
`-rlibrary`
|
|
50
|
+
Require the specified ruby library, before executing alf
|
|
51
|
+
|
|
52
|
+
`--ff=FORMAT`
|
|
53
|
+
Specify the floating point format
|
|
54
|
+
|
|
55
|
+
`--[no-]pretty`
|
|
56
|
+
Enable/disable pretty print best effort
|
|
57
|
+
|
|
58
|
+
`-h`, `--help`
|
|
59
|
+
Show this help
|
|
60
|
+
|
|
61
|
+
`-v`, `--version`
|
|
62
|
+
Show version and copyright
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
`help`
|
|
67
|
+
Shows help about a specific command, relational operator, aggregator,
|
|
68
|
+
or predicate.
|
|
69
|
+
|
|
70
|
+
`show`
|
|
71
|
+
Evaluates a query and shows the result in a specified format.
|
|
72
|
+
|
|
73
|
+
`metadata`
|
|
74
|
+
Show metadata for a query (heading, keys).
|
|
75
|
+
|
|
76
|
+
`explain`
|
|
77
|
+
Show the logical (optimizer) and physical (compiler) plans of a query.
|
|
78
|
+
|
|
79
|
+
See `alf help COMMAND` for details about a specific command or `alf help
|
|
80
|
+
OPERATOR` for documentation of a relational operator.
|