Ejemplo n.º 1
0
    def test_sql_query(self):
        """Test the SqlQuery class."""
        q = SqlQuery("my_table", COLS, DTYPES, "alias")
        self.assertEqual(q.order, ["alias"])
        self.assertEqual(q.tables, {"alias": "my_table"})
        self.assertEqual(q._columns, {"alias": EXPANDED_COLS})
        self.assertEqual(q.datatypes, {"alias": EXPANDED_DTYPES})
        self.assertEqual(q.condition, None)

        # test WHERE
        c1 = EqualsCondition("my_table", "1", VALS[0], DTYPES["1"])
        c2 = EqualsCondition("my_table", "2", VALS[1], DTYPES["2"])
        c21 = EqualsCondition("my_table", "2___0", VALS[1][0],
                              EXPANDED_DTYPES["2___0"])
        c22 = EqualsCondition("my_table", "2___1", VALS[1][1],
                              EXPANDED_DTYPES["2___1"])
        c3 = EqualsCondition("my_table", "3", VALS[2], DTYPES["2"])
        c3 = AndCondition(c1, c2, c3)
        q.where(c1)
        self.assertEqual(q.condition, c1)
        q.condition = None
        q.where(c2)
        self.assertIsInstance(q.condition, AndCondition)
        self.assertEqual(len(q.condition.conditions), 2)
        self.assertEqual(q.condition, AndCondition(c21, c22))
        q.condition = None
        q.where(c1)
        q.where(c2)
        self.assertIsInstance(q.condition, AndCondition)
        self.assertEqual(len(q.condition.conditions), 3)
        self.assertEqual(q.condition, AndCondition(c1, c21, c22))
        q.condition = None
        q.where(c2)
        q.where(c1)
        self.assertIsInstance(q.condition, AndCondition)
        self.assertEqual(len(q.condition.conditions), 3)
        self.assertEqual(q.condition, AndCondition(c1, c21, c22))
        q.condition = None
        q.where(c1)
        q.where(c1)
        self.assertIsInstance(q.condition, AndCondition)
        self.assertEqual(len(q.condition.conditions), 1)
        self.assertEqual(q.condition, AndCondition(c1))

        # test JOIN
        c4 = JoinCondition("alias", "1", "alias2", "1")
        q.join("2ndTable", COLS, DTYPES, alias="alias2")
        self.assertEqual(q.order, ["alias", "alias2"])
        self.assertEqual(q.tables, {"alias": "my_table", "alias2": "2ndTable"})
        self.assertEqual(q._columns, {
            "alias": EXPANDED_COLS,
            "alias2": EXPANDED_COLS
        })
        self.assertEqual(q.datatypes, {
            "alias": EXPANDED_DTYPES,
            "alias2": EXPANDED_DTYPES
        })
        self.assertEqual(q.condition, AndCondition(c1))
        q.where(c4)
        self.assertEqual(q.condition, AndCondition(c1, c4))
 def test_construct_remove_condition(self):
     """Test construction a remove condition."""
     # from rel table
     r = sorted(self.session._queries(
         pattern=(iri_from_uid(uuid.UUID(int=1)), city.hasInhabitant.iri,
                  iri_from_uid(uuid.UUID(int=2))),
         mode="delete"),
                key=lambda x: x[1])
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0][1], RELATIONSHIP_TABLE)
     self.assertEqual(r[0][2], rdflib.XSD.integer)
     self.assertEqual(
         r[0][0],
         AndCondition(
             EqualsCondition(RELATIONSHIP_TABLE, "s", 1,
                             rdflib.XSD.integer),
             EqualsCondition(RELATIONSHIP_TABLE, "p", 42,
                             rdflib.XSD.integer),
             EqualsCondition(RELATIONSHIP_TABLE, "o", 2,
                             rdflib.XSD.integer)))
     # from types table
     r = sorted(self.session._queries(pattern=(iri_from_uid(
         uuid.UUID(int=1)), rdflib.RDF.type, city.City.iri),
                                      mode="delete"),
                key=lambda x: x[1])
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0][1], TYPES_TABLE)
     self.assertEqual(r[0][2], rdflib.XSD.integer)
     self.assertEqual(
         r[0][0],
         AndCondition(
             EqualsCondition(TYPES_TABLE, "s", 1, rdflib.XSD.integer),
             EqualsCondition(TYPES_TABLE, "o", 42, rdflib.XSD.integer)))
