Github user hvanhovell commented on a diff in the pull request: https://github.com/apache/spark/pull/16886#discussion_r100544404 --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala --- @@ -218,22 +220,33 @@ private[hive] trait HiveInspectors { case c: Class[_] if c == java.lang.Float.TYPE => FloatType case c: Class[_] if c == java.lang.Boolean.TYPE => BooleanType - case c: Class[_] if c.isArray => ArrayType(javaClassToDataType(c.getComponentType)) + case c: Class[_] if c.isArray => ArrayType(javaTypeToDataType(c.getComponentType)) // Hive seems to return this for struct types? case c: Class[_] if c == classOf[java.lang.Object] => NullType - // java list type unsupported + // raw java list type unsupported case c: Class[_] if c == classOf[java.util.List[_]] => throw new AnalysisException( - "List type in java is unsupported because " + - "JVM type erasure makes spark fail to catch a component type in List<>") + "Raw list type in java is unsupported because Spark cannot infer the element type.") - // java map type unsupported + // raw java map type unsupported case c: Class[_] if c == classOf[java.util.Map[_, _]] => throw new AnalysisException( - "Map type in java is unsupported because " + - "JVM type erasure makes spark fail to catch key and value types in Map<>") + "Raw map type in java is unsupported because Spark cannot infer key and value types.") + + case p: ParameterizedType if p.getRawType == classOf[java.util.List[_]] => + val Array(elementType) = p.getActualTypeArguments + ArrayType(javaTypeToDataType(elementType)) + + case p: ParameterizedType if p.getRawType == classOf[java.util.Map[_, _]] => + val Array(keyType, valueType) = p.getActualTypeArguments + MapType(javaTypeToDataType(keyType), javaTypeToDataType(valueType)) + + case _: WildcardType => + throw new AnalysisException( + "Collection types with wildcards (e.g. List<?> or Map<?, ?>) are unsupported because " + + "Spark cannot infer the data type for these type parameters.") --- End diff -- `BoundedType` is a mockito class and not a JVM class. A bound type that cannot be translated to a `DataType` is caught by the final case in the match.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org