Querying Aws Sagemaker Catalog

作者 aws188af2f810ce無授權條款2.8K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Runs SQL analytics on SageMaker Catalog asset metadata tables exported as Apache Iceberg in S3 Tables. Covers governance queries, asset growth tracking, ownership audits, time-travel over catalog state, and metadata quality analysis. Applies when querying catalog inventory, finding assets without descriptions, comparing catalog snapshots, or auditing data ownership. Trigger phrases: catalog inventory SQL, how many assets, assets without descriptions, asset growth over time, who owns this data, catalog governance, data quality audit, catalog analytics.

AI 產生的概覽

對以 Iceberg 資料表形式匯出至 S3 Tables 的 SageMaker Catalog 資產中繼資料執行 SQL 分析。

功能
指導對 SageMaker Catalog 每日快照匯出的 Apache Iceberg 資產中繼資料表(位於 aws-sagemaker-catalog S3 Tables 儲存貯體)執行 SQL 查詢。內容涵蓋設定檢查、啟用匯出、Lake Formation 權限授予、關鍵欄位說明,以及資產數量、治理缺口、歸屬稽核、成長趨勢與時間旅行比較的範例查詢。亦提供疑難排解步驟與安全注意事項。
適用情境
適用於分析目錄清單、統計資產數量、尋找缺少描述或負責人的資產、比較不同時間的目錄快照,或稽核資料歸屬。不適用於依名稱尋找特定資料表、互動式瀏覽目錄、查詢資料表內的資料,或編輯目錄中繼資料。
執行需求
需要已設定憑證的 AWS CLI、建議使用 AWS MCP 伺服器以進行沙箱執行與稽核記錄、已啟用資料匯出的 SageMaker Unified Studio 網域、在 Glue 中註冊的 S3 Tables 聯合目錄、Lake Formation 的 SELECT 與 DESCRIBE 授權,以及 Athena 工作群組與輸出位置。需要存取 AWS 服務的網路連線;此技能未隨附指令碼。

Query AWS SageMaker Catalog System Tables

Overview

Works best with the AWS MCP server for sandboxed execution and audit logging. All commands below use the AWS CLI and work in any environment with configured AWS credentials.

Amazon SageMaker Unified Studio (whose catalog feature is referred to below as SageMaker Catalog) exports asset metadata as a daily-snapshot Apache Iceberg table in the AWS-managed aws-sagemaker-catalog table bucket. This enables SQL queries over your entire data catalog inventory — asset counts, governance gaps, ownership audits, and historical comparisons — without building custom ETL.

Data is partitioned by snapshot_time and exported once daily (around midnight per region). The table is read-only.

Decision Tree

User intentUse this skill?Alternative
SQL analytics on catalog state (counts, governance, trends)Yes—
Historical comparison ("what changed in catalog last week")Yes — time travel via snapshot_time—
Find assets without owners or descriptionsYes—
Find a specific table by name or conceptNofinding-data-lake-assets or Glue Discovery search
Browse/enumerate catalog interactivelyNoexploring-data-catalog
Run a query on a table's dataNoquerying-data-lake
Manage catalog metadata (add descriptions, tags)NoGlue Discovery put-form-type / associate-glossary-terms

Common Tasks

1. Check If Configured

bash
aws datazone get-data-export-configuration \  --domain-identifier <DOMAIN_ID> \  --region <REGION>
  • If no domain exists: aws datazone list-domains --region <REGION>
  • If export not enabled: guide user to enable.
  • One domain per account per region.

Verify table bucket exists:

bash
aws s3tables list-table-buckets --region <REGION> \  --query "tableBuckets[?name=='aws-sagemaker-catalog']"

2. Enable

With KMS encryption (recommended for production):

bash
aws datazone put-data-export-configuration \  --domain-identifier <DOMAIN_ID> \  --region <REGION> \  --enable-export \  --encryption-configuration kmsKeyArn=<KMS_KEY_ARN>,sseAlgorithm=aws:kms

Note: Encryption cannot be changed after creation. Always specify KMS for sensitive catalog data.

Without encryption (for quick testing only):

bash
aws datazone put-data-export-configuration \  --domain-identifier <DOMAIN_ID> \  --region <REGION> \  --enable-export

First data available within 24 hours. See: Exporting asset metadata

3. Verify Permissions for Querying

Requires:

  • S3 Tables federated catalog registered in Glue (s3tablescatalog)
  • Lake Formation SELECT + DESCRIBE grants on the table

Grant access:

bash
aws lakeformation grant-permissions \  --principal DataLakePrincipalIdentifier=<ROLE_ARN> \  --resource '{"Table": {"CatalogId": "<ACCOUNT>:s3tablescatalog/aws-sagemaker-catalog", "DatabaseName": "asset_metadata", "Name": "asset"}}' \  --permissions DESCRIBE SELECT \  --region <REGION>

4. Query

Query syntax:

sql
"s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"

Constraints:

  • You MUST always filter by snapshot_time — without it, the query scans all historical snapshots and returns duplicates

  • You MUST confirm workgroup and output location before executing

  • Default to DATE(snapshot_time) = CURRENT_DATE for current state

  • You SHOULD use the key columns documented in this skill to build queries. If you need the full schema, run get-tables once:

    aws glue get-tables --catalog-id "<ACCOUNT>:s3tablescatalog/aws-sagemaker-catalog" --database-name "asset_metadata" --region <REGION>

