Sha256: 132ffc991cce6138512f0be8c3aeddb6ba08161b6ab35e096b242e625250a103

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

.TH Union
.PP
Logical OR
.SH Signature
.PP
.RS
.nf
union(left: Relation, right: Relation) -> Relation
.fi
.RE
.SH Examples
.PP
.RS
.nf
union(project(suppliers, [:city]), project(parts, [:city]))
.fi
.RE
.SH Description
.PP
Computes the relation as the set union of \fB\fCleft\fR and \fB\fCright\fR\&.
.PP
The \fB\fCleft\fR and \fB\fCright\fR relations must be union\-compatible, meaning that they
must have same heading (type inheritance is partly supported through ruby's
own type system, so that the actual behavior is slighlty more permissive).
.SH Implementation notes
.PP
Unlike SQL, this operator ALWAYS remove duplicates. There is no way, in
Alf, to compute \fIbags\fP of tuples and therefore no way to express something
such as SQL's UNION ALL.
.PP
The optimizer is not smart enough so far to discover when operands are
actually disjoint and duplicate removal not needed (e.g. the SQL compiler
never generates UNION ALL). Any patch improving this is welcome!
.PP
Similarly, it is sometimes idiomatic in Alf to use \fB\fCunion\fR as a logical OR,
as illustrated below. So far, the optimizer/compiler is not smart enough to
translate the former in the latter (which is likely to have a better query
plan, especially when using faithful SQL compilation and usual SQL DBMSs).
Any patch is welcome here too!
.PP
.RS
.nf
union(
  restrict(suppliers, city: 'Paris'),
  restrict(suppliers, city: 'London'))
.fi
.RE
.PP
is equivalent to
.PP
.RS
.nf
restrict(suppliers, eq(:city, 'Paris') | eq(:city, 'London'))
.fi
.RE

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alf-shell-0.16.4 doc/man/union.man
alf-shell-0.16.0 doc/man/union.man
alf-shell-0.15.0 doc/man/union.man