• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python parser.parse_column函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metastore.parser.parse_column函数的典型用法代码示例。如果您正苦于以下问题:Python parse_column函数的具体用法?Python parse_column怎么用?Python parse_column使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_column函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:rhmiller47,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:rhmiller47,项目名称:hue,代码行数:7,代码来源:tests.py


示例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
开发者ID:GorillaTester,项目名称:hue,代码行数:31,代码来源:api.py


示例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
开发者ID:HaNeul-Kim,项目名称:hue,代码行数:34,代码来源:api.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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
开发者ID:RoxC,项目名称:hue,代码行数:25,代码来源:api.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:rhmiller47,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:voyageth,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:mapr,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:mapr,项目名称:hue,代码行数:7,代码来源:tests.py


示例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)
开发者ID:rhmiller47,项目名称:hue,代码行数:12,代码来源:tests.py


示例16: 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)
开发者ID:rhmiller47,项目名称:hue,代码行数:12,代码来源:tests.py


示例17: _autocomplete

def _autocomplete(db, database=None, table=None, column=None, nested=None, query=None, cluster=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:
      if query is not None:
        table = SubQueryTable(db, query)
      else:
        table = db.get_table(database, table)
      response['hdfs_link'] = table.hdfs_link
      response['comment'] = table.comment

      cols_extended = massage_columns_for_json(table.cols)

      if table.is_impala_only:
        if db.client.query_server['server_name'] != 'impala': # Expand Kudu columns information
          query_server = get_query_server_config('impala', cluster=cluster)
          db = dbms.get(db.client.user, query_server, cluster=cluster)

        col_options = db.get_table_describe(database, table.name)
        extra_col_options = dict([(col[0], dict(zip(col_options.cols(), col))) for col in col_options.rows()])

        for col_props in cols_extended:
          col_props.update(extra_col_options.get(col_props['name'], {}))

      response['support_updates'] = table.is_impala_only
      response['columns'] = [column.name for column in table.cols]
      response['extended_columns'] = cols_extended
      response['is_view'] = table.is_view
      response['partition_keys'] = [{'name': part.name, 'type': part.type} for part in table.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']):
          sample = _get_sample_data(db, database, table, column, cluster=cluster)
          if 'rows' in sample:
            response['sample'] = sample['rows']
      else:
        raise Exception('Could not find column `%s`.`%s`.`%s`' % (database, table, column))
  except (QueryServerTimeoutException, TTransportException), e:
    response['code'] = 503
    response['error'] = e.message
开发者ID:cloudera,项目名称:hue,代码行数:52,代码来源:api.py



注:本文中的metastore.parser.parse_column函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python meterbus.load函数代码示例发布时间:2022-05-27
下一篇:
Python module.log函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap