فهرست منبع

HUE-1565 [beeswax] Adding tests to multi partition support

Romain Rigaux 12 سال پیش
والد
کامیت
a2c5273
2فایلهای تغییر یافته به همراه17 افزوده شده و 6 حذف شده
  1. 1 5
      apps/beeswax/src/beeswax/server/hive_server2_lib.py
  2. 16 1
      apps/beeswax/src/beeswax/tests.py

+ 1 - 5
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -555,11 +555,7 @@ class PartitionValueCompatible:
 
 
   def __init__(self, partition, table):
   def __init__(self, partition, table):
     # Parses: ['datehour=2013022516'] or ['month=2011-07/dt=2011-07-01/hr=12']
     # Parses: ['datehour=2013022516'] or ['month=2011-07/dt=2011-07-01/hr=12']
-    self.values = []
-    for part in partition:
-      parts = part.split('/')
-      for val in parts:
-        self.values.append(val.split('=')[1])
+    self.values = [val.split('=')[1] for part in partition for val in part.split('/')]
     self.sd = type('Sd', (object,), {'location': '%s/%s' % (table.path_location, ','.join(partition)),})
     self.sd = type('Sd', (object,), {'location': '%s/%s' % (table.path_location, ','.join(partition)),})
 
 
 
 

+ 16 - 1
apps/beeswax/src/beeswax/tests.py

@@ -55,7 +55,8 @@ from beeswax.data_export import download
 from beeswax.models import SavedQuery, QueryHistory, HQL
 from beeswax.models import SavedQuery, QueryHistory, HQL
 from beeswax.server import dbms
 from beeswax.server import dbms
 from beeswax.server.dbms import QueryServerException
 from beeswax.server.dbms import QueryServerException
-from beeswax.server.hive_server2_lib import HiveServerClient
+from beeswax.server.hive_server2_lib import HiveServerClient,\
+  PartitionValueCompatible
 from beeswax.test_base import BeeswaxSampleProvider
 from beeswax.test_base import BeeswaxSampleProvider
 
 
 
 
@@ -1436,6 +1437,20 @@ def test_split_statements():
   assert_equal(['select', "select * where id == '\"10;\"\"\"' limit 100"], hql_query("select; select * where id == '\"10;\"\"\"' limit 100;").statements)
   assert_equal(['select', "select * where id == '\"10;\"\"\"' limit 100"], hql_query("select; select * where id == '\"10;\"\"\"' limit 100;").statements)
 
 
 
 
+class MockHiveServerTable():
+
+  def __init__(self, data):
+    self.path_location = data.get('path_location')
+
+
+class TestHiveServer2API():
+
+  def test_partition_values(self):
+    table = MockHiveServerTable({'path_location': '/my/table'})
+
+    assert_equal(['2013022516'], PartitionValueCompatible(['datehour=2013022516'], table).values)
+    assert_equal(['2011-07', '2011-07-01', '12'], PartitionValueCompatible(['month=2011-07/dt=2011-07-01/hr=12'], table).values)
+
 
 
 class MockDbms:
 class MockDbms: