BigQuery data quality monitoring fails: PRIMARY KEY placed outside the column list in monitoring table DDL
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
sdk/python/feast/infra/offline_stores/bigquery.py の _bq_ensure_monitoring_tables から始めてください。ここでは、4つの CREATE TABLE IF NOT EXISTS 文が、列リストの閉じ括弧の後に PRIMARY KEY (...) NOT ENFORCED を置いています。各制約を、末尾のカンマの後にリスト内へ移動し、同じキー列を維持してください。4つの文がすべて有効であり、単体テストで制約が要素リスト内にあることを検証できたら完了です。sdk/python/tests/integration/monitoring/test_monitoring_integration.py の統合テストはこの関数をモックしているため、この変更は検出できません。
索引モデルが issue の本文から書いたものです。
説明
Expected Behavior
With a BigQuery offline store, data quality monitoring (feast monitor run, the /monitoring REST endpoints, and the auto_baseline jobs submitted by feast apply) creates its four monitoring tables (feast_monitoring_feature_metrics, feast_monitoring_feature_view_metrics, feast_monitoring_feature_service_metrics, feast_monitoring_jobs) if they don't already exist, then computes and stores metrics.
Current Behavior
Every monitoring call on a BigQuery deployment fails before any metric is computed, because _bq_ensure_monitoring_tables sends DDL that BigQuery can't parse:
google.api_core.exceptions.BadRequest: 400 PRIMARY KEY must be defined in the table element list as column attribute or constraint. at [27:1]
The failure happens when BigQuery parses the statement, so CREATE TABLE IF NOT EXISTS doesn't help. Creating the tables by hand beforehand doesn't help either: the same statements are still sent and rejected on every run.
Steps to reproduce
- Configure a feature repo with
offline_store: type: bigquery. - Run
feast monitor run --project <project>(or call a/monitoringendpoint, orfeast applywithauto_baselineenabled). - The command fails with the
400 PRIMARY KEY must be defined in the table element listerror above.
You can reproduce the parser behavior on its own with a BigQuery dry run. A dry run creates nothing, and the result is the same in every location I tried (US, EU, us-central1, us-south1):
# Constraint after the closing parenthesis (what Feast generates today): rejected
bq query --dry_run --use_legacy_sql=false \
'CREATE TABLE IF NOT EXISTS `my-project.my_dataset.t` (job_id STRING NOT NULL, status STRING) PRIMARY KEY (job_id) NOT ENFORCED'
# Error: PRIMARY KEY must be defined in the table element list as column attribute or constraint.
# Constraint inside the element list: accepted
bq query --dry_run --use_legacy_sql=false \
'CREATE TABLE IF NOT EXISTS `my-project.my_dataset.t` (job_id STRING NOT NULL, status STRING, PRIMARY KEY (job_id) NOT ENFORCED)'
# Query successfully validated.
Specifications
- Version: 0.67.0 (Feast Operator v0.67.0, feature server image 0.67.0). Affects v0.64.0 through v0.67.0 and current
master. - Platform: Kubernetes (Feast Operator);
google-cloud-bigquery3.46.1 - Subsystem: BigQuery offline store, data quality monitoring
Possible Solution
Root cause. In _bq_ensure_monitoring_tables (bigquery.py#L873), each of the four CREATE TABLE IF NOT EXISTS statements puts PRIMARY KEY (...) NOT ENFORCED after the closing ) of the column list:
- L909 (
feast_monitoring_feature_metrics) - L927 (
feast_monitoring_feature_view_metrics) - L944 (
feast_monitoring_feature_service_metrics) - L960 (
feast_monitoring_jobs)
GoogleSQL only accepts table constraints inside the table element list: CREATE TABLE ... ( column | constraint_definition [, ...] ) (docs). This code arrived in #6202 (first released in v0.64.0).
Fix. Move each PRIMARY KEY (...) NOT ENFORCED inside its column list, after a trailing comma on the last column. The key columns stay the same. The other offline stores that create these tables (Redshift, Snowflake, Postgres, Oracle) already put the constraint inside the list, so only BigQuery is affected.
Test gap. No unit test covers _bq_ensure_monitoring_tables, and sdk/python/tests/integration/monitoring/test_monitoring_integration.py mocks ensure_monitoring_tables, so no test ever checks the generated DDL. I'll open a PR with the fix and a unit test that asserts the constraint sits inside the element list for all four tables.
- 主要言語
- Python
- スター
- 7.4k
- フォーク
- 1.5k
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 107
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
feast-dev/feast のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
get_online_features silently drops a join key value when it shares a name with an OnDemandFeatureView's RequestSource field対応中かも @OHMFOHS が 99 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
kind/bug priority/p2
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
feast-dev/feast#6778 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Feast UI container in a different format from ther others再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンkind/bug priority/p2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
feast-dev/feast#6725 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
feast-dev/feast の issue をすべて見る
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
future-agi/future-agi#6392 ·
メンテナーはふだん 1 日以内に返信
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold対応中かも @prathameshfuke が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
StingraySoftware/HENDRICS#213 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信