databricks / cli

Databricks CLI
Other
115 stars 39 forks source link

Compare `.Kind()` instead of direct equality checks on a `dyn.Value` #1520

Closed shreyas-goenka closed 4 days ago

shreyas-goenka commented 1 week ago

Changes

This PR makes two changes:

  1. In https://github.com/databricks/cli/pull/1510 we'll be adding multiple associated location metadata with a dyn.Value. The Go compiler does not allow comparing structs if they contain slice values (presumably due to multiple possible definitions for equality). In anticipation for adding a []dyn.Location type field to dyn.Value this PR removes all direct comparisons of dyn.Value and instead relies on the kind.

  2. Retain location metadata for values in convert.FromTyped. The change diff is exactly the same as https://github.com/databricks/cli/pull/1523. It's been combined with this PR because they both depend on each other to prevent test failures (forming a test failure deadlock).

Go patch used:

@@
var x expression
@@
-x == dyn.InvalidValue
+x.Kind() == dyn.KindInvalid

@@
var x expression
@@
-x != dyn.InvalidValue
+x.Kind() != dyn.KindInvalid

@@
var x expression
@@
-x == dyn.NilValue
+x.Kind() == dyn.KindNil

@@
var x expression
@@
-x != dyn.NilValue
+x.Kind() != dyn.KindNil

Tests

Unit tests and integration tests pass.