【问题标题】:AWS Glue Search OptionAWS Glue 搜索选项
【发布时间】:2019-11-27 07:03:22
【问题描述】:

我目前正在使用 AWS Glue 数据目录来组织我的数据库。一旦我建立了连接并发送了我的爬虫来收集信息,我就能够看到制定的元数据。

一个很好的功能是能够在一个列名称上搜索整个数据目录。例如,如果我的数据目录中有 5 个表,其中一个表恰好有一个字段“年龄”。我希望能够看到那张桌子。

我还想知道是否可以搜索 AWS Glue 数据目录表中每列的“cmets”字段

希望能得到一些帮助!

【问题讨论】:

    标签: python rest aws-glue aws-glue-data-catalog


    【解决方案1】:

    您可以使用 AWS Glue API 做到这一点。例如,您可以使用 python SDK boto3get_tables() 方法来检索有关特定数据库中表的所有元信息。看看调用get_tables()返回的Response Syntax,然后你只需要解析它,例如:

    import boto3
    
    glue_client = boto3.client('glue')
    
    response = glue_client.get_tables(
        DatabaseName='__SOME_NAME__'
    )
    
    for table in response['TableList']:
        columns = table['StorageDescriptor']['Columns']
        for col in columns:
            col_name = col['Name']
            col_comment = col['Comment']
    
            # Here you do search for what you need
    

    注意:如果你有一个带分区的表(人工列),那么你都需要搜索

    columns_as_partitions = table['PartitionKeys']
    for col in columns_as_partitions:
        col_name = col['Name']
        col_comment = col['Comment']
    
        # Here you do search for what you need
    

    【讨论】:

    猜你喜欢
    • 2021-01-20
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多