Skip to content

Commit 765cad9

Browse files
committed
Minor refactoring
1 parent f086305 commit 765cad9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dataset/src/main/scala/frameless/TypedDataset.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -750,15 +750,17 @@ class TypedDataset[T] protected[frameless](val dataset: Dataset[T])(implicit val
750750

751751
// now we need to unpack `Tuple1[A]` to `A`
752752

753-
TypedEncoder[A].catalystRepr match {
754-
case StructType(_) =>
753+
ea.catalystRepr match {
754+
case StructType(_) => {
755755
// if column is struct, we use all its fields
756756
val df = tuple1
757757
.dataset
758758
.selectExpr("_1.*")
759759
.as[A](TypedExpressionEncoder[A])
760760

761761
TypedDataset.create(df)
762+
}
763+
762764
case other =>
763765
// for primitive types `Tuple1[A]` has the same schema as `A`
764766
TypedDataset.create(tuple1.dataset.as[A](TypedExpressionEncoder[A]))
@@ -1217,9 +1219,9 @@ class TypedDataset[T] protected[frameless](val dataset: Dataset[T])(implicit val
12171219
val df = dataset.toDF()
12181220

12191221
val trans =
1220-
df
1221-
.withColumn(column.value.name, sparkExplode(df(column.value.name)))
1222+
df.withColumn(column.value.name, sparkExplode(df(column.value.name)))
12221223
.as[Out](TypedExpressionEncoder[Out])
1224+
12231225
TypedDataset.create[Out](trans)
12241226
}
12251227

@@ -1267,6 +1269,7 @@ class TypedDataset[T] protected[frameless](val dataset: Dataset[T])(implicit val
12671269
// we rename the original Row columns to avoid this collision
12681270
val dfr = df.toDF(columnNamesRenamed: _*)
12691271
val exploded = dfr.select(sparkCol("*"), sparkExplode(dfr(columnRenamed)))
1272+
12701273
val trans =
12711274
exploded
12721275
// map explode explodes it into [key, value] columns
@@ -1277,6 +1280,7 @@ class TypedDataset[T] protected[frameless](val dataset: Dataset[T])(implicit val
12771280
// rename columns back and form the result
12781281
.toDF(columnNames: _*)
12791282
.as[Out](TypedExpressionEncoder[Out])
1283+
12801284
TypedDataset.create[Out](trans)
12811285
}
12821286

0 commit comments

Comments
 (0)