From b7b1045a120ebfde54158487d29327bc77d27c9d Mon Sep 17 00:00:00 2001 From: Andres Gomez Ferrer Date: Fri, 29 Dec 2023 16:48:00 +0100 Subject: [PATCH 1/2] Add complex types scala tests Signed-off-by: Andres Gomez Ferrer Fix Signed-off-by: Hongxin Liang Fix Signed-off-by: Hongxin Liang --- .../flytekitscala/SdkScalaTypeTest.scala | 52 +++++++++++++++++-- pom.xml | 2 +- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/flytekit-scala-tests/src/test/scala/org/flyte/flytekitscala/SdkScalaTypeTest.scala b/flytekit-scala-tests/src/test/scala/org/flyte/flytekitscala/SdkScalaTypeTest.scala index 93014c55..92cafad9 100644 --- a/flytekit-scala-tests/src/test/scala/org/flyte/flytekitscala/SdkScalaTypeTest.scala +++ b/flytekit-scala-tests/src/test/scala/org/flyte/flytekitscala/SdkScalaTypeTest.scala @@ -82,7 +82,8 @@ class SdkScalaTypeTest { floats: SdkBindingData[List[Double]], booleans: SdkBindingData[List[Boolean]], datetimes: SdkBindingData[List[Instant]], - durations: SdkBindingData[List[Duration]] + durations: SdkBindingData[List[Duration]], + generics: SdkBindingData[List[ScalarNested]] ) case class MapInput( @@ -91,7 +92,8 @@ class SdkScalaTypeTest { floatMap: SdkBindingData[Map[String, Double]], booleanMap: SdkBindingData[Map[String, Boolean]], datetimeMap: SdkBindingData[Map[String, Instant]], - durationMap: SdkBindingData[Map[String, Duration]] + durationMap: SdkBindingData[Map[String, Duration]], + genericMap: SdkBindingData[Map[String, ScalarNested]] ) case class ComplexInput( @@ -352,7 +354,8 @@ class SdkScalaTypeTest { "floats" -> createCollectionVar(SimpleType.FLOAT), "booleans" -> createCollectionVar(SimpleType.BOOLEAN), "datetimes" -> createCollectionVar(SimpleType.DATETIME), - "durations" -> createCollectionVar(SimpleType.DURATION) + "durations" -> createCollectionVar(SimpleType.DURATION), + "generics" -> createCollectionVar(SimpleType.STRUCT) ).asJava val output = SdkScalaType[CollectionInput].getVariableMap @@ -448,6 +451,25 @@ class SdkScalaTypeTest { ), durations = SdkBindingDataFactory.of( List(Duration.ofSeconds(123, 456), Duration.ofSeconds(543, 21)) + ), + generics = SdkBindingDataFactory.of( + SdkLiteralTypes.generics[ScalarNested](), + List( + ScalarNested( + "foo", + Some("bar"), + Some(ScalarNestedNested("foo", Some("bar"))), + List(ScalarNestedNested("foo", Some("bar"))), + Map("foo" -> ScalarNestedNested("foo", Some("bar"))) + ), + ScalarNested( + "foo2", + Some("bar2"), + Some(ScalarNestedNested("foo2", Some("bar2"))), + List(ScalarNestedNested("foo2", Some("bar2"))), + Map("foo2" -> ScalarNestedNested("foo2", Some("bar2"))) + ) + ) ) ) @@ -466,7 +488,8 @@ class SdkScalaTypeTest { "floatMap" -> createMapVar(SimpleType.FLOAT), "booleanMap" -> createMapVar(SimpleType.BOOLEAN), "datetimeMap" -> createMapVar(SimpleType.DATETIME), - "durationMap" -> createMapVar(SimpleType.DURATION) + "durationMap" -> createMapVar(SimpleType.DURATION), + "genericMap" -> createMapVar(SimpleType.STRUCT) ).asJava val output = SdkScalaType[MapInput].getVariableMap @@ -495,7 +518,26 @@ class SdkScalaTypeTest { datetimeMap = SdkBindingDataFactory.of(Map("k5" -> Instant.ofEpochMilli(321L))), durationMap = - SdkBindingDataFactory.of(Map("k6" -> Duration.ofSeconds(543, 21))) + SdkBindingDataFactory.of(Map("k6" -> Duration.ofSeconds(543, 21))), + genericMap = SdkBindingDataFactory.of( + SdkLiteralTypes.generics[ScalarNested](), + Map( + "a" -> ScalarNested( + "foo2", + Some("bar2"), + Some(ScalarNestedNested("foo2", Some("bar2"))), + List(ScalarNestedNested("foo2", Some("bar2"))), + Map("foo2" -> ScalarNestedNested("foo2", Some("bar2"))) + ), + "b" -> ScalarNested( + "foo2", + Some("bar2"), + Some(ScalarNestedNested("foo2", Some("bar2"))), + List(ScalarNestedNested("foo2", Some("bar2"))), + Map("foo2" -> ScalarNestedNested("foo2", Some("bar2"))) + ) + ) + ) ) val output = SdkScalaType[MapInput].fromLiteralMap( diff --git a/pom.xml b/pom.xml index 80b75a63..b189e965 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ flytekit-api flytekit-jackson flytekit-java - flytekit-scala_2.12 + flytekit-scala_2.13 flytekit-scala-tests flytekit-testing From d2261c99163f9f87d645771c3c023f820da753c8 Mon Sep 17 00:00:00 2001 From: Andres Gomez Ferrer Date: Fri, 29 Dec 2023 17:17:16 +0100 Subject: [PATCH 2/2] Fix modules Signed-off-by: Andres Gomez Ferrer --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b189e965..80b75a63 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ flytekit-api flytekit-jackson flytekit-java - + flytekit-scala_2.12 flytekit-scala_2.13 flytekit-scala-tests flytekit-testing