Ejemplo n.º 3
0
    def test_check_characters(self):
        """Test character check."""
        c1 = EqualsCondition("c", "d", "e", rdflib.XSD.string)
        c2 = EqualsCondition("c;", "d", "e", rdflib.XSD.string)
        c3 = EqualsCondition("c", "d;", "e", rdflib.XSD.string)
        c4 = JoinCondition("g", "h", "i", "j")
        c5 = JoinCondition("g;", "h", "i", "j")
        c6 = JoinCondition("g", "h;", "i", "j")
        c7 = JoinCondition("g", "h", "i;", "j")
        c8 = JoinCondition("g", "h", "i", "j;")
        x = {"key": ["a", ("b", AndCondition(c1, c4))]}
        x1 = {"key;": ["a", ("b", AndCondition(c1, c4))]}
        x2 = {"key": ["a;", ("b", AndCondition(c1, c4))]}
        x3 = {"key": ["a", ("b;", AndCondition(c1, c4))]}

        x4 = {"key": ["a", ("b", AndCondition(c2, c4))]}
        x5 = {"key": ["a", ("b", AndCondition(c3, c4))]}

        x6 = {"key": ["a", ("b", AndCondition(c1, c5))]}
        x7 = {"key": ["a", ("b", AndCondition(c1, c6))]}
        x8 = {"key": ["a", ("b", AndCondition(c1, c7))]}
        x9 = {"key": ["a", ("b", AndCondition(c1, c8))]}
        check_characters(x)
        self.assertRaises(ValueError, check_characters, x1)
        self.assertRaises(ValueError, check_characters, x2)
        self.assertRaises(ValueError, check_characters, x3)
        self.assertRaises(ValueError, check_characters, x4)
        self.assertRaises(ValueError, check_characters, x5)
        self.assertRaises(ValueError, check_characters, x6)
        self.assertRaises(ValueError, check_characters, x7)
        self.assertRaises(ValueError, check_characters, x8)
        self.assertRaises(ValueError, check_characters, x9)
Ejemplo n.º 4
0
 def _get_entity_idx(self, ns_idx, name):
     c = self._default_select(
         self.ENTITIES_TABLE,
         condition=AndCondition(
             EqualsCondition(
                 self.ENTITIES_TABLE,
                 "ns_idx",
                 ns_idx,
                 datatype=rdflib.XSD.integer,
             ),
             EqualsCondition(
                 self.ENTITIES_TABLE,
                 "name",
                 name,
                 datatype=rdflib.XSD.string,
             ),
         ),
     )
     for entity_idx, ns_idx, name in c:
         return entity_idx
     return self._do_db_insert(
         table_name=self.ENTITIES_TABLE,
         columns=["ns_idx", "name"],
         values=[ns_idx, name],
         datatypes=self.DATATYPES[self.ENTITIES_TABLE],
     )
Ejemplo n.º 5
0
    def _get_conditions(self, triple, table_name, object_datatype):
        conditions = []
        s, p, o = triple

        if s is not None:
            uid = self._split_namespace(s)
            conditions += [EqualsCondition("ts", "uid", uid, "UUID")]

        if p is not None and table_name != self.TYPES_TABLE:
            ns_idx, name = self._split_namespace(p)
            conditions += [
                EqualsCondition("tp", "ns_idx", ns_idx, rdflib.XSD.integer),
                EqualsCondition("tp", "name", name, rdflib.XSD.string)
            ]

        if o is not None and table_name == self.RELATIONSHIP_TABLE:
            uid = self._split_namespace(o)
            conditions += [EqualsCondition("to", "uid", uid, "UUID")]

        elif o is not None and table_name == self.TYPES_TABLE:
            ns_idx, name = self._split_namespace(o)
            conditions += [
                EqualsCondition("to", "ns_idx", ns_idx, rdflib.XSD.integer),
                EqualsCondition("to", "name", name, rdflib.XSD.string)
            ]

        elif o is not None:
            conditions += [
                EqualsCondition(table_name, "o", o.toPython(), object_datatype)
            ]

        return AndCondition(*conditions)
