On Mon, Sep 22, 2014 at 7:28 AM, David Mertens <dcmertens.p...@gmail.com> wrote:
>> On Sep 18, 2014, at 3:31 PM, Vered Caspi <vere...@bgu.ac.il> wrote:
>>
>> I am new to PDL, and I wonder whether it is possible to do SQL-like
>> operations in PDL.
>> For example, is it possible to join (merge) tables? To use inner join,
>> left outer join etc?
>> Is it possible to concatenate tables, like R's rbind and cbind?

> You should also know that performing a "query" on a piddle is quite
> straight-forward with the "where" and "which" methods.

For whatever it's worth, I've started in on preliminary work on what
I've been calling "PQL" (in homage to PDL), which attempts to allow
the user to build complex SQL queries directly in Perl using Perl
operators as their nearest Relational Algebra / Tuple Relational
Calculus equivalents.

Unfortunately, I don't have a convenient synopsis of the full desired
functionality at hand. For example, though:

use PQL;

my $dbh = PQL->connect(‘dbi:Oracle:SCOTT’,’scott’,’tiger’);
my $emp = $dbh->(‘employees’);
my $dep = $dbh->(‘departments’);

my $whoin = $emp | $dep; # Inner Join
my $mfg_sth = $whoin->{ department_name => ‘Manufacturing’ }->execute;

my $no_raises_sth = $emp > $dbh->('raises_given')->execute; # antijoin

The set of supported operators is going to include something like ...

$t1 | $t2 # inner join
$t1 || $t2 # left outer join
$t1 . $t # full outer join
$t1 * $t2 # natural join / fiber product
$t1 x $t2 # cross join
$t1 > $t2 # antijoin
$t1 / $t2 # relational division
$t1 + $t2 # union
$t1 - $t2 # except
$t1 & $t2 # intersection

... plus additional chaining methods similar to IO::All for
controlling things like special-case joins, grouping, ordering,
selection, projection, renaming, extension, and so on.

I don't expect it to be ready for even a limited alpha release any
time soon, but the topic of this thread made me suspect it was time
for a preliminary pre-announcement.


--
P/PW/PWBENNETT

_______________________________________________
Perldl mailing list
Perldl@jach.hawaii.edu
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to