Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bundle:
name: test-bundle

resources:
schemas:
myschema:
name: myschema
catalog_name: main
grants:
- principal: ${workspace.current_user.userName}
privileges:
- USE_SCHEMA
- principal: extra@example.test # TO_REMOVE
privileges: # TO_REMOVE
- CREATE_TABLE # TO_REMOVE
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"depends_on": [
{
"node": "resources.schemas.myschema",
"label": "${resources.schemas.myschema.id}"
}
],
"action": "update",
"new_state": {
"value": {
"securable_type": "schema",
"full_name": "main.myschema",
"__embed__": [
{
"principal": "[USERNAME]",
"privileges": [
"USE_SCHEMA"
]
}
]
}
},
"remote_state": {
"securable_type": "schema",
"full_name": "main.myschema",
"__embed__": [
{
"principal": "extra@example.test",
"privileges": [
"CREATE_TABLE"
]
},
{
"principal": "[USERNAME]",
"privileges": [
"USE_SCHEMA"
]
}
]
},
"changes": {
"[principal='extra@example.test']": {
"action": "update",
"old": {
"principal": "extra@example.test",
"privileges": [
"CREATE_TABLE"
]
},
"remote": {
"principal": "extra@example.test",
"privileges": [
"CREATE_TABLE"
]
}
}
}
}

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,81 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py //unity-catalog/permissions --sort
{
"method": "PATCH",
"path": "/api/2.1/unity-catalog/permissions/schema/main.myschema",
"body": {
"changes": [
{
"add": [
"USE_SCHEMA"
],
"principal": "[USERNAME]",
"remove": [
"ALL_PRIVILEGES"
]
},
{
"add": [
"CREATE_TABLE"
],
"principal": "extra@example.test",
"remove": [
"ALL_PRIVILEGES"
]
}
]
}
}

>>> [CLI] bundle plan -o json

>>> print_requests.py --get //unity-catalog/permissions --sort
{
"method": "GET",
"path": "/api/2.1/unity-catalog/permissions/schema/main.myschema"
}
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py //unity-catalog/permissions --sort
{
"method": "PATCH",
"path": "/api/2.1/unity-catalog/permissions/schema/main.myschema",
"body": {
"changes": [
{
"add": [
"USE_SCHEMA"
],
"principal": "[USERNAME]",
"remove": [
"ALL_PRIVILEGES"
]
},
{
"principal": "extra@example.test",
"remove": [
"ALL_PRIVILEGES"
]
}
]
}
}
The following resources will be deleted:
delete resources.schemas.myschema

This action will result in the deletion of the following UC schemas. Any underlying data may be lost:
delete resources.schemas.myschema

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default

Deleting files...
Destroy complete!
25 changes: 25 additions & 0 deletions acceptance/bundle/deploy/readplan/grants-remove-principal/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cleanup() {
$CLI bundle destroy --auto-approve
rm -f out.requests.txt
}
trap cleanup EXIT

# Deploy schema with two grant principals.
trace $CLI bundle deploy
trace print_requests.py //unity-catalog/permissions --sort

# Remove extra@example.test from config.
grep -v 'TO_REMOVE' databricks.yml > updated.yml && mv updated.yml databricks.yml

# Generate update plan: entry.RemoteState captures both principals as GrantsState.
trace $CLI bundle plan -o json > tmp.plan.json
jq '.plan["resources.schemas.myschema.grants"]' tmp.plan.json > out.plan.grants.json
trace print_requests.py --get //unity-catalog/permissions --sort

# Deploy from serialized plan (READPLAN=1) or without (READPLAN="").
# Without the fix, entry.RemoteState.(*GrantsState) fails for JSON-loaded plan,
# removedGrantPrincipals returns nil, and the revocation is silently skipped.
$CLI bundle deploy $(readplanarg tmp.plan.json)

# Verify the PATCH call included a REMOVE for extra@example.test.
trace print_requests.py //unity-catalog/permissions --sort | contains.py 'extra@example.test'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
EnvMatrix.READPLAN = ["", "1"]
RecordRequests = true
Ignore = ["tmp.plan.json"]
20 changes: 20 additions & 0 deletions acceptance/bundle/deploy/readplan/large-int/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
bundle:
name: test-bundle

