Beispiel #1
0
 def test_select(self, source: frame.Queryable):
     """Select test."""
     assert source.select(source.score).selection[0] == source.score
     assert source.select(source.score,
                          source.surname).selection == (source.score,
                                                        source.surname)
     with pytest.raises(error.Syntax):
         source.select(
             source.reference().score)  # not subset of source columns
Beispiel #2
0
 def test_groupby(self, source: frame.Queryable):
     """Groupby test."""
     assert source.select(source.score.alias('foo')).groupby(
         source.score).grouping[0] == source.score
     assert source.select(source.score, source.surname).groupby(
         source.score, source.surname).grouping == (
             source.score,
             source.surname,
         )
     with pytest.raises(error.Syntax):
         source.select(source.score, source.surname).groupby(
             source.score)  # surname neither aggregate nor group
     with pytest.raises(error.Syntax):
         source.select(function.Count(source.score)).groupby(
             function.Count(source.score))  # grouping by aggregation
     assert source.select(source.score, function.Count(
         source.surname)).groupby(source.score)
     assert source.select(source.score,
                          function.Count(source.surname) + 1).groupby(
                              source.score)
     self._expression(source.select(source.score > 2),
                      lambda s, e: s.groupby(e), lambda q: q.grouping[0])