Key columns:

ColumnWhat it holdsUsage
snapshot_timePartition key — daily snapshot timestampAlways filter on this
asset_idUnique catalog asset identifierPrimary key for lookups
resource_type_enumGlueTable, RedshiftTable, S3Collection, etc.Filter by asset type
resource_idARN or native identifierCross-reference with source systems
asset_nameBusiness-friendly nameDisplay, search
resource_nameTechnical name (table name, prefix)Filtering
business_descriptionBusiness context (NULL if not provided)Governance gaps
extended_metadatamap<string,string> — flexible key-value attributesUse bracket notation: extended_metadata['owningEntityId']
asset_created_timeWhen asset first appeared in catalogGrowth analysis
asset_updated_timeLast modification timeFreshness checks

Current catalog state:

sql
SELECT resource_type_enum, COUNT(*) as countFROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"WHERE DATE(snapshot_time) = CURRENT_DATEGROUP BY resource_type_enumORDER BY count DESC;

Assets without business descriptions:

sql
SELECT asset_name, resource_name, resource_type_enum, account_idFROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"WHERE DATE(snapshot_time) = CURRENT_DATE  AND business_description IS NULL;

Asset growth over last 30 days:

sql
SELECT DATE(snapshot_time) as date, COUNT(*) as total_assetsFROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"WHERE DATE(snapshot_time) >= CURRENT_DATE - INTERVAL '30' DAYGROUP BY DATE(snapshot_time)ORDER BY date DESC;

Time travel — compare current vs 7 days ago (new descriptions added):

sql
SELECT t.asset_id, t.resource_name,       p.business_description as before,       t.business_description as nowFROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset" tJOIN "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset" p  ON t.asset_id = p.asset_idWHERE DATE(t.snapshot_time) = CURRENT_DATE  AND DATE(p.snapshot_time) = CURRENT_DATE - INTERVAL '7' DAY  AND p.business_description IS NULL  AND t.business_description IS NOT NULL;

Assets by owner:

sql
SELECT extended_metadata['owningEntityId'] as owner, COUNT(*) as countFROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"WHERE DATE(snapshot_time) = CURRENT_DATE  AND extended_metadata['owningEntityId'] IS NOT NULLGROUP BY extended_metadata['owningEntityId']ORDER BY count DESC;

Filter by metadata form field:

sql
SELECT *FROM "s3tablescatalog/aws-sagemaker-catalog"."asset_metadata"."asset"WHERE DATE(snapshot_time) = CURRENT_DATE  AND extended_metadata['<metadata-form-name>.<field-name>'] = '<field-value>';

Key Behaviors

  • Daily snapshots — exported around midnight per region
  • Always filter by snapshot_time — without it you get all history (duplicates, slow)
  • One domain per account per region — to switch domains, delete config first
  • No additional charge beyond S3 Tables storage + Athena queries
  • Read-only — to update asset metadata, use Glue Discovery APIs or SageMaker Unified Studio

Troubleshooting

ErrorCauseFix
aws-sagemaker-catalog bucket not foundExport not enabledRun put-data-export-configuration --enable-export
Empty results with CURRENT_DATEFirst export hasn't run yet (takes up to 24h)Wait; try yesterday's date
AccessDenied on queryMissing Lake Formation grantsGrant SELECT + DESCRIBE on the table
CATALOG_NOT_FOUNDS3 Tables not registered in GlueEnable integration: S3 console > Table buckets > Enable integration
Duplicate rows in resultsMissing snapshot_time filterAdd WHERE DATE(snapshot_time) = CURRENT_DATE
extended_metadata key returns NULLKey doesn't exist for that assetCheck available keys: SELECT DISTINCT key FROM ... CROSS JOIN UNNEST(map_keys(extended_metadata)) AS t(key) WHERE DATE(snapshot_time) = CURRENT_DATE
Cannot update export encryptionEncryption set at creation time onlyDelete and recreate export config

Security Considerations

Data sensitivity: Catalog metadata exposes organizational structure including asset names, ownership, account IDs, naming conventions, and internal resource identifiers. Treat query results as sensitive by default.

Encryption at rest: Always enable KMS encryption when creating the export configuration. Encryption cannot be changed after creation. Additionally, configure SSE-KMS on your Athena workgroup output bucket.

Least-privilege access: Grant Lake Formation SELECT + DESCRIBE only on the specific asset_metadata.asset table to roles that need catalog analytics. Avoid granting access to the entire aws-sagemaker-catalog bucket.

Audit trail: Enable CloudTrail logging for DataZone (PutDataExportConfiguration, GetDataExportConfiguration), Athena (StartQueryExecution, GetQueryResults), and S3 Tables API calls to track who queries catalog metadata.

Credential hygiene: Use IAM roles with temporary credentials for querying. Avoid long-lived access keys for users accessing catalog metadata. Scope down or rotate principals when access is no longer needed.

Additional Resources

來源與署名

來源:aws/agent-toolkit-for-aws位於skills/specialized-skills/system-table-skills/querying-aws-sagemaker-catalog提交188af2f

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架