Skip to content

Commit a549807

Browse files
committed
typelevel#787 - use shim'd joinWith - requires extra implicit
1 parent 13177e7 commit a549807

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

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

+25-26
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,16 @@ import java.util
44
import frameless.functions.CatalystExplodableCollection
55
import frameless.ops._
66
import org.apache.spark.rdd.RDD
7-
import org.apache.spark.sql.{ Column, DataFrame, Dataset, SparkSession }
8-
import org.apache.spark.sql.catalyst.expressions.{
9-
Attribute,
10-
AttributeReference,
11-
Literal
12-
}
13-
import org.apache.spark.sql.catalyst.plans.logical.{ Join, JoinHint }
7+
import org.apache.spark.sql.{Column, DataFrame, Dataset, ShimUtils, SparkSession}
8+
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference, Literal}
9+
import org.apache.spark.sql.catalyst.plans.logical.{Join, JoinHint}
1410
import org.apache.spark.sql.catalyst.plans.Inner
1511
import org.apache.spark.sql.ShimUtils.column
1612
import org.apache.spark.sql.types.StructType
1713
import shapeless._
1814
import shapeless.labelled.FieldType
19-
import shapeless.ops.hlist.{
20-
Diff,
21-
IsHCons,
22-
Mapper,
23-
Prepend,
24-
ToTraversable,
25-
Tupler
26-
}
27-
import shapeless.ops.record.{ Keys, Modifier, Remover, Values }
15+
import shapeless.ops.hlist.{Diff, IsHCons, Mapper, Prepend, ToTraversable, Tupler}
16+
import shapeless.ops.record.{Keys, Modifier, Remover, Values}
2817

2918
import scala.language.experimental.macros
3019

@@ -767,7 +756,8 @@ class TypedDataset[T] protected[frameless] (
767756
e: TypedEncoder[(T, U)]
768757
): TypedDataset[(T, U)] =
769758
new TypedDataset(
770-
self.dataset.joinWith(other.dataset, column(Literal(true)), "cross")
759+
ShimUtils.joinWith(dataset, other.dataset, column(Literal(true)), "cross")(TypedExpressionEncoder[(T, U)])
760+
//self.dataset.joinWith(other.dataset, column(Literal(true)), "cross")
771761
)
772762

773763
/**
@@ -778,14 +768,17 @@ class TypedDataset[T] protected[frameless] (
778768
other: TypedDataset[U]
779769
)(condition: TypedColumn[T with U, Boolean]
780770
)(implicit
781-
e: TypedEncoder[(Option[T], Option[U])]
771+
e: TypedEncoder[(Option[T], Option[U])],
772+
to: TypedEncoder[(T, U)]
782773
): TypedDataset[(Option[T], Option[U])] =
783774
new TypedDataset(
784-
self.dataset
775+
ShimUtils.joinWith(dataset, other.dataset, condition.untyped, "full")(TypedExpressionEncoder[(T, U)])
776+
.as[(Option[T], Option[U])](TypedExpressionEncoder[(Option[T], Option[U])])
777+
/*self.dataset
785778
.joinWith(other.dataset, condition.untyped, "full")
786779
.as[(Option[T], Option[U])](
787780
TypedExpressionEncoder[(Option[T], Option[U])]
788-
)
781+
)*/
789782
)
790783

791784
/**
@@ -820,12 +813,15 @@ class TypedDataset[T] protected[frameless] (
820813
other: TypedDataset[U]
821814
)(condition: TypedColumn[T with U, Boolean]
822815
)(implicit
823-
e: TypedEncoder[(T, Option[U])]
816+
e: TypedEncoder[(T, Option[U])],
817+
to: TypedEncoder[(T, U)]
824818
): TypedDataset[(T, Option[U])] =
825819
new TypedDataset(
826-
self.dataset
827-
.joinWith(other.dataset, condition.untyped, "left_outer")
820+
ShimUtils.joinWith(dataset, other.dataset, condition.untyped, "left_outer")(TypedExpressionEncoder[(T, U)])
828821
.as[(T, Option[U])](TypedExpressionEncoder[(T, Option[U])])
822+
/*self.dataset
823+
.joinWith(other.dataset, condition.untyped, "left_outer")
824+
.as[(T, Option[U])](TypedExpressionEncoder[(T, Option[U])])*/
829825
)
830826

831827
/**
@@ -864,12 +860,15 @@ class TypedDataset[T] protected[frameless] (
864860
other: TypedDataset[U]
865861
)(condition: TypedColumn[T with U, Boolean]
866862
)(implicit
867-
e: TypedEncoder[(Option[T], U)]
863+
e: TypedEncoder[(Option[T], U)],
864+
to: TypedEncoder[(T, U)]
868865
): TypedDataset[(Option[T], U)] =
869866
new TypedDataset(
870-
self.dataset
871-
.joinWith(other.dataset, condition.untyped, "right_outer")
867+
ShimUtils.joinWith( self.dataset, other.dataset, condition.untyped, "right_outer")(TypedExpressionEncoder[(T, U)])
872868
.as[(Option[T], U)](TypedExpressionEncoder[(Option[T], U)])
869+
/*self.dataset
870+
.joinWith(other.dataset, condition.untyped, "right_outer")
871+
.as[(Option[T], U)](TypedExpressionEncoder[(Option[T], U)])*/
873872
)
874873

875874
private def disambiguate(join: Join): Join = {

0 commit comments

Comments
 (0)