diff --git a/.run/single-binary.run.xml b/.run/single-binary.run.xml
index 4b5de3705a..77de6fe10a 100644
--- a/.run/single-binary.run.xml
+++ b/.run/single-binary.run.xml
@@ -8,6 +8,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/flyteadmin/go.mod b/flyteadmin/go.mod
index 09f43329f7..b8507cc0e5 100644
--- a/flyteadmin/go.mod
+++ b/flyteadmin/go.mod
@@ -48,7 +48,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
- github.com/wI2L/jsondiff v0.5.0
+ github.com/wI2L/jsondiff v0.6.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0
go.opentelemetry.io/otel v1.24.0
golang.org/x/net v0.27.0
@@ -176,9 +176,9 @@ require (
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
- github.com/tidwall/gjson v1.17.0 // indirect
+ github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
- github.com/tidwall/pretty v1.2.0 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
diff --git a/flyteadmin/go.sum b/flyteadmin/go.sum
index f872388bff..a7d12f01fd 100644
--- a/flyteadmin/go.sum
+++ b/flyteadmin/go.sum
@@ -1271,8 +1271,8 @@ github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJH
github.com/tidwall/gjson v1.6.8/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
github.com/tidwall/gjson v1.7.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
-github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
@@ -1280,8 +1280,9 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
-github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y=
github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
@@ -1302,8 +1303,8 @@ github.com/unrolled/secure v0.0.0-20181005190816-ff9db2ff917f/go.mod h1:mnPT77IA
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
-github.com/wI2L/jsondiff v0.5.0 h1:RRMTi/mH+R2aXcPe1VYyvGINJqQfC3R+KSEakuU1Ikw=
-github.com/wI2L/jsondiff v0.5.0/go.mod h1:qqG6hnK0Lsrz2BpIVCxWiK9ItsBCpIZQiv0izJjOZ9s=
+github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI=
+github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
diff --git a/flytectl/go.mod b/flytectl/go.mod
index b657a02d4d..6e258b1bad 100644
--- a/flytectl/go.mod
+++ b/flytectl/go.mod
@@ -141,13 +141,19 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
- github.com/shamaton/msgpack/v2 v2.2.2 // indirect
+ github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
+ github.com/tidwall/gjson v1.17.1 // indirect
+ github.com/tidwall/match v1.1.1 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
+ github.com/tidwall/sjson v1.2.5 // indirect
+ github.com/wI2L/jsondiff v0.6.0 // indirect
+ gitlab.com/yvesf/json-schema-compare v0.0.0-20190604192943-a900c04201f7 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
diff --git a/flytectl/go.sum b/flytectl/go.sum
index f57ca65c0a..9f81c0ec9d 100644
--- a/flytectl/go.sum
+++ b/flytectl/go.sum
@@ -418,6 +418,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=
+github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
github.com/shamaton/msgpack/v2 v2.2.2 h1:GOIg0c9LV04VwzOOqZSrmsv/JzjNOOMxnS/HvOHGdgs=
github.com/shamaton/msgpack/v2 v2.2.2/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -457,6 +459,18 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
+github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
+github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI=
+github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -466,6 +480,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zalando/go-keyring v0.1.1 h1:w2V9lcx/Uj4l+dzAf1m9s+DJ1O8ROkEHnynonHjTcYE=
github.com/zalando/go-keyring v0.1.1/go.mod h1:OIC+OZ28XbmwFxU/Rp9V7eKzZjamBJwRzC8UFJH9+L8=
+gitlab.com/yvesf/json-schema-compare v0.0.0-20190604192943-a900c04201f7 h1:BAkxmYRc1ZPl6Gap4HWqwPT8yLZMrgaAwx12Ft408sg=
+gitlab.com/yvesf/json-schema-compare v0.0.0-20190604192943-a900c04201f7/go.mod h1:X40Z1OU8o1oiXWzBmkuYOaruzYGv60l0AxGiB0E9keI=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
diff --git a/flyteidl/go.mod b/flyteidl/go.mod
index 0da94cea32..6653ce5a87 100644
--- a/flyteidl/go.mod
+++ b/flyteidl/go.mod
@@ -5,6 +5,7 @@ go 1.22
require (
github.com/flyteorg/flyte/flytestdlib v0.0.0-00010101000000-000000000000
github.com/go-test/deep v1.0.7
+ github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golang/protobuf v1.5.3
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
@@ -55,7 +56,6 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
- github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
diff --git a/flytepropeller/go.mod b/flytepropeller/go.mod
index c819278d90..3e83107905 100644
--- a/flytepropeller/go.mod
+++ b/flytepropeller/go.mod
@@ -27,6 +27,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
+ github.com/wI2L/jsondiff v0.6.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
@@ -124,6 +125,10 @@ require (
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
+ github.com/tidwall/gjson v1.17.1 // indirect
+ github.com/tidwall/match v1.1.1 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
+ github.com/tidwall/sjson v1.2.5 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
diff --git a/flytepropeller/go.sum b/flytepropeller/go.sum
index 37a8766913..3ab11fff27 100644
--- a/flytepropeller/go.sum
+++ b/flytepropeller/go.sum
@@ -410,6 +410,18 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
+github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
+github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI=
+github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
diff --git a/flytepropeller/pkg/compiler/validators/typing.go b/flytepropeller/pkg/compiler/validators/typing.go
index 66847410f7..988308b15b 100644
--- a/flytepropeller/pkg/compiler/validators/typing.go
+++ b/flytepropeller/pkg/compiler/validators/typing.go
@@ -1,9 +1,11 @@
package validators
import (
+ "encoding/json"
"strings"
structpb "github.com/golang/protobuf/ptypes/struct"
+ "github.com/wI2L/jsondiff"
flyte "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
)
@@ -16,6 +18,53 @@ type trivialChecker struct {
literalType *flyte.LiteralType
}
+func isSuperTypeInJSON(sourceMetaData, targetMetaData *structpb.Struct) bool {
+ // Check if the source schema is a supertype of the target schema, beyond simple inheritance.
+ // For custom types, we expect the JSON schemas in the metadata to come from the same JSON schema package,
+ // specifically draft 2020-12 from Mashumaro.
+
+ srcSchemaBytes, _ := json.Marshal(sourceMetaData.GetFields())
+ tgtSchemaBytes, _ := json.Marshal(targetMetaData.GetFields())
+
+ patch, _ := jsondiff.CompareJSON(srcSchemaBytes, tgtSchemaBytes)
+ for _, p := range patch {
+ if p.Type == jsondiff.OperationReplace {
+ if strings.Contains(p.Path, "title") {
+ // Ignore title changes to support inheritance
+ continue
+ } else if strings.Contains(p.Path, "max") {
+ // If the value of maxItems, maxProperties, maxLength is changed, the target schema should have a smaller range.
+ if p.OldValue.(int) == -1 || p.OldValue.(int) < p.Value.(int) {
+ return false
+ }
+ continue
+ } else if strings.Contains(p.Path, "min") {
+ // If the value of minItems, minProperties, minLength is changed, the target schema should have a larger range.
+ if p.OldValue.(int) == -1 || p.OldValue.(int) > p.Value.(int) {
+ return false
+ }
+ continue
+ }
+ return false
+ } else if p.Type == jsondiff.OperationAdd {
+ return false
+ }
+ }
+ return true
+
+}
+
+func isSameTypeInJSON(sourceMetaData, targetMetaData *structpb.Struct) bool {
+ srcSchemaBytes, _ := json.Marshal(sourceMetaData.GetFields())
+ tgtSchemaBytes, _ := json.Marshal(targetMetaData.GetFields())
+
+ patch, err := jsondiff.CompareJSON(srcSchemaBytes, tgtSchemaBytes)
+ if err != nil {
+ return false
+ }
+ return len(patch) == 0
+}
+
// CastsFrom is a trivial type checker merely checks if types match exactly.
func (t trivialChecker) CastsFrom(upstreamType *flyte.LiteralType) bool {
// If upstream is an enum, it can be consumed as a string downstream
@@ -35,6 +84,17 @@ func (t trivialChecker) CastsFrom(upstreamType *flyte.LiteralType) bool {
return false
}
+ if upstreamType.GetSimple() == flyte.SimpleType_STRUCT && t.literalType.GetSimple() == flyte.SimpleType_STRUCT {
+ upstreamMetaData := upstreamType.GetMetadata()
+ downstreamMetaData := t.literalType.GetMetadata()
+
+ if upstreamMetaData == nil || downstreamMetaData == nil {
+ return true
+ }
+
+ return isSameTypeInJSON(upstreamMetaData, downstreamMetaData) || isSuperTypeInJSON(upstreamMetaData, downstreamMetaData)
+ }
+
// Ignore metadata when comparing types.
upstreamTypeCopy := *upstreamType
downstreamTypeCopy := *t.literalType
diff --git a/flytepropeller/pkg/compiler/validators/typing_test.go b/flytepropeller/pkg/compiler/validators/typing_test.go
index f2e407b986..2d27df5f34 100644
--- a/flytepropeller/pkg/compiler/validators/typing_test.go
+++ b/flytepropeller/pkg/compiler/validators/typing_test.go
@@ -5,6 +5,7 @@ import (
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/stretchr/testify/assert"
+ structpb2 "google.golang.org/protobuf/types/known/structpb"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
)
@@ -557,6 +558,417 @@ func TestMapCasting(t *testing.T) {
assert.True(t, castable, "castable from Struct to struct")
})
+ t.Run("dataclass cast to same dataclass with draft 2020-12 (one level)", func(t *testing.T) {
+ /*
+ @dataclass
+ class A:
+ a: int
+ */
+ castable := AreTypesCastable(
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "A"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "A"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ )
+ assert.True(t, castable, "dataclass castable with one level properties")
+ })
+
+ t.Run("dataclass cast to dataclass with draft 2020-12 (two level)", func(t *testing.T) {
+ /*
+ @dataclass
+ class A:
+ a: int
+
+ @dataclass
+ class B:
+ b: A
+ */
+
+ castable := AreTypesCastable(
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "b"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "B"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "b": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "required": {
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": {
+ Kind: &structpb.Value_StringValue{StringValue: "A"},
+ },
+ "properties": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "b"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "B"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "b": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "required": {
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": {
+ Kind: &structpb.Value_StringValue{StringValue: "A"},
+ },
+ "properties": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ )
+ assert.True(t, castable, "dataclass castable with two level properties")
+ })
+
+ t.Run("dataclass cast to superset dataclass with draft 2020-12 (one level)", func(t *testing.T) {
+ /*
+ @dataclass
+ class A:
+ a: int
+
+ @dataclass
+ class B(A):
+ b: Optional[str] = None
+ */
+ castable := AreTypesCastable(
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "B"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ "b": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "default": {
+ Kind: &structpb.Value_NullValue{},
+ },
+ "anyOf": {
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{
+ {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "string"},
+ },
+ },
+ },
+ },
+ },
+ {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "null"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ &core.LiteralType{
+ Type: &core.LiteralType_Simple{
+ Simple: core.SimpleType_STRUCT,
+ },
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb2.Value{
+ "required": &structpb.Value{
+ Kind: &structpb.Value_ListValue{
+ ListValue: &structpb.ListValue{
+ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "a"}}},
+ },
+ },
+ },
+ "title": &structpb.Value{
+ Kind: &structpb.Value_StringValue{StringValue: "A"},
+ },
+ "properties": &structpb.Value{
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "a": {
+ Kind: &structpb.Value_StructValue{
+ StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "integer"},
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "type": {
+ Kind: &structpb.Value_StringValue{StringValue: "object"},
+ },
+ "AdditionalProperties": {
+ Kind: &structpb.Value_BoolValue{BoolValue: false},
+ },
+ },
+ },
+ },
+ )
+ assert.True(t, castable, "dataclass castable to superset with one level properties")
+ })
+
t.Run("MismatchedMapNestLevels_Scalar", func(t *testing.T) {
castable := AreTypesCastable(
&core.LiteralType{
diff --git a/go.mod b/go.mod
index 65cbc7be79..aaeda42cf8 100644
--- a/go.mod
+++ b/go.mod
@@ -175,11 +175,11 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
- github.com/tidwall/gjson v1.17.0 // indirect
+ github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
- github.com/tidwall/pretty v1.2.0 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
- github.com/wI2L/jsondiff v0.5.0 // indirect
+ github.com/wI2L/jsondiff v0.6.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
diff --git a/go.sum b/go.sum
index d0d2474eec..fb4d1bc05b 100644
--- a/go.sum
+++ b/go.sum
@@ -1310,8 +1310,8 @@ github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJH
github.com/tidwall/gjson v1.6.8/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
github.com/tidwall/gjson v1.7.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
-github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
@@ -1319,8 +1319,9 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
-github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y=
github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
@@ -1341,8 +1342,8 @@ github.com/unrolled/secure v0.0.0-20181005190816-ff9db2ff917f/go.mod h1:mnPT77IA
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
-github.com/wI2L/jsondiff v0.5.0 h1:RRMTi/mH+R2aXcPe1VYyvGINJqQfC3R+KSEakuU1Ikw=
-github.com/wI2L/jsondiff v0.5.0/go.mod h1:qqG6hnK0Lsrz2BpIVCxWiK9ItsBCpIZQiv0izJjOZ9s=
+github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI=
+github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=