【问题标题】:Glue AWS creating a data catalog table on boto3 pythonGlue AWS在boto3 python上创建数据目录表
【发布时间】:2018-09-13 17:25:35
【问题描述】:

我一直在尝试使用 python API 在我们的数据目录中创建一个表。按照为 API 发布的文档 herehere。我能理解这是怎么回事。不过,我需要在创建表时不明白如何声明字段结构,因为当我查看表here 的存储定义时,有任何关于我应该如何为我的表定义这种类型的列的解释。此外。我没有看到被覆盖的表格的分类属性。也许在属性上?我在这个示例中使用了 boto3 documentation

代码:

import boto3


client = boto3.client(service_name='glue', region_name='us-east-1')


response = client.create_table(
        DatabaseName='dbname',
        TableInput={
        'Name': 'tbname',
        'Description': 'tb description',
        'Owner': 'I'm',
        'StorageDescriptor': {
            'Columns': [

                { 'Name': 'agents', 'Type': 'struct','Comment': 'from deserializer'  },
                { 'Name': 'conference_sid', 'Type': 'string','Comment': 'from deserializer'  },
                { 'Name': 'call_sid', 'Type': 'string','Comment': 'from deserializer'  }
            ] ,
        'Location': 's3://bucket/location/', 
        'InputFormat': 'org.apache.hadoop.mapred.TextInputFormat',
        'OutputFormat': 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',
        'Compressed': False,
        'SerdeInfo': {  'SerializationLibrary': 'org.openx.data.jsonserde.JsonSerDe'}
        },
        'TableType' : "EXTERNAL_TABLE"} )

【问题讨论】:

    标签: amazon-web-services aws-sdk boto3 aws-glue


    【解决方案1】:

    发现这篇文章是因为我遇到了同样的问题并最终找到了解决方案,因此您可以按照以下方式进行操作:

    array<struct<id:string,timestamp:bigint,message:string>>
    

    我在使用 AWS 控制台并单击通过爬虫创建的现有表的数据类型时发现了这个“提示”。它提示:

    An ARRAY of scalar type as a top - level column.
    ARRAY <STRING>
    
    An ARRAY with elements of complex type (STRUCT).
    ARRAY < STRUCT <
      place: STRING,
      start_year: INT
    >>
    
    An ARRAY as a field (CHILDREN) within a STRUCT. (The STRUCT is inside another    ARRAY, because it is rare for a STRUCT to be a top-level column.)
    ARRAY < STRUCT <
      spouse: STRING,
      children: ARRAY <STRING>
    >>
    
    A STRUCT as the element type of an ARRAY.
    ARRAY < STRUCT <
      street: STRING,
      city: STRING,
      country: STRING
    >>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-16
      • 1970-01-01
      • 2020-05-11
      • 2021-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多