IITDBGroup / gprom

GProM is a middleware that adds support for provenance to database backends.
http://www.cs.iit.edu/%7edbgroup/research/gprom.php
Apache License 2.0
8 stars 5 forks source link

LATERAL rewrites treat integers as booleans #77

Open lordpretzel opened 3 years ago

lordpretzel commented 3 years ago

The LATERAL rewrites in lateral_prov_main.c use integers instead of booleans, but then treat these integers as booleans in selection conditions, e.g.,

Projection [a ] (a: DT_INT) [0x7fec08c0a07b]()
  Selection [nesting_eval_1] (a: DT_INT, b: DT_INT, nesting_eval_1: DT_BOOL) [0x7fec08c09e46](0x7fec08c0a07b)    NestingOperator[EXISTS] [] (a: DT_INT, b: DT_INT, nesting_eval_1: DT_BOOL) [0x7fec08c09c85](0x7fec08c09e4      TableAccess [r] (a: DT_INT, b: DT_INT) [0x7fec08c09184](0x7fec08c09c85)
      Projection [b ] (b: DT_INT) [0x7fec08c09504](0x7fec08c09c85)
        TableAccess [s] (c: DT_INT, d: DT_INT) [0x7fec08c09302](0x7fec08c09504)

is translated into

Projection [a ] (a: DT_INT) [0x7fec08a08268]()
  Selection [nesting_eval_1] (a: DT_INT, b: DT_INT, nesting_eval_1: DT_INT) [0x7fec08a08585](0x7fec08a08268)
    NestingOperator[LATERAL] [] (a: DT_INT, b: DT_INT, nesting_eval_1: DT_INT) [0x7fec08a086af](0x7fec08a0858      TableAccess [r] (a: DT_INT, b: DT_INT) [0x7fec08a087e2](0x7fec08a086af)
      Projection [(CASE  WHEN (AGGR_0 > 0) THEN 1 ELSE 0 END) ] (nesting_eval_1: DT_INT) [0x7fec08a0a22e](0x7        Aggregation [(COUNT(1))] (AGGR_0: DT_STRING) [0x7fec08a09af4](0x7fec08a0a22e)
          Projection [b ] (b: DT_INT) [0x7fec08a08932](0x7fec08a09af4)
            TableAccess [s] (c: DT_INT, d: DT_INT) [0x7fec08a08a0f](0x7fec08a08932)

We need to either change the rewrites to rewrite conditions into nesting_eval_xxx = 1 or use booleans instead (and for the Oracle serializer call the method the translates booleans in places where they are not allowed into comparisons).