Ejemplo n.º 1
0
 def test_join_with_index(self):
     """
     Test Join operation with index
     """
     R = Table.inputfromfile('test_csv/real_sales1.csv')
     S = Table.inputfromfile('test_csv/real_sales1.csv')
     start = time.time()
     R1 = Table.join(R, S, 'R', 'S', 'R.pricerange = S.pricerange')
     end = time.time()
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertEqual(row['R_pricerange'], row['S_pricerange'])
     without_index = end - start
     Table.Hash(R, 'pricerange')
     Table.Hash(S, 'pricerange')
     start = time.time()
     R1 = Table.join(R, S, 'R', 'S', 'R.pricerange = S.pricerange')
     end = time.time()
     with_index = end - start
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertEqual(row['R_pricerange'], row['S_pricerange'])
     self.assertLess(with_index, without_index*0.9)
     start = time.time()
     R1 = Table.join(R, S, 'R', 'S', 'S.pricerange = R.pricerange')
     end = time.time()
     with_index = end - start
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertEqual(row['R_pricerange'], row['S_pricerange'])
     self.assertLess(with_index, without_index*0.9)
Ejemplo n.º 2
0
 def test_join_with_greater(self):
     '''Test join wtih condition: R.qty > S.Q'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     S = Table.inputfromfile('test_csv/sales2.csv')
     R1 = Table.join(R, S, 'R', 'S', 'R.qty >S.Q')
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertIsNotNone(row['R_qty'], row['S_Q'])
         self.assertGreater(row['R_qty'], row['S_Q'])
Ejemplo n.º 3
0
 def test_join_with_same_customerid(self):
     """Test join wtih condition: R.customerid = S.C"""
     R = Table.inputfromfile('test_csv/sales1.csv')
     S = Table.inputfromfile('test_csv/sales2.csv')
     R1 = Table.join(R, S, 'R', 'S', 'R.customerid=S.C')
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertIsNotNone(row['R_customerid'], row['S_C'])
         self.assertEqual(row['R_customerid'], row['S_C'])
Ejemplo n.º 4
0
 def test_join_with_same_princerage(self):
     '''Test join wtih condition: R.pricerange = S.P'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     S = Table.inputfromfile('test_csv/sales2.csv')
     R1 = Table.join(R, S, 'R', 'S', 'R.pricerange = S.P')
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertIsNotNone(row['R_pricerange'], row['S_P'])
         self.assertEqual(row['R_pricerange'], row['S_P'])
Ejemplo n.º 5
0
 def test_join_with_multiple_condtion(self):
     '''Test join wtih condition: (R.qty >= S.Q) and (R.pricerange = S.P)'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     S = Table.inputfromfile('test_csv/sales2.csv')
     R1 = Table.join(R, S, 'R', 'S', '(R.qty >= S.Q) and (R.pricerange = S.P)')
     self.assertIsNotNone(R1.table)
     for row in R1.table:
         self.assertIsNotNone(row['R_qty'], row['S_Q'])
         self.assertGreaterEqual(row['R_qty'], row['S_Q'])
         self.assertIsNotNone(row['R_pricerange'], row['S_P'])
         self.assertEqual(row['R_pricerange'], row['S_P'])
Ejemplo n.º 6
0
 def test_join_column_name(self):
     '''Test join wtih the output column name'''
     R = Table.inputfromfile('test_csv/sales1.csv')
     S = Table.inputfromfile('test_csv/sales2.csv')
     R1 = Table.join(R, S, 'R1', 'S1', 'True')
     self.assertIsNotNone(R1.table)
     keyset = R1.table[0].keys()
     for key in R.table[0].keys():
         new_key = 'R1_{}'.format(key)
         self.assertTrue(new_key in keyset)
     for key in S.table[0].keys():
         new_key = 'S1_{}'.format(key)
         self.assertTrue(new_key in keyset)