Skip to content
Merged
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
20 changes: 20 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Note, I'm not testing jobs here. I'm testing how encoder/decoders work with int64, job_id is just a field that came up.
resources:
jobs:
foo:
tasks:
- task_key: max(int64)
run_job_task:
job_id: 9223372036854775807
- task_key: max(int64) - 1
run_job_task:
job_id: 9223372036854775806
- task_key: max(int64) - 2
run_job_task:
job_id: 9223372036854775805
- task_key: min(int64)
run_job_task:
job_id: -9223372036854775808
- task_key: min(int64) - 4
run_job_task:
job_id: -9223372036854775804
56 changes: 56 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/out.plan.direct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"plan_version": 1,
"cli_version": "[DEV_VERSION]",
"plan": {
"resources.jobs.foo": {
"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": "Untitled",
"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) - 1"
},
{
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_2]
},
"task_key": "max(int64) - 2"
},
{
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min(int64)"
},
{
"run_job_task": {
"job_id": [MIN_INT_64_MINUS_4]
},
"task_key": "min(int64) - 4"
}
]
}
}
}
}
}
56 changes: 56 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/out.state.direct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"state_version": 1,
"cli_version": "[DEV_VERSION]",
"lineage": "[UUID]",
"serial": 2,
"state": {
"resources.jobs.foo": {
"__id__": "[NUMID]",
"state": {
"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": "Untitled",
"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) - 1"
},
{
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_2]
},
"task_key": "max(int64) - 2"
},
{
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min(int64)"
},
{
"run_job_task": {
"job_id": [MIN_INT_64_MINUS_4]
},
"task_key": "min(int64) - 4"
}
]
}
}
}
}
5 changes: 5 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/out.test.toml

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

49 changes: 49 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/out.validate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"jobs": {
"foo": {
"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": "Untitled",
"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) - 1"
},
{
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_2]
},
"task_key": "max(int64) - 2"
},
{
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min(int64)"
},
{
"run_job_task": {
"job_id": [MIN_INT_64_MINUS_4]
},
"task_key": "min(int64) - 4"
}
]
}
}
}
80 changes: 80 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

>>> [CLI] bundle validate -o json

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

>>> print_requests.py //jobs
{
"method": "POST",
"path": "/api/2.2/jobs/create",
"body": {
"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": "Untitled",
"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) - 1"
},
{
"run_job_task": {
"job_id": [MAX_INT_64_MINUS_2]
},
"task_key": "max(int64) - 2"
},
{
"run_job_task": {
"job_id": [MIN_INT_64]
},
"task_key": "min(int64)"
},
{
"run_job_task": {
"job_id": [MIN_INT_64_MINUS_4]
},
"task_key": "min(int64) - 4"
}
]
}
}

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.foo

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

Deleting files...
Destroy complete!

>>> print_requests.py //jobs
{
"method": "POST",
"path": "/api/2.2/jobs/delete",
"body": {
"job_id": [NUMID]
}
}
8 changes: 8 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
trace $CLI bundle validate -o json | jq .resources > out.validate.json
trace $CLI bundle plan -o json > out.plan.$DATABRICKS_BUNDLE_ENGINE.json
$CLI bundle deploy
trace print_requests.py //jobs
print_state.py > out.state.$DATABRICKS_BUNDLE_ENGINE.json
trace $CLI bundle plan | contains.py '0 to add, 0 to change, 0 to delete'
trace $CLI bundle destroy --auto-approve
trace print_requests.py //jobs
23 changes: 23 additions & 0 deletions acceptance/bundle/resources/jobs/big_id/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# terraform fails with:
# panic: Error reading level state: strconv.ParseInt: parsing "[NUMID]": value out of range
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ['direct']

[[Repls]]
Old = '9223372036854775807'
New = '[MAX_INT_64]'

[[Repls]]
Old = '9223372036854775806'
New = '[MAX_INT_64_MINUS_1]'

[[Repls]]
Old = '9223372036854775805'
New = '[MAX_INT_64_MINUS_2]'

[[Repls]]
Old = '-9223372036854775808'
New = '[MIN_INT_64]'

[[Repls]]
Old = '-9223372036854775804'
New = '[MIN_INT_64_MINUS_4]'
11 changes: 2 additions & 9 deletions bundle/direct/apply.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package direct

import (
"bytes"
"context"
"encoding/json"
"errors"
Expand Down Expand Up @@ -210,15 +209,9 @@ func (d *DeploymentUnit) Resize(ctx context.Context, db *dstate.DeploymentState,
return nil
}

func typeConvert(destType reflect.Type, src any) (any, error) {
raw, err := json.Marshal(src)
if err != nil {
return nil, fmt.Errorf("marshalling: %w", err)
}

func parseState(destType reflect.Type, raw json.RawMessage) (any, error) {
destPtr := reflect.New(destType).Interface()
dec := json.NewDecoder(bytes.NewReader(raw))
err = dec.Decode(destPtr)
err := json.Unmarshal(raw, destPtr)
if err != nil {
return nil, fmt.Errorf("unmarshalling into %s: %w", destType, err)
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/bundle_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (b *DeploymentBundle) CalculatePlan(ctx context.Context, client *databricks
return false
}

savedState, err := typeConvert(adapter.StateType(), dbentry.State)
savedState, err := parseState(adapter.StateType(), dbentry.State)
if err != nil {
logdiag.LogError(ctx, fmt.Errorf("%s: interpreting state: %w", errorPrefix, err))
return false
Expand Down
Loading