粘附 AWS 在 boto3 python 上创建数据目录表



我一直在尝试使用 python API 在数据目录中创建一个表。按照此处和此处发布的 API 文档进行操作。我能理解这是怎么回事。尽管如此,我需要在创建表时了解如何声明字段结构,因为当我查看此处表的存储定义时,有任何关于我应该如何为我的表定义这种类型的列的解释。另外。我没有看到所涵盖的表的分类属性。也许在房产上?我已经在此示例中使用了 boto3 文档

法典:

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"} )

找到这篇文章是因为我遇到了同样的问题,最终找到了解决方案,所以你可以按类型做:

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
>>

最新更新