Repository navigation
Conversation
JSON doesn't tell 1.0 from 1, so a float variable default comes back from Python as an int. Treat an int equal to the original float as unchanged and keep the original value. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 4 tests: regression=4 unreleased=0 coverage=0 failing=0
TestAccept/bundle/python/numeric-variable-default/DMS=/PYDAB_VERSION=0.266.0: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/python/numeric-variable-default/DMS=/PYDAB_VERSION=current: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/python/numeric-variable-default/DMS=true/PYDAB_VERSION=0.266.0: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/python/numeric-variable-default/DMS=true/PYDAB_VERSION=current: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) |
✅ Integration test reportCommit: c942a1f
Top 3 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at c942a1f. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR fixes the Python mutator rejecting whole-number floats (like 1.0) that come back from Python as ints, by adding an isWholeFloatAsInt guard in VisitUpdate. The approach is reasonable and the tests cover the main cases. Two issues remain: the changelog entry will fail CI because it lacks the required trailing PR link, and the float/int comparison can silently drop a genuine change for large values beyond 2^53 due to float64 precision loss—a pattern the codebase already guards against elsewhere.
| @@ -0,0 +1 @@ | |||
| * Fix `bundle` commands failing with "unexpected change at variables.X.default" when a bundle with Python code has a variable default such as `1.0`, `1e3` or `0012345678901234`. | |||
There was a problem hiding this comment.
[blocking] .nextchanges/README.md requires a trailing PR link on every entry and CI enforces it. Append ([#7842](https://github.com/databricks/cli/pull/7842)) after the period.
| // back from Python as an int. | ||
| func isWholeFloatAsInt(left, right dyn.Value) bool { | ||
| return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && | ||
| left.MustFloat() == float64(right.MustInt()) |
There was a problem hiding this comment.
[nice to have] float64(right.MustInt()) is lossy for any int64 whose absolute value exceeds 2^53: e.g. float64(9007199254740993) rounds to 9007199254740992.0, so if the original float is 9007199254740992.0 the comparison returns true and the real update is silently dropped. normalizeFloat in libs/dyn/convert/normalize.go:441 already guards against exactly this with a round-trip check. Adding && right.MustInt() == int64(left.MustFloat()) here would close the gap.
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Fable 5.2, cross-verified). Only points the reviewers agreed on are posted.
| // back from Python as an int. | ||
| func isWholeFloatAsInt(left, right dyn.Value) bool { | ||
| return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && | ||
| left.MustFloat() == float64(right.MustInt()) |
There was a problem hiding this comment.
[AI Generated] Above 2^53 Python returns the float's shortest decimal, not its exact value: 1234567890123456789.0 comes back as 1234567890123456800. This check accepts it, but an exact round-trip would not. Can a test pin that case?
| } | ||
|
|
||
| // isWholeFloatAsInt reports whether right is the int Python returns for the float left. | ||
| // JSON doesn't tell 1.0 from 1, so a float such as a variable default of 1.0 comes |
There was a problem hiding this comment.
[AI Generated] nit: It's json.Marshal in writeInputFile (python_mutator.go:506) that writes 1.0 as 1; Python's json keeps 1.0 a float. Could the comment name that cause instead of JSON itself?
| VisitUpdate: func(valuePath dyn.Path, _, right dyn.Value) (dyn.Value, error) { | ||
| VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) { | ||
| if isWholeFloatAsInt(left, right) { | ||
| return left, nil |
There was a problem hiding this comment.
[AI Generated] nit: applyPythonOutput's doc comment lists where the result differs from Python's output (kept locations, undone empty deletes). Keeping the original float when Python returns a whole int is a third case; add a bullet there?
Changes
When merging Python mutator output, an int equal to the original float is treated as unchanged and the original value is kept.
Why
JSON doesn't tell
1.0from1, so a float variable default came back from Python as an int and failed the bundle withunexpected change at "variables.id.default" (update). See #7841.Not fixed: a whole float beyond int64 (e.g.
0012345678901234567890) still fails, because Python returns an int our YAML loader can't parse. That needs a loader change and is left as is.Tests
Updated golden from #7841; unit tests in
apply_python_output_test.go.This pull request and its description were written by Isaac.