Ejemplo n.º 6
0
    def _construct_remove_condition(self, pattern, table, object_datatype):
        conditions = list()
        s, p, o = pattern
        if s is not None:
            s = self._get_cuds_idx(self._split_namespace(s))
            conditions += [
                EqualsCondition(table,
                                column="s",
                                value=s,
                                datatype=rdflib.XSD.integer)
            ]
        if table == self.TYPES_TABLE:
            if o is not None:
                o = self._get_entity_idx(*self._split_namespace(o))
                conditions += [
                    EqualsCondition(table,
                                    column="o",
                                    value=o,
                                    datatype=rdflib.XSD.integer)
                ]
            return AndCondition(*conditions)

        if p is not None:
            p = self._get_entity_idx(*self._split_namespace(p))
            conditions += [
                EqualsCondition(table,
                                column="p",
                                value=p,
                                datatype=rdflib.XSD.integer)
            ]

        if o is not None:
            o = o.toPython()
            if table == self.RELATIONSHIP_TABLE:
                o = self._get_cuds_idx(self._split_namespace(o))
            conditions += [
                EqualsCondition(table,
                                column="o",
                                value=o,
                                datatype=object_datatype)
            ]
        return AndCondition(*conditions)
Ejemplo n.º 7
0
 def _get_cuds_idx(self, uid):
     c = self._default_select(self.CUDS_TABLE,
                              condition=EqualsCondition(self.CUDS_TABLE,
                                                        "uid",
                                                        uid,
                                                        datatype="UUID"))
     for cuds_idx, uid in c:
         return cuds_idx
     return self._do_db_insert(
         table_name=self.CUDS_TABLE,
         columns=["uid"],
         values=[uid],
         datatypes=self.DATATYPES[self.CUDS_TABLE],
     )
    def test_queries_subject_given(self):
        """Test computing the queries corresponding to a triple pattern."""
        r = sorted(
            self.session._queries(pattern=(iri_from_uid(uuid.UUID(int=1)),
                                           None, None)),
            key=lambda x: x[1])
        self.assertEqual(len(r), 4)
        self.assertEqual(r[0][1], data_tbl("VECTOR-2-2"))
        self.assertEqual(r[1][1], data_tbl("XSD_string"))
        self.assertEqual(r[2][1], RELATIONSHIP_TABLE)
        self.assertEqual(r[3][1], TYPES_TABLE)
        self.assertEqual(r[0][2], rdflib_cuba["_datatypes/VECTOR-2-2"])
        self.assertEqual(r[1][2], rdflib.XSD.string)
        self.assertEqual(r[2][2], rdflib.XSD.integer)
        self.assertEqual(r[3][2], rdflib.XSD.integer)
        self.assertEqual(r[0][0].order, ["ts", "tp", data_tbl("VECTOR-2-2")])

        # first query
        self.assertEqual(
            r[0][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                data_tbl("VECTOR-2-2"): ["o___0", "o___1", "o___2", "o___3"]
            })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(data_tbl("VECTOR-2-2"), "s", "ts", "cuds_idx"),
                JoinCondition(data_tbl("VECTOR-2-2"), "p", "tp", "entity_idx"),
                EqualsCondition("ts", "uid", str(uuid.UUID(int=1)), "UUID")))
        self.assertEqual(
            r[0][0].datatypes, {
                data_tbl("VECTOR-2-2"): {
                    "o": rdflib_cuba["_datatypes/VECTOR-2-2"],
                    "o___0": rdflib.XSD.float,
                    "o___1": rdflib.XSD.float,
                    "o___2": rdflib.XSD.float,
                    "o___3": rdflib.XSD.float
                },
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                }
            })
        self.assertEqual(
            r[0][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                data_tbl("VECTOR-2-2"): data_tbl("VECTOR-2-2")
            })

        # second query
        self.assertEqual(r[1][0]._columns, {
            "ts": ["uid"],
            "tp": ["ns_idx", "name"],
            data_tbl("XSD_string"): ["o"]
        })
        self.assertEqual(
            r[1][0].condition,
            AndCondition(
                JoinCondition(data_tbl("XSD_string"), "s", "ts", "cuds_idx"),
                JoinCondition(data_tbl("XSD_string"), "p", "tp", "entity_idx"),
                EqualsCondition("ts", "uid", str(uuid.UUID(int=1)), "UUID")))
        self.assertEqual(
            r[1][0].datatypes, {
                data_tbl("XSD_string"): {
                    "o": rdflib.XSD.string
                },
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                }
            })
        self.assertEqual(
            r[1][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                data_tbl("XSD_string"): data_tbl("XSD_string")
            })

        # third query
        self.assertEqual(
            r[2][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                RELATIONSHIP_TABLE: [],
                "to": ["uid"]
            })
        self.assertEqual(
            r[2][0].condition,
            AndCondition(
                JoinCondition(RELATIONSHIP_TABLE, "s", "ts", "cuds_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "p", "tp", "entity_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "o", "to", "cuds_idx"),
                EqualsCondition("ts", "uid", str(uuid.UUID(int=1)), "UUID")))
        self.assertEqual(
            r[2][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                "to": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                RELATIONSHIP_TABLE: {}
            })
        self.assertEqual(
            r[2][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                "to": CUDS_TABLE,
                RELATIONSHIP_TABLE: RELATIONSHIP_TABLE
            })

        # fourth query
        self.assertEqual(r[3][0]._columns, {
            "ts": ["uid"],
            TYPES_TABLE: [],
            "to": ["ns_idx", "name"]
        })
        self.assertEqual(
            r[3][0].condition,
            AndCondition(
                JoinCondition(TYPES_TABLE, "s", "ts", "cuds_idx"),
                JoinCondition(TYPES_TABLE, "o", "to", "entity_idx"),
                EqualsCondition("ts", "uid", str(uuid.UUID(int=1)), "UUID")))
        self.assertEqual(
            r[3][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "to": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                TYPES_TABLE: {}
            })
        self.assertEqual(r[3][0].tables, {
            "ts": CUDS_TABLE,
            "to": ENTITIES_TABLE,
            TYPES_TABLE: TYPES_TABLE
        })
    def test_queries_object_given(self):
        """Test the _queries method when the object is given."""
        # type given
        r = sorted(self.session._queries(pattern=(None, None, city.City.iri)),
                   key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(r[0][1:], (TYPES_TABLE, rdflib.XSD.integer))
        self.assertEqual(r[0][0]._columns, {
            "ts": ["uid"],
            "to": ["ns_idx", "name"],
            TYPES_TABLE: []
        })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(TYPES_TABLE, "s", "ts", "cuds_idx"),
                JoinCondition(TYPES_TABLE, "o", "to", "entity_idx"),
                EqualsCondition("to", "ns_idx", 2, rdflib.XSD.integer),
                EqualsCondition("to", "name", "City", rdflib.XSD.string)))
        self.assertEqual(
            r[0][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "to": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                TYPES_TABLE: {}
            })
        self.assertEqual(r[0][0].tables, {
            "ts": CUDS_TABLE,
            "to": ENTITIES_TABLE,
            TYPES_TABLE: TYPES_TABLE
        })

        # UUID given
        r = sorted(
            self.session._queries(pattern=(None, None,
                                           iri_from_uid(uuid.UUID(int=1)))),
            key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(r[0][1:], (RELATIONSHIP_TABLE, rdflib.XSD.integer))
        self.assertEqual(
            r[0][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                RELATIONSHIP_TABLE: [],
                "to": ["uid"]
            })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(RELATIONSHIP_TABLE, "s", "ts", "cuds_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "p", "tp", "entity_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "o", "to", "cuds_idx"),
                EqualsCondition("to", "uid", str(uuid.UUID(int=1)), "UUID")))
        self.assertEqual(
            r[0][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                "to": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                RELATIONSHIP_TABLE: {}
            })
        self.assertEqual(
            r[0][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                "to": CUDS_TABLE,
                RELATIONSHIP_TABLE: RELATIONSHIP_TABLE
            })
