本文整理汇总了Python中metastore.parser.parse_column函数的典型用法代码示例。如果您正苦于以下问题:Python parse_column函数的具体用法?Python parse_column怎么用?Python parse_column使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_column函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_map
def test_parse_map(self):
name = "map"
type = "map<string,int>"
comment = "test_parse_map"
column = {"name": name, "type": "map", "comment": comment, "key": {"type": "string"}, "value": {"type": "int"}}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例2: test_parse_array
def test_parse_array(self):
name = "array"
type = "array<string>"
comment = "test_parse_array"
column = {"name": name, "type": "array", "comment": comment, "item": {"type": "string"}}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例3: autocomplete
def autocomplete(request, database=None, table=None, column=None, nested=None):
app_name = get_app_name(request)
query_server = get_query_server_config(app_name)
do_as = request.user
if (request.user.is_superuser or request.user.has_hue_permission(action="impersonate", app="security")) and 'doas' in request.GET:
do_as = User.objects.get(username=request.GET.get('doas'))
db = dbms.get(do_as, query_server)
response = {}
try:
if database is None:
response['databases'] = db.get_databases()
elif table is None:
response['tables'] = db.get_tables(database=database)
elif column is None:
t = db.get_table(database, table)
response['hdfs_link'] = t.hdfs_link
response['columns'] = [column.name for column in t.cols]
response['extended_columns'] = massage_columns_for_json(t.cols)
else:
col = db.get_column(database, table, column)
if col:
parse_tree = parser.parse_column(col.name, col.type, col.comment)
if nested:
parse_tree = _extract_nested_type(parse_tree, nested)
response = parse_tree
else:
raise Exception('Could not find column `%s`.`%s`.`%s`' % (database, table, column))
except (QueryServerTimeoutException, TTransportException), e:
response['code'] = 503
response['error'] = e.message
示例4: _autocomplete
def _autocomplete(db, database=None, table=None, column=None, nested=None):
response = {}
try:
if database is None:
response['databases'] = db.get_databases()
elif table is None:
tables_meta = db.get_tables_meta(database=database)
response['tables_meta'] = tables_meta
elif column is None:
t = db.get_table(database, table)
response['hdfs_link'] = t.hdfs_link
response['columns'] = [column.name for column in t.cols]
response['extended_columns'] = massage_columns_for_json(t.cols)
response['partition_keys'] = [{'name': part.name, 'type': part.type} for part in t.partition_keys]
else:
col = db.get_column(database, table, column)
if col:
parse_tree = parser.parse_column(col.name, col.type, col.comment)
if nested:
parse_tree = _extract_nested_type(parse_tree, nested)
response = parse_tree
# If column or nested type is scalar/primitive, add sample of values
if parser.is_scalar_type(parse_tree['type']):
table_obj = db.get_table(database, table)
sample = db.get_sample(database, table_obj, column, nested)
if sample:
sample = set([row[0] for row in sample.rows()])
response['sample'] = sorted(list(sample))
else:
raise Exception('Could not find column `%s`.`%s`.`%s`' % (database, table, column))
except (QueryServerTimeoutException, TTransportException), e:
response['code'] = 503
response['error'] = e.message
示例5: test_parse_nested
def test_parse_nested(self):
name = 'nested'
type = 'array<struct<name:string,age:int>>'
comment = 'test_parse_nested'
column = {'name': name, 'type': 'array', 'comment': comment, 'item': {'type': 'struct', 'fields': [{'name': 'name', 'type': 'string'}, {'name': 'age', 'type': 'int'}]}}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例6: _autocomplete
def _autocomplete(db, database=None, table=None, column=None, nested=None):
response = {}
try:
if database is None:
response['databases'] = db.get_databases()
elif table is None:
response['tables'] = db.get_tables(database=database)
elif column is None:
t = db.get_table(database, table)
response['hdfs_link'] = t.hdfs_link
response['columns'] = [column.name for column in t.cols]
response['extended_columns'] = massage_columns_for_json(t.cols)
else:
col = db.get_column(database, table, column)
if col:
parse_tree = parser.parse_column(col.name, col.type, col.comment)
if nested:
parse_tree = _extract_nested_type(parse_tree, nested)
response = parse_tree
else:
raise Exception('Could not find column `%s`.`%s`.`%s`' % (database, table, column))
except (QueryServerTimeoutException, TTransportException), e:
response['code'] = 503
response['error'] = e.message
示例7: test_parse_map
def test_parse_map(self):
name = 'map'
type = 'map<string,int>'
comment = 'test_parse_map'
column = {'name': name, 'type': 'map', 'comment': comment, 'key': {'type': 'string'}, 'value': {'type': 'int'}}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例8: test_parse_struct
def test_parse_struct(self):
name = 'struct'
type = 'struct<name:string,age:int>'
comment = 'test_parse_struct'
column = {'name': name, 'type': 'struct', 'comment': comment, 'fields': [{'name': 'name', 'type': 'string'}, {'name': 'age', 'type': 'int'}]}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例9: test_parse_decimal
def test_parse_decimal(self):
name = 'simple'
type = 'decimal(12,2)'
comment = 'test_parse_decimal'
column = {'name': name, 'type': type, 'comment': comment}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例10: test_parse_array
def test_parse_array(self):
name = 'array'
type = 'array<string>'
comment = 'test_parse_array'
column = {'name': name, 'type': 'array', 'comment': comment, 'item': {'type': 'string'}}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例11: test_parse_simple
def test_parse_simple(self):
name = "simple"
type = "string"
comment = "test_parse_simple"
column = {"name": name, "type": type, "comment": comment}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例12: test_parse_simple
def test_parse_simple(self):
name = 'simple'
type = 'string'
comment = 'test_parse_simple'
column = {'name': name, 'type': type, 'comment': comment}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例13: test_parse_nested_with_array
def test_parse_nested_with_array(self):
name = 'nested'
type = 'struct<fieldname1:bigint,fieldname2:int,fieldname3:int,fieldname4:array<bigint>,fieldname5:bigint,fieldname6:array<struct<array_elem:string>>,fieldname7:string>'
comment = 'test_parse_nested'
column = {'comment': 'test_parse_nested', 'fields': [{'type': 'bigint', 'name': 'fieldname1'}, {'type': 'int', 'name': 'fieldname2'}, {'type': 'int', 'name': 'fieldname3'}, {'item': {'type': 'bigint'}, 'type': 'array', 'name': 'fieldname4'}, {'type': 'bigint', 'name': 'fieldname5'}, {'item': {'fields': [{'type': 'string', 'name': 'array_elem'}], 'type': 'struct'}, 'type': 'array', 'name': 'fieldname6'}, {'type': 'string', 'name': 'fieldname7'}], 'type': 'struct', 'name': 'nested'}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例14: test_parse_varchar
def test_parse_varchar(self):
name = 'varchar'
type = 'varchar(1000)'
comment = 'test_parse_varchar'
column = {'name': name, 'type': type, 'comment': comment}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)
示例15: test_parse_nested
def test_parse_nested(self):
name = "nested"
type = "array<struct<name:string,age:int>>"
comment = "test_parse_nested"
column = {
"name": name,
"type": "array",
"comment": comment,
"item": {"type": "struct", "fields": [{"name": "name", "type": "string"}, {"name": "age", "type": "int"}]},
}
parse_tree = parser.parse_column(name, type, comment)
assert_equal(parse_tree, column)