View a markdown version of this page

在 Data Catalog 中开始使用业务上下文 - AWS Glue

在 Data Catalog 中开始使用业务上下文

注意

业务上下文和语义搜索目前为预览 AWS Glue 状态,可能会发生更改。

本教程将引导您创建术语表、标记资产以及使用语义搜索按含义发现数据。

先决条件

  • 在支持的区域中配置了 AWS Glue Data Catalog 的 AWS 账户。

  • AWS CLI 已安装并配置完成。

  • Data Catalog 中至少注册了一个表。

  • 具有 AWS Glue Data Catalog 操作权限的 IAM 角色或用户。

请附加以下 IAM 策略以授予所需的权限:

{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "glue:SearchAssets", "glue:PutAsset", "glue:GetAsset", "glue:DeleteAsset", "glue:PutAssetType", "glue:GetAssetType", "glue:DeleteAssetType", "glue:ListAssetTypes", "glue:CreateGlossary", "glue:UpdateGlossary", "glue:GetGlossary", "glue:ListGlossaries", "glue:DeleteGlossary", "glue:CreateGlossaryTerm", "glue:UpdateGlossaryTerm", "glue:GetGlossaryTerm", "glue:ListGlossaryTerms", "glue:DeleteGlossaryTerm", "glue:AssociateGlossaryTerms", "glue:DisassociateGlossaryTerms", "glue:PutFormType", "glue:GetFormType", "glue:DeleteFormType", "glue:ListFormTypes", "glue:PutAttachment", "glue:DeleteAttachment", "glue:ListIterableForms", "glue:BatchGetIterableForms" ], "Resource": "*" }] }

第 1 步:创建术语表并标记资产

创建术语表

运行以下命令:

aws glue create-glossary \ --name "Enterprise Data Glossary" \ --description "Standardized business definitions for enterprise data assets."

输出示例:

{ "Id": "d7xm3np5rk2w9j", "Name": "Enterprise Data Glossary" }
创建术语表条目

将术语表标识符替换为前面输出中的Id

aws glue create-glossary-term \ --glossary-identifier "d7xm3np5rk2w9j" \ --name "Active User" \ --short-description "A user with at least one login in the last 30 days." \ --long-description "An account that has logged in at least once within the trailing 30-day window."

输出示例:

{ "Id": "c2fymbu18rtsx5", "GlossaryId": "d7xm3np5rk2w9j", "Name": "Active User" }
将术语与资产相关联

运行以下命令:

aws glue associate-glossary-terms \ --asset-identifier "arn:aws:glue:us-east-1:123456789012:table/mydb/sales_transactions" \ --glossary-term-identifiers "c2fymbu18rtsx5"

使用 SearchAssets API 按业务含义查找资产。

aws glue search-assets \ --search-text "active users"

输出示例:

{ "Items": [ {"Id": "c9vq7sh2fk4t2h", "AssetName": "Customer Sales Transactions", "AssetTypeId": "Table"} ] }

按资产类型筛选结果:

aws glue search-assets \ --search-text "active users" \ --filter-clause '{"AttributeFilter":{"Attribute":"type","Operator":"equals","Value":{"StringValue":"Table"}}}' \ --max-results 10

要仅筛选到 AWS Glue 表(不包括来自其他源系统的表),请执行以下操作:

aws glue search-assets \ --search-text "active users" \ --filter-clause '{"AndAllFilters":[{"AttributeFilter":{"Attribute":"type","Operator":"equals","Value":{"StringValue":"Table"}}},{"AttributeFilter":{"Attribute":"namespace","Operator":"equals","Value":{"StringValue":"amazon.glue"}}}]}' \ --max-results 10

将人工智能代理与目录配合使用

兼容 MCP 的人工智能代理可以使用 AWS 代理工具包中的技能发现目录资产、检索业务上下文和加载技能内容。您可以通过下列方式获得目录技能:

  • 与插件捆绑在一起–安装 aws-data-analytics 插件,其中包括一组精选的目录技能,供代理在安装后立即使用。有关说明,请参阅《AWS代理工具包用户指南》中的安装插件

  • 本地安装–从 GitHub 上的 AWS 存储库的代理工具包下载单个技能,然后将其添加到代理的技能目录中。以下技能支持目录工作流程:

后续步骤

  • 附加表单以标准化元数据字段,例如数据驻留或保留政策。

  • 创建技能资产,为人工智能代理提供数据域上下文。