Type-ARQuE example transformation: test/ssws2010/untranslatable-up-down-filters.rq (simple-inline)

SPARQL Query

SELECT *
WHERE {
  ?a ?b ?c
  OPTIONAL {
    ?d ?e ?f
    FILTER(?i='abc')
    OPTIONAL {
      ?g ?h ?i
      FILTER(?c='def')
    }
  }
}

Query translated into AQL

(aql-query ("triple_1_1")
           (select "a" (property (string IRI double integer boolean datetime)
                                 "triple_1_1" subject))
           (select "b" (property (string IRI double integer boolean datetime)
                                 "triple_1_1" predicate))
           (select "c" (property (string IRI double integer boolean datetime)
                                 "triple_1_1" object))
           (select "d" (property (string IRI double integer boolean datetime)
                                 "triple_2_1" subject))
           (select "e" (property (string IRI double integer boolean datetime)
                                 "triple_2_1" predicate))
           (select "f" (property (string IRI double integer boolean datetime)
                                 "triple_2_1" object))
           (select "g" (property (string IRI double integer boolean datetime)
                                 "triple_3_1" subject))
           (select "h" (property (string IRI double integer boolean datetime)
                                 "triple_3_1" predicate))
           (select "i" (property (string IRI double integer boolean datetime)
                                 "triple_3_1" object))
           (join left ("triple_2_1")
                      (comp-eq (property (string IRI double integer boolean datetime)
                                         "triple_3_1" object)
                               (literal string "abc"))
                      (join left ("triple_3_1")
                                 (comp-eq (property (string IRI double integer boolean datetime)
                                                    "triple_1_1" object)
                                          (literal string "def"))))
           (criterion))

Lowered and optimized AQL

(aql-query ("triple_1_1")
           (select "a" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE subj_value USING JOIN triple_1_1))
           (select "b" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE pred_value USING JOIN triple_1_1))
           (select "c" (custom (string)
                               FlexibleSQLLayout::SQLAccessExpr INLINE obj_value USING JOIN triple_1_1))
           (select "d" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE subj_value USING JOIN triple_2_1))
           (select "e" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE pred_value USING JOIN triple_2_1))
           (select "f" (custom (string)
                               FlexibleSQLLayout::SQLAccessExpr INLINE obj_value USING JOIN triple_2_1))
           (select "g" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE subj_value USING JOIN triple_3_1))
           (select "h" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INLINE pred_value USING JOIN triple_3_1))
           (select "i" (custom (string)
                               FlexibleSQLLayout::SQLAccessExpr INLINE obj_value USING JOIN triple_3_1))
           (join left ("triple_2_1")
                      (function"builtin:comp-eq" (boolean) ### variant [(string) (string)] : (boolean)
                                                           (custom (string)
                                                                   FlexibleSQLLayout::SQLAccessExpr INLINE obj_value USING JOIN triple_3_1)
                                                           (literal string "abc"))
# Inference map = {
#  triple_2_1.subject: (IRI)
#  triple_2_1.predicate: (IRI)
#  triple_2_1.object: (string IRI double integer boolean datetime)
                                                            )
           (join left ("triple_3_1")
                      (function"builtin:and" (boolean) ### variant [(boolean) (boolean)] : (boolean)
                                                       (function"builtin:comp-eq" (boolean) ### variant [(string) (string)] : (boolean)
                                                                                            (custom (string)
                                                                                                    FlexibleSQLLayout::SQLAccessExpr INLINE obj_value USING JOIN triple_1_1)
                                                                                            (literal string "def"))
                                                       (function"builtin:is-not-null" (boolean) ### variant [(string IRI double integer boolean datetime)] : (boolean)
                                                                                                (custom (integer)
                                                                                                        FlexibleSQLLayout::SQLAccessExpr INLINE subj_value USING JOIN triple_2_1)))
# Inference map = {
#  triple_3_1.subject: (IRI)
#  triple_3_1.predicate: (IRI)
#  triple_3_1.object: (string)
                                                        )
           (criterion (literal boolean true))
# Inference map = {
#  triple_1_1.subject: (IRI)
#  triple_1_1.predicate: (IRI)
#  triple_1_1.object: (string IRI double integer boolean datetime)
                       )

SQL

SELECT triple_1_1.subj_value AS c0,
       triple_1_1.pred_value AS c1,
       triple_1_1.obj_value AS c2,
       triple_2_1.subj_value AS c3,
       triple_2_1.pred_value AS c4,
       triple_2_1.obj_value AS c5,
       triple_3_1.subj_value AS c6,
       triple_3_1.pred_value AS c7,
       triple_3_1.obj_value AS c8
  FROM InlinedTriples AS triple_1_1
       LEFT JOIN InlinedTriples AS triple_2_1 ON triple_3_1.obj_value='abc'
       LEFT JOIN InlinedTriples AS triple_3_1 ON triple_1_1.obj_value='def' AND triple_2_1.subj_value IS NOT NULL
 WHERE TRUE

Execution result