Type-ARQuE example transformation: test/ssws2010/references.rq (versatile-compact)

SPARQL Query

SELECT *
WHERE {

  ?a ?b ?c
  ?c ?d ?e

}

Query translated into AQL

(aql-query ("triple_1_1" "triple_1_2")
           (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_1_2" predicate))
           (select "e" (property (string IRI double integer boolean datetime)
                                 "triple_1_2" object))
           (criterion (comp-eq (property (string IRI double integer boolean datetime)
                                         "triple_1_2" subject)
                               (property (string IRI double integer boolean datetime)
                                         "triple_1_1" object))))

Lowered and optimized AQL

(aql-query ("triple_1_1" "triple_1_2")
           (select "a" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INDEX VC_IRIs.{ix: id, value: iri_value, triple-table-column: subj(subject)} USING JOIN triple_1_1))
           (select "b" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INDEX VC_IRIs.{ix: id, value: iri_value, triple-table-column: pred(predicate)} USING JOIN triple_1_1))
           (select "c" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INDEX VC_IRIs.{ix: id, value: iri_value, triple-table-column: obj(object)} USING JOIN triple_1_1))
           (select "d" (custom (IRI)
                               FlexibleSQLLayout::SQLAccessExpr INDEX VC_IRIs.{ix: id, value: iri_value, triple-table-column: pred(predicate)} USING JOIN triple_1_2))
           (select "e" (function"builtin:coalesce" (string) ### variant [(string) (string) (string) (string) (string) (string) (string)] : (string)
                                                            (custom (string)
                                                                    FlexibleSQLLayout::SQLAccessExpr INDEX VC_Strings.{ix: id, value: str_value, triple-table-column: obj(object)} USING JOIN triple_1_2)
                                                            (custom (string)
                                                                    FlexibleSQLLayout::SQLAccessExpr INDEX VC_BigStrings.{ix: id, value: text_value, triple-table-column: obj(object)} USING JOIN triple_1_2)
                                                            (function"builtin:to-string" (string IRI double integer boolean datetime)
                                                                                         (custom (IRI)
                                                                                                 FlexibleSQLLayout::SQLAccessExpr INDEX VC_IRIs.{ix: id, value: iri_value, triple-table-column: obj(object)} USING JOIN triple_1_2))
                                                            (function"builtin:to-string" (string IRI double integer boolean datetime)
                                                                                         (custom (double)
                                                                                                 FlexibleSQLLayout::SQLAccessExpr INDEX VC_Doubles.{ix: id, value: double_value, triple-table-column: obj(object)} USING JOIN triple_1_2))
                                                            (function"builtin:to-string" (string IRI double integer boolean datetime)
                                                                                         (custom (integer)
                                                                                                 FlexibleSQLLayout::SQLAccessExpr INDEX VC_Integers.{ix: id, value: int_value, triple-table-column: obj(object)} USING JOIN triple_1_2))
                                                            (function"builtin:to-string" (string IRI double integer boolean datetime)
                                                                                         (custom (boolean)
                                                                                                 FlexibleSQLLayout::SQLAccessExpr INDEX VC_Booleans.{ix: id, value: boolean_value, triple-table-column: obj(object)} USING JOIN triple_1_2))
                                                            (function"builtin:to-string" (string IRI double integer boolean datetime)
                                                                                         (custom (datetime)
                                                                                                 FlexibleSQLLayout::SQLAccessExpr INDEX VC_Datetimes.{ix: id, value: datetime_value, triple-table-column: obj(object)} USING JOIN triple_1_2))))
           (criterion (function"builtin:comp-eq" (boolean) ### variant [(reference) (reference)] : (boolean)
                                                           (custom (integer)
                                                                   FlexibleSQLLayout::SQLAccessExpr INLINE subj USING JOIN triple_1_2)
                                                           (custom (integer)
                                                                   FlexibleSQLLayout::SQLAccessExpr INLINE obj USING JOIN triple_1_1)))
# Inference map = {
#  triple_1_1.subject: (IRI)
#  triple_1_1.predicate: (IRI)
#  triple_1_1.object: (IRI)
#  triple_1_2.subject: (IRI)
#  triple_1_2.predicate: (IRI)
#  triple_1_2.object: (string IRI double integer boolean datetime)
                       )

SQL

