Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/10283#discussion_r48048560
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LocalRelation.scala
---
@@ -29,20 +30,28 @@ object LocalRelation {
new LocalRelation(StructType(output1 +: output).toAttributes)
}
+ def fromInternalRows(output: Seq[Attribute], data: Seq[InternalRow]):
LocalRelation = {
+ val projection =
UnsafeProjection.create(output.map(_.dataType).toArray)
+ new LocalRelation(output, data.map(projection(_).copy()))
+ }
+
def fromExternalRows(output: Seq[Attribute], data: Seq[Row]):
LocalRelation = {
val schema = StructType.fromAttributes(output)
val converter =
CatalystTypeConverters.createToCatalystConverter(schema)
- LocalRelation(output, data.map(converter(_).asInstanceOf[InternalRow]))
+ val internalRows = data.map(converter(_).asInstanceOf[InternalRow])
+ fromInternalRows(output, internalRows)
}
- def fromProduct(output: Seq[Attribute], data: Seq[Product]):
LocalRelation = {
+ def fromProduct[T <: Product : ExpressionEncoder](
+ output: Seq[Attribute],
+ data: Seq[T]): LocalRelation = {
+ val encoder = implicitly[ExpressionEncoder[T]]
--- End diff --
we can use `encoderFor[T]` here
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]