squito commented on code in PR #48304:
URL: https://github.com/apache/spark/pull/48304#discussion_r1811724997


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/JavaTypeInferenceSuite.scala:
##########
@@ -279,4 +279,36 @@ class JavaTypeInferenceSuite extends SparkFunSuite {
       ))
     assert(encoder === expected)
   }
+
+  test("SPARK-46679: resolve generics with multi-level inheritance different 
type names") {
+    val encoder = JavaTypeInference.encoderFor(classOf[CompanyWrapper])
+    val expected =
+      JavaBeanEncoder(ClassTag(classOf[CompanyWrapper]), Seq(
+        encoderField("name", StringEncoder),
+        encoderField("team", 
JavaBeanEncoder(ClassTag(classOf[Team[PersonData]]), Seq(
+          encoderField("name", StringEncoder),
+          encoderField("person", 
JavaBeanEncoder(ClassTag(classOf[PersonData]), Seq(
+            encoderField("firstName", StringEncoder),
+            encoderField("id", StringEncoder)
+          )))
+        )))
+      ))
+    assert(encoder === expected)
+  }
+
+  test("SPARK-46679: resolve generics with multi-level inheritance same type 
names") {
+    val encoder = JavaTypeInference.encoderFor(classOf[CompanyWrapperT])

Review Comment:
   I spent a bit of time playing around with the test bean classes, and I think 
the actual minimal example to reproduce the bug is
   
   ```
     static class Foo<T> {
       T t;
   
       public void setT(T t) {
         this.t = t;
       }
   
       public T getT() {
         return t;
       }
     }
     static class InnerWrapper<U> {
       Foo<U> foo;
   
       public void setFoo(Foo<U> foo) {
         this.foo = foo;
       }
   
       public Foo<U> getFoo() {
         return foo;
       }
     }
     static class OuterWrapper extends InnerWrapper<String> {}
   ```
   
   while I know this test case came from the user's report, I think it would 
actually be easier for another developer to understand the point of this test 
case with the more minimal example.
   
   I do think there is value in having the test cases with both combos of names 
for the type parameters still.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to