|
@@ -58,7 +58,7 @@ 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
|
|
|
|
|
|
|
+ PartitionValueCompatible, HiveServerTable
|
|
|
from beeswax.test_base import BeeswaxSampleProvider
|
|
from beeswax.test_base import BeeswaxSampleProvider
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1426,7 +1426,7 @@ 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():
|
|
|
|
|
|
|
+class MockHiveServerTable(HiveServerTable):
|
|
|
|
|
|
|
|
def __init__(self, data):
|
|
def __init__(self, data):
|
|
|
self.path_location = data.get('path_location')
|
|
self.path_location = data.get('path_location')
|
|
@@ -1440,6 +1440,53 @@ class TestHiveServer2API():
|
|
|
assert_equal(['2013022516'], PartitionValueCompatible(['datehour=2013022516'], table).values)
|
|
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)
|
|
assert_equal(['2011-07', '2011-07-01', '12'], PartitionValueCompatible(['month=2011-07/dt=2011-07-01/hr=12'], table).values)
|
|
|
|
|
|
|
|
|
|
+ def test_table_properties(self):
|
|
|
|
|
+ table = MockHiveServerTable({})
|
|
|
|
|
+ prev_extended_describe = getattr(MockHiveServerTable, 'extended_describe')
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ extended_describe = 'Table(tableName:page_view, dbName:default, owner:romain, createTime:1360732885, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:viewtime, type:int, comment:null), FieldSchema(name:userid, type:bigint, comment:null), FieldSchema(name:page_url, type:string, comment:null), FieldSchema(name:referrer_url, type:string, comment:null), FieldSchema(name:ip, type:string, comment:IP Address of the User), FieldSchema(name:dt, type:string, comment:null), FieldSchema(name:country, type:string, comment:null)], location:hdfs://localhost:8020/user/hive/warehouse/page_view, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[FieldSchema(name:dt, type:string, comment:null), FieldSchema(name:country, type:string, comment:null)], parameters:{numPartitions=0, numFiles=1, transient_lastDdlTime=1360732885, comment=This is the page view table}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)'
|
|
|
|
|
+ setattr(table, 'extended_describe', extended_describe)
|
|
|
|
|
+
|
|
|
|
|
+ assert_equal([['tableName', 'page_view'],
|
|
|
|
|
+ ['dbName', 'default'],
|
|
|
|
|
+ ['owner', 'romain'],
|
|
|
|
|
+ ['createTime', '1360732885'],
|
|
|
|
|
+ ['lastAccessTime', '0'],
|
|
|
|
|
+ ['retention', '0'],
|
|
|
|
|
+ ['location:hdfs://localhost', '8020/user/hive/warehouse/page_view'],
|
|
|
|
|
+ ['inputFormat', 'org.apache.hadoop.mapred.TextInputFormat'],
|
|
|
|
|
+ ['outputFormat', 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'],
|
|
|
|
|
+ ['compressed', 'false'],
|
|
|
|
|
+ ['numBuckets', '-1'],
|
|
|
|
|
+ ['serdeInfo:SerDeInfo(name', 'null'],
|
|
|
|
|
+ ['serializationLib', 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'],
|
|
|
|
|
+ ['parameters', '{serialization.format=1})'],
|
|
|
|
|
+ ['bucketCols', '[]'],
|
|
|
|
|
+ ['sortCols', '[]'],
|
|
|
|
|
+ ['parameters', '{}'],
|
|
|
|
|
+ ['skewedInfo:SkewedInfo(skewedColNames', '[]'],
|
|
|
|
|
+ ['skewedColValues', '[]'],
|
|
|
|
|
+ ['skewedColValueLocationMaps', '{})'],
|
|
|
|
|
+ ['storedAsSubDirectories', 'false)'],
|
|
|
|
|
+ ['partitionKeys:[FieldSchema(name', 'dt'],
|
|
|
|
|
+ ['type', 'string'],
|
|
|
|
|
+ ['comment', 'null)'],
|
|
|
|
|
+ ['FieldSchema(name', 'country'],
|
|
|
|
|
+ ['type', 'string'],
|
|
|
|
|
+ ['comment', 'null)]'],
|
|
|
|
|
+ ['parameters', '{numPartitions=0'],
|
|
|
|
|
+ ['numFiles', '1'],
|
|
|
|
|
+ ['transient_lastDdlTime', '1360732885'],
|
|
|
|
|
+ ['comment', 'This is the page view table}'],
|
|
|
|
|
+ ['viewOriginalText', 'null'],
|
|
|
|
|
+ ['viewExpandedText', 'null'],
|
|
|
|
|
+ ['tableType', 'MANAGED_TABLE']
|
|
|
|
|
+ ],
|
|
|
|
|
+ table.properties)
|
|
|
|
|
+ finally:
|
|
|
|
|
+ setattr(table, 'extended_describe', prev_extended_describe)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class MockDbms:
|
|
class MockDbms:
|
|
|
|
|
|