def test_sorted_descending(self):
   expected_sql = 'SELECT * FROM (%s) ORDER BY f1 DESC LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.sorted('f1', ascending=False), expected_sql)
 def test_sorted_with_fields(self):
   expected_sql = 'SELECT f1,f2 FROM (%s) ORDER BY f1 LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.sorted('f1', fields=['f1', 'f2']), expected_sql)
 def test_hashed_and_limited(self):
   expected_sql = 'SELECT * FROM (%s) ' \
                  'WHERE MOD(ABS(FARM_FINGERPRINT(CAST(f1 AS STRING))), 100) < 5 LIMIT 100' \
                  % TestCases.BASE_SQL
   self._apply_sampling(Sampling.hashed('f1', 5, count=100), expected_sql)
 def test_hashed_with_fields(self):
   expected_sql = 'SELECT f1 FROM (%s) ' \
                  'WHERE MOD(ABS(FARM_FINGERPRINT(CAST(f1 AS STRING))), 100) < 5' \
                  % TestCases.BASE_SQL
   self._apply_sampling(Sampling.hashed('f1', 5, fields=['f1']), expected_sql)
 def test_default_custom_fields(self):
   expected_sql = 'SELECT f1,f2 FROM (%s) LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(fields=['f1', 'f2']), expected_sql)
 def test_default_all_fields(self):
   expected_sql = 'SELECT * FROM (%s) LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(fields=[]), expected_sql)
Example #7
0
 def test_sorted_with_fields(self):
   expected_sql = 'SELECT f1,f2 FROM (%s) ORDER BY f1 LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.sorted('f1', fields=['f1', 'f2']), expected_sql)
 def test_default_custom_count(self):
   expected_sql = 'SELECT * FROM (%s) LIMIT 20' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(count=20), expected_sql)
Example #9
0
 def test_hashed_with_fields(self):
   expected_sql = 'SELECT f1 FROM (%s) WHERE MOD(FARM_FINGERPRINT(CAST(f1 AS STRING)), 100) < 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.hashed('f1', 5, fields=['f1']), expected_sql)
Example #10
0
 def test_sorted_descending(self):
   expected_sql = 'SELECT * FROM (%s) ORDER BY f1 DESC LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.sorted('f1', ascending=False), expected_sql)
Example #11
0
 def test_hashed_and_limited(self):
   expected_sql = 'SELECT * FROM (%s) WHERE MOD(FARM_FINGERPRINT(CAST(f1 AS STRING)), 100) < 5 LIMIT 100' \
                  % TestCases.BASE_SQL
   self._apply_sampling(Sampling.hashed('f1', 5, count=100), expected_sql)
Example #12
0
 def test_default_all_fields(self):
   expected_sql = 'SELECT * FROM (%s) LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(fields=[]), expected_sql)
Example #13
0
 def test_default_custom_fields(self):
   expected_sql = 'SELECT f1,f2 FROM (%s) LIMIT 5' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(fields=['f1', 'f2']), expected_sql)
Example #14
0
 def test_default_custom_count(self):
   expected_sql = 'SELECT * FROM (%s) LIMIT 20' % TestCases.BASE_SQL
   self._apply_sampling(Sampling.default(count=20), expected_sql)
 def test_hashed(self):
     expected_sql = 'SELECT * FROM (%s) ' \
                    'WHERE MOD(FARM_FINGERPRINT(CAST(f1 AS STRING)), 100) < 5' \
                    % TestCases.BASE_SQL
     self._apply_sampling(Sampling.hashed('f1', 5), expected_sql)