-
Notifications
You must be signed in to change notification settings - Fork 477
(feat: persistence) Add schema-metrics-v1.sql for metrics tables (#3337) #3523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
persistence/relational-jdbc/src/main/resources/h2/schema-metrics-v1.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| -- | ||
| -- Licensed to the Apache Software Foundation (ASF) under one | ||
| -- or more contributor license agreements. See the NOTICE file-- | ||
| -- distributed with this work for additional information | ||
| -- regarding copyright ownership. The ASF licenses this file | ||
| -- to you under the Apache License, Version 2.0 (the | ||
| -- "License"). You may not use this file except in compliance | ||
| -- with the License. You may obtain a copy of the License at | ||
| -- | ||
| -- http://www.apache.org/licenses/LICENSE-2.0 | ||
| -- | ||
| -- Unless required by applicable law or agreed to in writing, | ||
| -- software distributed under the License is distributed on an | ||
| -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| -- KIND, either express or implied. See the License for the | ||
| -- specific language governing permissions and limitations | ||
| -- under the License. | ||
| -- | ||
|
|
||
| -- This schema is SEPARATE from the entity schema and can evolve independently. | ||
| -- It contains tables for storing Iceberg metrics reports. | ||
| -- | ||
| -- Tables: | ||
| -- * `metrics_version` - Version tracking for the metrics schema | ||
| -- * `scan_metrics_report` - Scan metrics reports | ||
| -- * `commit_metrics_report` - Commit metrics reports | ||
| -- ============================================================================ | ||
|
|
||
| CREATE SCHEMA IF NOT EXISTS POLARIS_SCHEMA; | ||
| SET SCHEMA POLARIS_SCHEMA; | ||
|
|
||
| -- Metrics schema version tracking (separate from entity schema version) | ||
| CREATE TABLE IF NOT EXISTS metrics_version ( | ||
| version_key VARCHAR PRIMARY KEY, | ||
| version_value INTEGER NOT NULL | ||
| ); | ||
|
|
||
| MERGE INTO metrics_version (version_key, version_value) | ||
| KEY (version_key) | ||
| VALUES ('metrics_version', 1); | ||
|
|
||
| COMMENT ON TABLE metrics_version IS 'the version of the metrics schema in use'; | ||
|
|
||
| -- ============================================================================ | ||
| -- SCAN METRICS REPORT TABLE | ||
| -- ============================================================================ | ||
|
|
||
| CREATE TABLE IF NOT EXISTS scan_metrics_report ( | ||
| report_id TEXT NOT NULL, | ||
| realm_id TEXT NOT NULL, | ||
| catalog_id BIGINT NOT NULL, | ||
| table_id BIGINT NOT NULL, | ||
|
|
||
| -- Report metadata | ||
| timestamp_ms BIGINT NOT NULL, | ||
| principal_name TEXT, | ||
| request_id TEXT, | ||
|
|
||
| -- Trace correlation | ||
| otel_trace_id TEXT, | ||
| otel_span_id TEXT, | ||
| report_trace_id TEXT, | ||
|
|
||
| -- Scan context | ||
| snapshot_id BIGINT, | ||
| schema_id INTEGER, | ||
| filter_expression TEXT, | ||
| projected_field_ids TEXT, | ||
| projected_field_names TEXT, | ||
|
|
||
| -- Scan metrics | ||
| result_data_files BIGINT DEFAULT 0, | ||
| result_delete_files BIGINT DEFAULT 0, | ||
| total_file_size_bytes BIGINT DEFAULT 0, | ||
| total_data_manifests BIGINT DEFAULT 0, | ||
| total_delete_manifests BIGINT DEFAULT 0, | ||
| scanned_data_manifests BIGINT DEFAULT 0, | ||
| scanned_delete_manifests BIGINT DEFAULT 0, | ||
| skipped_data_manifests BIGINT DEFAULT 0, | ||
| skipped_delete_manifests BIGINT DEFAULT 0, | ||
| skipped_data_files BIGINT DEFAULT 0, | ||
| skipped_delete_files BIGINT DEFAULT 0, | ||
| total_planning_duration_ms BIGINT DEFAULT 0, | ||
|
|
||
| -- Equality/positional delete metrics | ||
| equality_delete_files BIGINT DEFAULT 0, | ||
| positional_delete_files BIGINT DEFAULT 0, | ||
| indexed_delete_files BIGINT DEFAULT 0, | ||
| total_delete_file_size_bytes BIGINT DEFAULT 0, | ||
|
|
||
| -- Additional metadata (for extensibility) | ||
| metadata TEXT DEFAULT '{}', | ||
|
|
||
| PRIMARY KEY (realm_id, report_id) | ||
| ); | ||
|
|
||
| COMMENT ON TABLE scan_metrics_report IS 'Scan metrics reports as first-class entities'; | ||
|
|
||
| -- Index for retention cleanup by timestamp | ||
| CREATE INDEX IF NOT EXISTS idx_scan_report_timestamp ON scan_metrics_report(realm_id, timestamp_ms); | ||
|
|
||
| -- ============================================================================ | ||
| -- COMMIT METRICS REPORT TABLE | ||
| -- ============================================================================ | ||
|
|
||
| CREATE TABLE IF NOT EXISTS commit_metrics_report ( | ||
| report_id TEXT NOT NULL, | ||
| realm_id TEXT NOT NULL, | ||
| catalog_id BIGINT NOT NULL, | ||
| table_id BIGINT NOT NULL, | ||
|
|
||
| -- Report metadata | ||
| timestamp_ms BIGINT NOT NULL, | ||
| principal_name TEXT, | ||
| request_id TEXT, | ||
|
|
||
| -- Trace correlation | ||
| otel_trace_id TEXT, | ||
| otel_span_id TEXT, | ||
| report_trace_id TEXT, | ||
|
|
||
| -- Commit context | ||
| snapshot_id BIGINT NOT NULL, | ||
| sequence_number BIGINT, | ||
| operation TEXT NOT NULL, | ||
|
|
||
| -- File metrics | ||
| added_data_files BIGINT DEFAULT 0, | ||
| removed_data_files BIGINT DEFAULT 0, | ||
| total_data_files BIGINT DEFAULT 0, | ||
| added_delete_files BIGINT DEFAULT 0, | ||
| removed_delete_files BIGINT DEFAULT 0, | ||
| total_delete_files BIGINT DEFAULT 0, | ||
|
|
||
| -- Equality delete files | ||
| added_equality_delete_files BIGINT DEFAULT 0, | ||
| removed_equality_delete_files BIGINT DEFAULT 0, | ||
|
|
||
| -- Positional delete files | ||
| added_positional_delete_files BIGINT DEFAULT 0, | ||
| removed_positional_delete_files BIGINT DEFAULT 0, | ||
|
|
||
| -- Record metrics | ||
| added_records BIGINT DEFAULT 0, | ||
| removed_records BIGINT DEFAULT 0, | ||
| total_records BIGINT DEFAULT 0, | ||
|
|
||
| -- Size metrics | ||
| added_file_size_bytes BIGINT DEFAULT 0, | ||
| removed_file_size_bytes BIGINT DEFAULT 0, | ||
| total_file_size_bytes BIGINT DEFAULT 0, | ||
|
|
||
| -- Duration and attempts | ||
| total_duration_ms BIGINT DEFAULT 0, | ||
| attempts INTEGER DEFAULT 1, | ||
|
|
||
| -- Additional metadata (for extensibility) | ||
| metadata TEXT DEFAULT '{}', | ||
|
|
||
| PRIMARY KEY (realm_id, report_id) | ||
| ); | ||
|
|
||
| COMMENT ON TABLE commit_metrics_report IS 'Commit metrics reports as first-class entities'; | ||
|
|
||
| -- Index for retention cleanup by timestamp | ||
| CREATE INDEX IF NOT EXISTS idx_commit_report_timestamp ON commit_metrics_report(realm_id, timestamp_ms); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.