Skip to content

Commit

Permalink
fix: issue #2 Join fails due to type confusion for String
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobfi committed Dec 13, 2022
1 parent 0504310 commit fa2f685
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.bsp/
.idea/
target/
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ name := "crossbow"

version := "0.1.5"

scalaVersion := "2.13.3"
scalaVersion := "2.13.6"
crossScalaVersions := Seq(scalaVersion.value, "2.12.12", "2.11.12")

scalacOptions += "-deprecation"
scalacOptions ++= Seq("-deprecation", "-feature", "-language:existentials")

libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.0" % "test"
Expand All @@ -16,7 +16,7 @@ libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.0" % "test
* Maven specific settings for publishing to Maven central.
*/
publishMavenStyle := true
publishArtifact in Test := false
Test / publishArtifact := false
pomIncludeRepository := { _ => false }
publishTo := {
val nexus = "https://oss.sonatype.org/"
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.3.13
sbt.version = 1.6.2
15 changes: 15 additions & 0 deletions src/main/scala/com/audienceproject/crossbow/expr/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,29 @@ package object expr {

case class AnyType(runtimeType: ru.Type) extends Type {
override def toString: String = runtimeType.toString

override def equals(obj: Any): Boolean = obj match {
case AnyType(otherRuntimeType) => runtimeType =:= otherRuntimeType
case _ => false
}
}

case class ProductType(elementTypes: Type*) extends Type {
override def toString: String = s"(${elementTypes.mkString(",")})"

override def equals(obj: Any): Boolean = obj match {
case ProductType(otherElementTypes@_*) => elementTypes == otherElementTypes
case _ => false
}
}

case class ListType(elementType: Type) extends Type {
override def toString: String = s"List($elementType)"

override def equals(obj: Any): Boolean = obj match {
case ListType(otherElementType) => elementType == otherElementType
case _ => false
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ class SortMergeJoinTest extends AnyFunSuite {
assert(joined == expected)
}

test("Join on scala.Predef.String and java.lang.String") {
case class Score(name: String, points: Int)
val scores = Seq(Score("abc", 20), Score("def", 40)).flatMap(Score.unapply).toDataFrame("name", "points")
val names = Seq("abc", "def").toDataFrame("name")
val joined = scores.join(names, $"name")
assert(joined.rowCount == 2)
}

}

0 comments on commit fa2f685

Please sign in to comment.