Ejemplo n.º 10
0
    def test_queries_predicate_given(self):
        """Test the _queries method with a given relationship."""
        # object property
        r = sorted(self.session._queries(pattern=(None,
                                                  cuba.activeRelationship.iri,
                                                  None)),
                   key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(r[0][1:], (RELATIONSHIP_TABLE, rdflib.XSD.integer))
        self.assertEqual(
            r[0][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                RELATIONSHIP_TABLE: [],
                "to": ["uid"]
            })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(RELATIONSHIP_TABLE, "s", "ts", "cuds_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "p", "tp", "entity_idx"),
                JoinCondition(RELATIONSHIP_TABLE, "o", "to", "cuds_idx"),
                EqualsCondition("tp", "ns_idx", 1, rdflib.XSD.integer),
                EqualsCondition("tp", "name", "activeRelationship",
                                rdflib.XSD.string)))
        self.assertEqual(
            r[0][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                "to": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                RELATIONSHIP_TABLE: {}
            })
        self.assertEqual(
            r[0][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                "to": CUDS_TABLE,
                RELATIONSHIP_TABLE: RELATIONSHIP_TABLE
            })

        # type
        r = sorted(self.session._queries(pattern=(None, rdflib.RDF.type,
                                                  None)),
                   key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(r[0][1:], (TYPES_TABLE, rdflib.XSD.integer))
        self.assertEqual(r[0][0]._columns, {
            "ts": ["uid"],
            TYPES_TABLE: [],
            "to": ["ns_idx", "name"]
        })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(JoinCondition(TYPES_TABLE, "s", "ts", "cuds_idx"),
                         JoinCondition(TYPES_TABLE, "o", "to", "entity_idx")))
        self.assertEqual(
            r[0][0].datatypes, {
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "to": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                },
                TYPES_TABLE: {}
            })
        self.assertEqual(r[0][0].tables, {
            "ts": CUDS_TABLE,
            "to": ENTITIES_TABLE,
            TYPES_TABLE: TYPES_TABLE
        })

        # data
        r = sorted(self.session._queries(pattern=(None, city.coordinates.iri,
                                                  None)),
                   key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(
            r[0][1:],
            (data_tbl("VECTOR-INT-2"), rdflib_cuba["_datatypes/VECTOR-INT-2"]))
        self.assertEqual(
            r[0][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                data_tbl("VECTOR-INT-2"): ["o___0", "o___1"]
            })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(data_tbl("VECTOR-INT-2"), "s", "ts", "cuds_idx"),
                JoinCondition(data_tbl("VECTOR-INT-2"), "p", "tp",
                              "entity_idx"),
                EqualsCondition("tp", "ns_idx", 2, rdflib.XSD.integer),
                EqualsCondition("tp", "name", "coordinates",
                                rdflib.XSD.string)))
        self.assertEqual(
            r[0][0].datatypes, {
                data_tbl("VECTOR-INT-2"): {
                    "o": rdflib_cuba["_datatypes/VECTOR-INT-2"],
                    "o___1": rdflib.XSD.integer,
                    "o___0": rdflib.XSD.integer
                },
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                }
            })
        self.assertEqual(
            r[0][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                data_tbl("VECTOR-INT-2"): data_tbl("VECTOR-INT-2")
            })

        # data with value
        dtype = rdflib_cuba["_datatypes/VECTOR-INT-2"]
        r = sorted(self.session._queries(
            pattern=(None, city.coordinates.iri,
                     rdflib.Literal(np.array([1, 1]), datatype=dtype))),
                   key=lambda x: x[1])
        self.assertEqual(len(r), 1)
        self.assertEqual(
            r[0][1:],
            (data_tbl("VECTOR-INT-2"), rdflib_cuba["_datatypes/VECTOR-INT-2"]))
        self.assertEqual(
            r[0][0]._columns, {
                "ts": ["uid"],
                "tp": ["ns_idx", "name"],
                data_tbl("VECTOR-INT-2"): ["o___0", "o___1"]
            })
        self.assertEqual(
            r[0][0].condition,
            AndCondition(
                JoinCondition(data_tbl("VECTOR-INT-2"), "s", "ts", "cuds_idx"),
                JoinCondition(data_tbl("VECTOR-INT-2"), "p", "tp",
                              "entity_idx"),
                EqualsCondition("tp", "ns_idx", 2, rdflib.XSD.integer),
                EqualsCondition("tp", "name", "coordinates",
                                rdflib.XSD.string),
                AndCondition(
                    EqualsCondition(data_tbl("VECTOR-INT-2"), "o___0", 1,
                                    rdflib.XSD.integer),
                    EqualsCondition(data_tbl("VECTOR-INT-2"), "o___1", 1,
                                    rdflib.XSD.integer),
                )))
        self.assertEqual(
            r[0][0].datatypes, {
                data_tbl("VECTOR-INT-2"): {
                    "o": rdflib_cuba["_datatypes/VECTOR-INT-2"],
                    "o___0": rdflib.XSD.integer,
                    "o___1": rdflib.XSD.integer
                },
                "ts": {
                    "uid": "UUID",
                    "cuds_idx": rdflib.XSD.integer
                },
                "tp": {
                    "name": rdflib.XSD.string,
                    "ns_idx": rdflib.XSD.integer,
                    "entity_idx": rdflib.XSD.integer
                }
            })
        self.assertEqual(
            r[0][0].tables, {
                "ts": CUDS_TABLE,
                "tp": ENTITIES_TABLE,
                data_tbl("VECTOR-INT-2"): data_tbl("VECTOR-INT-2")
            })