Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 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)
Ejemplo n.º 8
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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)