Ejemplo n.º 1
0
    def test_selection__projection__sort(self):
        result = parse_and_execute([
            ["SORT", ["name"]],
            ["PROJECTION", ["name"]],
            [
                "SELECTION",
                ["age", "EQUALS", "33", "AND", "major", "EQUALS", "econ"]
            ],
            ["SCAN", self._data],
        ])
        expected = [
            ("Carolyn", ),
            ("Jason", ),
        ]
        self.assertEquals(result, expected)

        result = parse_and_execute([
            ["SORT", ["name"]],
            ["PROJECTION", ["id", "name"]],
            [
                "SELECTION",
                ["age", "EQUALS", "33", "AND", "major", "EQUALS", "econ"]
            ],
            ["SCAN", self._data],
        ])
        expected = [
            (
                "5",
                "Carolyn",
            ),
            (
                "2",
                "Jason",
            ),
        ]
        self.assertEquals(result, expected)

        result = parse_and_execute([
            ["SORT", ["id"]],
            ["PROJECTION", ["id", "name"]],
            [
                "SELECTION",
                ["age", "EQUALS", "33", "AND", "major", "EQUALS", "econ"]
            ],
            ["SCAN", self._data],
        ])
        expected = [
            (
                "2",
                "Jason",
            ),
            (
                "5",
                "Carolyn",
            ),
        ]
        self.assertEquals(result, expected)
Ejemplo n.º 2
0
 def test_selection__equals(self):
     result = parse_and_execute([
         ["SELECTION", ["id", "EQUALS", "1"]],
         ["SCAN", self._data],
     ])
     expected = [
         self._data[1],
     ]
     self.assertEquals(result, expected)
Ejemplo n.º 3
0
 def test_filescan(self):
     result = parse_and_execute([
         ["DISTINCT", [""]],
         ["PROJECTION", ["movieId", "title"]],
         ["SELECTION", ["movieId", "EQUALS", "33"]],
         ["FILESCAN", FILE_PATH],
     ])
     expected = [
         ['33', 'Wings of Courage (1995)'],
     ]
     self.assertEquals(result, expected)
Ejemplo n.º 4
0
 def test_selection__equals__and(self):
     result = parse_and_execute([
         [
             "SELECTION",
             ["age", "EQUALS", "33", "AND", "major", "EQUALS", "econ"]
         ],
         ["SCAN", self._data],
     ])
     expected = [
         self._data[2],
         self._data[5],
     ]
     self.assertEquals(result, expected)
Ejemplo n.º 5
0
 def test_selection__projection__duplicates(self):
     result = parse_and_execute([
         ["PROJECTION", ["age"]],
         [
             "SELECTION",
             ["age", "EQUALS", "33", "AND", "major", "EQUALS", "econ"]
         ],
         ["SCAN", self._data],
     ])
     expected = [
         ["33"],
         ["33"],
     ]
     self.assertEquals(result, expected)
Ejemplo n.º 6
0
 def test_none(self):
     result = parse_and_execute([])
     expected = None
     self.assertEquals(result, expected)