-
Notifications
You must be signed in to change notification settings - Fork 174
Add postgres_synced_tables bundle resource #5268
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
Changes from all commits
f09b6f6
9688b99
f0036ce
721a598
3c1f4c8
9037247
53029c9
f39bd3c
5ccf8d1
bb87545
5d6d658
de011f9
2adce5e
a3b1372
6bbe5ac
f225351
52913dc
e388091
5732819
f26197d
ca14073
2beb3cb
3857f0f
bbbf49f
9744962
c4e5908
9150e27
376a4a9
7045564
495a076
647bd80
5d73765
73eabf1
36ae5e8
e8f59da
57c9aee
f32307e
1523e23
6e14171
88e01f4
288546a
ea272a8
3c31d81
e967ae7
457098b
b29719d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| postgres_synced_tables: | ||
| foo: | ||
| synced_table_id: lakebase_$UNIQUE_NAME.public.trips_synced | ||
| source_table_full_name: main.raw.trips | ||
| primary_key_columns: [id] | ||
| scheduling_policy: SNAPSHOT | ||
| postgres_database: appdb | ||
| branch: projects/test-pg-project-$UNIQUE_NAME/branches/production | ||
| create_database_objects_if_missing: true | ||
| new_pipeline_spec: | ||
| storage_catalog: main | ||
| storage_schema: pipelines |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| bundle: | ||
| name: deploy-postgres-synced-table-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| schemas: | ||
| pipeline_storage: | ||
| name: pipeline_storage_$UNIQUE_NAME | ||
| catalog_name: main | ||
| comment: "Pipeline storage for the synced-table test" | ||
|
|
||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Test Project for Synced Table" | ||
| pg_version: 17 | ||
|
|
||
| postgres_catalogs: | ||
| my_catalog: | ||
| catalog_id: lakebase_test_$UNIQUE_NAME | ||
| branch: ${resources.postgres_projects.my_project.id}/branches/production | ||
| postgres_database: appdb | ||
| create_database_if_missing: true | ||
|
|
||
| postgres_synced_tables: | ||
| my_table: | ||
| synced_table_id: ${resources.postgres_catalogs.my_catalog.catalog_id}.public.trips_synced | ||
| source_table_full_name: main.source_$UNIQUE_NAME.trips_source | ||
| primary_key_columns: ["tpep_pickup_datetime"] | ||
| scheduling_policy: SNAPSHOT | ||
| postgres_database: appdb | ||
| branch: ${resources.postgres_projects.my_project.id}/branches/production | ||
| create_database_objects_if_missing: true | ||
| new_pipeline_spec: | ||
| storage_catalog: ${resources.schemas.pipeline_storage.catalog_name} | ||
| storage_schema: ${resources.schemas.pipeline_storage.name} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Test Project for Synced Table", | ||
| "pg_version": 17 | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/catalogs", | ||
| "q": { | ||
| "catalog_id": "lakebase_test_[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "branch": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production", | ||
| "create_database_if_missing": true, | ||
| "postgres_database": "appdb" | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/synced_tables", | ||
| "q": { | ||
| "synced_table_id": "lakebase_test_[UNIQUE_NAME].public.trips_synced" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "branch": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production", | ||
| "create_database_objects_if_missing": true, | ||
| "new_pipeline_spec": { | ||
| "storage_catalog": "main", | ||
| "storage_schema": "pipeline_storage_[UNIQUE_NAME]" | ||
| }, | ||
| "postgres_database": "appdb", | ||
| "primary_key_columns": [ | ||
| "tpep_pickup_datetime" | ||
| ], | ||
| "scheduling_policy": "SNAPSHOT", | ||
| "source_table_full_name": "main.source_[UNIQUE_NAME].trips_source" | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/synced_tables/lakebase_test_[UNIQUE_NAME].public.trips_synced" | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| Creating temporary source table: main.source_[UNIQUE_NAME].trips_source | ||
| { | ||
| "full_name": "main.source_[UNIQUE_NAME]" | ||
| } | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Name: deploy-postgres-synced-table-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-synced-table-[UNIQUE_NAME]/default | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: deploy-postgres-synced-table-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-synced-table-[UNIQUE_NAME]/default | ||
| Resources: | ||
| Postgres catalogs: | ||
| my_catalog: | ||
| Name: lakebase_test_[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/explore/data/lakebase_test_[UNIQUE_NAME] | ||
| Postgres projects: | ||
| my_project: | ||
| Name: Test Project for Synced Table | ||
| URL: (not deployed) | ||
| Postgres synced tables: | ||
| my_table: | ||
| Name: ${resources.postgres_catalogs.my_catalog.catalog_id}.public.trips_synced | ||
| URL: [DATABRICKS_URL]/explore/data/$%7Bresources/postgres_catalogs/my_catalog.catalog_id%7D.public.trips_synced | ||
| Schemas: | ||
| pipeline_storage: | ||
| Name: pipeline_storage_[UNIQUE_NAME] | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-synced-table-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] postgres get-synced-table synced_tables/lakebase_test_[UNIQUE_NAME].public.trips_synced | ||
| { | ||
| "name": "synced_tables/lakebase_test_[UNIQUE_NAME].public.trips_synced", | ||
| "unity_catalog_provisioning_state": "ACTIVE" | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: deploy-postgres-synced-table-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-synced-table-[UNIQUE_NAME]/default | ||
| Resources: | ||
| Postgres catalogs: | ||
| my_catalog: | ||
| Name: lakebase_test_[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/explore/data/lakebase_test_[UNIQUE_NAME] | ||
| Postgres projects: | ||
| my_project: | ||
| Name: Test Project for Synced Table | ||
| URL: (not deployed) | ||
| Postgres synced tables: | ||
| my_table: | ||
| Name: lakebase_test_[UNIQUE_NAME].public.trips_synced | ||
| URL: [DATABRICKS_URL]/explore/data/lakebase_test_[UNIQUE_NAME]/public/trips_synced | ||
| Schemas: | ||
| pipeline_storage: | ||
| Name: pipeline_storage_[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/explore/data/main/pipeline_storage_[UNIQUE_NAME] | ||
|
|
||
| >>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/ | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.postgres_catalogs.my_catalog | ||
| delete resources.postgres_projects.my_project | ||
| delete resources.postgres_synced_tables.my_table | ||
| delete resources.schemas.pipeline_storage | ||
|
|
||
| This action will result in the deletion of the following UC schemas. Any underlying data may be lost: | ||
| delete resources.schemas.pipeline_storage | ||
|
|
||
| This action will result in the deletion of the following Lakebase projects along with | ||
| all their branches, databases, and endpoints. All data stored in them will be permanently lost: | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-synced-table-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
| Cleaning up temporary source table |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| # Create a per-test source schema + table. We can't read samples.nyctaxi.trips | ||
| # directly because shared workspaces hit the "20 synced tables per source table" | ||
| # limit (same reason synced_database_tables takes this approach). | ||
| echo "Creating temporary source table: main.source_$UNIQUE_NAME.trips_source" | ||
| $CLI schemas create source_$UNIQUE_NAME main -o json | jq '{full_name}' | ||
| MSYS_NO_PATHCONV=1 $CLI api post "/api/2.0/sql/statements/" --json "{ | ||
| \"warehouse_id\": \"$TEST_DEFAULT_WAREHOUSE_ID\", | ||
| \"statement\": \"CREATE TABLE main.source_$UNIQUE_NAME.trips_source AS SELECT * FROM samples.nyctaxi.trips LIMIT 10\", | ||
| \"wait_timeout\": \"45s\" | ||
| }" > /dev/null | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| echo "Cleaning up temporary source table" | ||
| $CLI tables delete main.source_$UNIQUE_NAME.trips_source || true | ||
| $CLI schemas delete main.source_$UNIQUE_NAME || true | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle validate | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| rm -f out.requests.txt | ||
| trace $CLI bundle deploy | ||
|
|
||
| # Keep only the deterministic identity + provisioning-state. detailed_state | ||
| # varies with pipeline-provisioning timing on cloud, ongoing_sync_progress and | ||
| # project only appear there, and create_time/update_time/uid/pipeline_id are | ||
| # random per run. | ||
| trace $CLI postgres get-synced-table "synced_tables/lakebase_test_${UNIQUE_NAME}.public.trips_synced" | jq '{name, unity_catalog_provisioning_state: .status.unity_catalog_provisioning_state}' | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| # Filter requests to only show postgres operations (exclude workspace, telemetry, and operation polling). | ||
| trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # All configuration inherited from parent test.toml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| bundle: | ||
| name: recreate-postgres-synced-table-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| schemas: | ||
| pipeline_storage: | ||
| name: pipeline_storage_$UNIQUE_NAME | ||
| catalog_name: main | ||
| comment: "Pipeline storage for the synced-table recreate test" | ||
|
|
||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Test Project for Synced Table Recreate" | ||
| pg_version: 17 | ||
|
|
||
| postgres_catalogs: | ||
| my_catalog: | ||
| catalog_id: lakebase_test_$UNIQUE_NAME | ||
| branch: ${resources.postgres_projects.my_project.id}/branches/production | ||
| postgres_database: appdb | ||
| create_database_if_missing: true | ||
|
|
||
| postgres_synced_tables: | ||
| my_table: | ||
| synced_table_id: ${resources.postgres_catalogs.my_catalog.catalog_id}.public.trips_synced | ||
| source_table_full_name: main.source_$UNIQUE_NAME.trips_source | ||
| primary_key_columns: ["tpep_pickup_datetime"] | ||
| scheduling_policy: SNAPSHOT | ||
| postgres_database: appdb | ||
| branch: ${resources.postgres_projects.my_project.id}/branches/production | ||
| create_database_objects_if_missing: true | ||
| timeseries_key: $TIMESERIES_KEY | ||
| new_pipeline_spec: | ||
| storage_catalog: ${resources.schemas.pipeline_storage.catalog_name} | ||
| storage_schema: ${resources.schemas.pipeline_storage.name} |
Uh oh!
There was an error while loading. Please reload this page.