# Test that large int64 values (> 2^53, not representable by float64 without loss)
# are correctly saved to and read from the plan JSON.
# job_id here is not a real job reference — it's a field that happens to be int64.
resources:
jobs:
job:
name: test-job
tasks:
- task_key: max_int64
run_job_task:
job_id: 9223372036854775807
- task_key: max_int64_minus_1
run_job_task:
job_id: 9223372036854775806
- task_key: min_int64
run_job_task:
job_id: -9223372036854775808
44 changes: 44 additions & 0 deletions acceptance/bundle/deploy/readplan/large-int/out.plan_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"plan_version": 2,
"cli_version": "[DEV_VERSION]",
"plan": {
"resources.jobs.job": {
"action": "create",
"new_state": {
"value": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "test-job",
"queue": {
"enabled": true
},
"tasks": [
{
"run_job_task": {
"job_id": [MAX_INT_64]
},
"task_key": "max_int64"
},
{
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_1]
},
"task_key": "max_int64_minus_1"
},
{
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min_int64"
}
]
}
}
}
}
}
122 changes: 122 additions & 0 deletions acceptance/bundle/deploy/readplan/large-int/out.plan_skip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"plan_version": 2,
"cli_version": "[DEV_VERSION]",
"lineage": "[UUID]",
"serial": 1,
"plan": {
"resources.jobs.job": {
"action": "skip",
"remote_state": {
"created_time": [UNIX_TIME_MILLIS],
"creator_user_name": "[USERNAME]",
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"email_notifications": {},
"format": "MULTI_TASK",
"job_id": [NUMID],
"max_concurrent_runs": 1,
"name": "test-job",
"queue": {
"enabled": true
},
"run_as_user_name": "[USERNAME]",
"tasks": [
{
"email_notifications": {},
"run_if": "ALL_SUCCESS",
"run_job_task": {
"job_id": [MAX_INT_64]
},
"task_key": "max_int64",
"timeout_seconds": 0
},
{
"email_notifications": {},
"run_if": "ALL_SUCCESS",
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_1]
},
"task_key": "max_int64_minus_1",
"timeout_seconds": 0
},
{
"email_notifications": {},
"run_if": "ALL_SUCCESS",
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min_int64",
"timeout_seconds": 0
}
],
"timeout_seconds": 0,
"webhook_notifications": {}
},
"changes": {
"email_notifications": {
"action": "skip",
"reason": "empty",
"remote": {}
},
"tasks[task_key='max_int64'].email_notifications": {
"action": "skip",
"reason": "empty",
"remote": {}
},
"tasks[task_key='max_int64'].run_if": {
"action": "skip",
"reason": "backend_default",
"remote": "ALL_SUCCESS"
},
"tasks[task_key='max_int64'].timeout_seconds": {
"action": "skip",
"reason": "empty",
"remote": 0
},
"tasks[task_key='max_int64_minus_1'].email_notifications": {
"action": "skip",
"reason": "empty",
"remote": {}
},
"tasks[task_key='max_int64_minus_1'].run_if": {
"action": "skip",
"reason": "backend_default",
"remote": "ALL_SUCCESS"
},
"tasks[task_key='max_int64_minus_1'].timeout_seconds": {
"action": "skip",
"reason": "empty",
"remote": 0
},
"tasks[task_key='min_int64'].email_notifications": {
"action": "skip",
"reason": "empty",
"remote": {}
},
"tasks[task_key='min_int64'].run_if": {
"action": "skip",
"reason": "backend_default",
"remote": "ALL_SUCCESS"
},
"tasks[task_key='min_int64'].timeout_seconds": {
"action": "skip",
"reason": "empty",
"remote": 0
},
"timeout_seconds": {
"action": "skip",
"reason": "empty",
"remote": 0
},
"webhook_notifications": {
"action": "skip",
"reason": "empty",
"remote": {}
}
}
}
}
}
3 changes: 3 additions & 0 deletions acceptance/bundle/deploy/readplan/large-int/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading