Skip to content

Commit f44075e

Browse files
denikjanniklasrose
authored andcommitted
python: honor the $${...} escape in the variable regex (#6488)
Fixes the python build on main, broken by #6484. That PR added escaped-reference vectors to the shared `reference_vectors.json` but only taught the Go regex to skip them, so `test_variable_reference_vectors.py` fails on main with 4 failures. Also drops the `python/**` path filter from the workflow — that filter is why the break was invisible on #6484. The parity test is driven by a file under `libs/`, so a Go-side change can break it while the PR stays green.
1 parent f6cdc5f commit f44075e

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎.github/workflows/python_push.yml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: python build
22

33
on:
4+
# Not restricted to python/**: these tests also cover contracts shared with the Go
5+
# code, such as libs/dyn/dynvar/testdata/reference_vectors.json, so a change outside
6+
# python/ can break them.
47
pull_request:
58
types: [opened, synchronize]
6-
paths:
7-
- python/**
89
merge_group:
910
types: [checks_requested]
10-
paths:
11-
- python/**
1211
push:
1312
# Always run on push to main. The build cache can only be reused
1413
# if it was saved by a run from the repository's default branch.

‎python/databricks/bundles/core/_transform.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,17 @@ def _unwrap_variable(tpe: type) -> Optional[type]:
277277
# The source of truth is regex in libs/dyn/dynvar/ref.go.
278278
# Behavioral parity is enforced by libs/dyn/dynvar/testdata/reference_vectors.json.
279279
#
280+
# The (?<!\$) lookbehind skips references escaped by a preceding "$": "$${a.b}" is a
281+
# literal "${a.b}" for the Databricks runtime, not a bundle reference.
282+
#
280283
# Example:
281284
# - "${a.b}"
282285
# - "${a.b.c}"
283286
# - "${a.b[0].c}"
284287
_base_var_def = r"_*[^\W\d_]+([-_]*[^\W_]+)*"
285288
_variable_regex = re.compile(
286-
r"\$\{(%s(\.%s(\[[0-9]+\])*)*(\[[0-9]+\])*)\}" % (_base_var_def, _base_var_def)
289+
r"(?<!\$)\$\{(%s(\.%s(\[[0-9]+\])*)*(\[[0-9]+\])*)\}"
290+
% (_base_var_def, _base_var_def)
287291
)
288292

289293

0 commit comments

Comments
 (0)