Skip to content

Commit

Permalink
Compiles in Spark 3.5 and Scala 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Nov 17, 2023
1 parent c9c7173 commit 88d944f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backends-velox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hivethriftserver_${scala.binary.version}</artifactId>
<artifactId>spark-hive-thriftserver_${scala.binary.version}</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hivethriftserver_${scala.binary.version}</artifactId>
<artifactId>spark-hive-thriftserver_${scala.binary.version}</artifactId>
<version>${spark.version}</version>
<scope>provided</scope>
<exclusions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ object Util {
def crossProduct[T](lists: Seq[Seq[T]]): Seq[Seq[T]] = {

/** list [a, b], element 1 => list + element => [a, b, 1] */
val appendElementToList: (ArrayBuffer[T], T) => ArrayBuffer[T] =
val appendElementToList: (Seq[T], T) => Seq[T] =
(list, element) => list :+ element

/** ([a, b], [1, 2]) ==> [a, b, 1], [a, b, 2] */
val appendAndGen: (ArrayBuffer[T], Seq[T]) => Seq[ArrayBuffer[T]] =
val appendAndGen: (Seq[T], Seq[T]) => Seq[Seq[T]] =
(list, elemsToAppend) => elemsToAppend.map(e => appendElementToList(list, e))

val firstListToJoin = lists.head
val startProduct = appendAndGen(new ArrayBuffer[T], firstListToJoin)
val startProduct = appendAndGen(new ArrayBuffer[T].toSeq, firstListToJoin)

/** ([ [a, b], [c, d] ], [1, 2]) -> [a, b, 1], [a, b, 2], [c, d, 1], [c, d, 2] */
val appendAndGenLists: (Seq[ArrayBuffer[T]], Seq[T]) => Seq[Seq[T]] =
(products, toJoin) => products.flatMap(product => appendAndGen(product, toJoin).toSeq)
val appendAndGenLists: (Seq[Seq[T]], Seq[T]) => Seq[Seq[T]] =
(products, toJoin) => products.flatMap(product => appendAndGen(product, toJoin).toSeq).toSeq
lists.tail.foldLeft(startProduct)(appendAndGenLists).map(_.toSeq)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class ToSubstraitType {
.zip(namedStruct.names().asScala)
.map { case ((t, d), name) => StructField(name, d, t.nullable()) }
.map(f => AttributeReference(f.name, f.dataType, f.nullable, f.metadata)())
.toSeq()
.toSeq
}
}

Expand Down

0 comments on commit 88d944f

Please sign in to comment.