SELECT triple_1_1_subj_VC_IRIs.iri_value AS c0,
       triple_1_1_pred_VC_IRIs.iri_value AS c1,
       triple_1_1_obj_VC_IRIs.iri_value AS c2,
       triple_1_2_pred_VC_IRIs.iri_value AS c3,
       COALESCE(triple_1_2_obj_VC_Strings.str_value,triple_1_2_obj_VC_BigStrings.text_value,triple_1_2_obj_VC_IRIs.iri_value,CAST(triple_1_2_obj_VC_Doubles.double_value AS TEXT),CAST(triple_1_2_obj_VC_Integers.int_value AS TEXT),aqltosql_boolean_to_text(triple_1_2_obj_VC_Booleans.boolean_value),aqltosql_timestamp_to_text(triple_1_2_obj_VC_Datetimes.datetime_value)) AS c4
  FROM VC_Triples AS triple_1_1 CROSS JOIN VC_Triples AS triple_1_2
      INNER JOIN VC_IRIs AS triple_1_1_obj_VC_IRIs ON triple_1_1_obj_VC_IRIs.id=triple_1_1.obj
      INNER JOIN VC_IRIs AS triple_1_1_pred_VC_IRIs ON triple_1_1_pred_VC_IRIs.id=triple_1_1.pred
      INNER JOIN VC_IRIs AS triple_1_1_subj_VC_IRIs ON triple_1_1_subj_VC_IRIs.id=triple_1_1.subj
       LEFT JOIN VC_Strings AS triple_1_2_obj_VC_Strings ON triple_1_2_obj_VC_Strings.id=triple_1_2.obj
       LEFT JOIN VC_BigStrings AS triple_1_2_obj_VC_BigStrings ON triple_1_2_obj_VC_BigStrings.id=triple_1_2.obj
       LEFT JOIN VC_IRIs AS triple_1_2_obj_VC_IRIs ON triple_1_2_obj_VC_IRIs.id=triple_1_2.obj
       LEFT JOIN VC_Doubles AS triple_1_2_obj_VC_Doubles ON triple_1_2_obj_VC_Doubles.id=triple_1_2.obj
       LEFT JOIN VC_Integers AS triple_1_2_obj_VC_Integers ON triple_1_2_obj_VC_Integers.id=triple_1_2.obj
       LEFT JOIN VC_Booleans AS triple_1_2_obj_VC_Booleans ON triple_1_2_obj_VC_Booleans.id=triple_1_2.obj
       LEFT JOIN VC_Datetimes AS triple_1_2_obj_VC_Datetimes ON triple_1_2_obj_VC_Datetimes.id=triple_1_2.obj
      INNER JOIN VC_IRIs AS triple_1_2_pred_VC_IRIs ON triple_1_2_pred_VC_IRIs.id=triple_1_2.pred
 WHERE triple_1_2.subj=triple_1_1.obj

Execution result

| a                                 | b                                     | c                               | d                                               | e                                    |
========================================================================================================================================================================================================
| http://test1.aql-testdata/book3   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book1 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author1 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/book3   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/title               | The Great Book of Nonsense           |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/title               | The Great Book of Nonsense           |
| http://test1.aql-testdata/author1 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/title               | The Great Book of Nonsense           |
| http://test1.aql-testdata/book3   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/isbn                | 9-111-222-333                        |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/isbn                | 9-111-222-333                        |
| http://test1.aql-testdata/author1 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book1 | http://test1.aql-testdata/p/isbn                | 9-111-222-333                        |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book2 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book2 | http://test1.aql-testdata/p/title               | The Book of Blah                     |
| http://test1.aql-testdata/author2 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book2 | http://test1.aql-testdata/p/isbn                | 9-333-222-333                        |
| http://test1.aql-testdata/book5   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/book4   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book3 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/book5   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/title               | The Art of Foo                       |
| http://test1.aql-testdata/book4   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/title               | The Art of Foo                       |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/title               | The Art of Foo                       |
| http://test1.aql-testdata/book5   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/isbn                | 9-111-333-333                        |
| http://test1.aql-testdata/book4   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/isbn                | 9-111-333-333                        |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/isbn                | 9-111-333-333                        |
| http://test1.aql-testdata/author4 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://test1.aql-testdata/types/book |
| http://test1.aql-testdata/author4 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/title               | Bar-Master                           |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/title               | Bar-Master                           |
| http://test1.aql-testdata/author4 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/isbn                | 9-111-444-333                        |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/isbn                | 9-111-444-333                        |
| http://test1.aql-testdata/book5   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/sequel-of           | http://test1.aql-testdata/book1      |
| http://test1.aql-testdata/book4   | http://test1.aql-testdata/p/sequel-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/sequel-of           | http://test1.aql-testdata/book1      |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book3 | http://test1.aql-testdata/p/sequel-of           | http://test1.aql-testdata/book1      |
| http://test1.aql-testdata/author4 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/sequel-of           | http://test1.aql-testdata/book3      |
| http://test1.aql-testdata/author3 | http://test1.aql-testdata/p/author-of | http://test1.aql-testdata/book4 | http://test1.aql-testdata/p/sequel-of           | http://test1.aql-testdata/book3      |

32 rows