Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade spark-ext to spark 3.5 #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/spark-ext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<properties>
<scala.library.version>2.12.16</scala.library.version>
<scala.test.version>3.2.12</scala.test.version>
<spark.version>3.2.2</spark.version>
<spark.version>3.5.3</spark.version>
<spark.jackson.version>2.12.7</spark.jackson.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ private[optimization] object DateExpressions extends SupportedExpressions {
case Month(date) ⇒
checkChild(date)

case ParseToDate(left, format, child) ⇒
checkChild(left) && (format.isEmpty || checkChild(format.get)) && checkChild(child)
case ParseToDate(left, format, _, _) ⇒
checkChild(left) && (format.isEmpty || checkChild(format.get))

case Quarter(date) ⇒
checkChild(date)
Expand Down Expand Up @@ -101,7 +101,7 @@ private[optimization] object DateExpressions extends SupportedExpressions {
case Month(date) ⇒
Some(s"MINUTE(${childToString(date)})")

case ParseToDate(left, formatOption, _) ⇒
case ParseToDate(left, formatOption, _, _) ⇒
formatOption match {
case Some(format) ⇒
Some(s"PARSEDATETIME(${childToString(left)}, ${childToString(format)})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private[optimization] object MathExpressions extends SupportedExpressions {
case Rand(child, _) ⇒
checkChild(child)

case Round(child, scale) ⇒
case Round(child, scale, _) ⇒
checkChild(child) && checkChild(scale)

case Signum(child) ⇒
Expand Down Expand Up @@ -230,7 +230,7 @@ private[optimization] object MathExpressions extends SupportedExpressions {
case Rand(child, _) ⇒
Some(s"RAND(${childToString(child)})")

case Round(child, scale) ⇒
case Round(child, scale, _) ⇒
Some(s"ROUND(${childToString(child)}, ${childToString(scale)})")

case Signum(child) ⇒
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.ignite.spark.impl.optimization

import org.apache.ignite.IgniteException
import org.apache.spark.sql.catalyst.expressions.{Coalesce, EqualTo, Expression, Greatest, If, IfNull, IsNotNull, IsNull, Least, Literal, NullIf, Nvl2}
import org.apache.spark.sql.catalyst.expressions.{Coalesce, EqualTo, Expression, Greatest, If, IsNotNull, IsNull, Least, Literal, NullIf, Nvl2}

/**
* Object to support some built-in expressions like `nvl2` or `coalesce`.
Expand All @@ -32,9 +32,6 @@ private[optimization] object SystemExpressions extends SupportedExpressions {
case Greatest(children) ⇒
children.forall(checkChild)

case IfNull(left, right, _) ⇒
checkChild(left) && checkChild(right)

case Least(children) ⇒
children.forall(checkChild)

Expand Down Expand Up @@ -78,9 +75,6 @@ private[optimization] object SystemExpressions extends SupportedExpressions {
case Greatest(children) ⇒
Some(s"GREATEST(${children.map(childToString(_)).mkString(", ")})")

case IfNull(left, right, _) ⇒
Some(s"IFNULL(${childToString(left)}, ${childToString(right)})")

case Least(children) ⇒
Some(s"LEAST(${children.map(childToString(_)).mkString(", ")})")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.ignite.spark

import org.apache.commons.lang.StringUtils.equalsIgnoreCase
import org.apache.ignite.cache.CacheMode
import org.apache.ignite.cluster.ClusterNode
import org.apache.ignite.configuration.CacheConfiguration
Expand Down Expand Up @@ -136,7 +135,7 @@ package object impl {
* @return `True` if column is key.
*/
def isKeyColumn(table: GridQueryTypeDescriptor, column: String): Boolean =
contains(allKeyFields(table), column) || equalsIgnoreCase(table.keyFieldName, column)
contains(allKeyFields(table), column) || column.equalsIgnoreCase(table.keyFieldName)

/**
* @param table Table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.apache.spark.sql.SparkSession.Builder
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst._
import org.apache.spark.sql.catalyst.encoders._
import org.apache.spark.sql.catalyst.types.DataTypeUtils
import org.apache.spark.sql.catalyst.expressions.AttributeReference
import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, Range}
import org.apache.spark.sql.execution._
Expand Down Expand Up @@ -101,12 +102,12 @@ class IgniteSparkSession private(
/** @inheritdoc */
override def emptyDataset[T: Encoder]: Dataset[T] = {
val encoder = implicitly[Encoder[T]]
new Dataset(self, LocalRelation(encoder.schema.toAttributes), encoder)
new Dataset(self, LocalRelation(DataTypeUtils.toAttributes(encoder.schema)), encoder)
}

/** @inheritdoc */
override def createDataFrame(rows: java.util.List[Row], schema: StructType): DataFrame = {
Dataset.ofRows(self, LocalRelation.fromExternalRows(schema.toAttributes, rows.asScala))
Dataset.ofRows(self, LocalRelation.fromExternalRows(DataTypeUtils.toAttributes(schema), rows.asScala))
}

/** @inheritdoc */
Expand Down Expand Up @@ -141,7 +142,7 @@ class IgniteSparkSession private(
/** @inheritdoc */
override def createDataset[T: Encoder](data: Seq[T]): Dataset[T] = {
val enc = encoderFor[T]
val attributes = enc.schema.toAttributes
val attributes = DataTypeUtils.toAttributes(enc.schema)
val encoded = data.map(d => enc.createSerializer().apply(d))
val plan = new LocalRelation(attributes, encoded)
Dataset[T](self, plan)
Expand Down Expand Up @@ -179,7 +180,7 @@ class IgniteSparkSession private(
/** @inheritdoc */
override private[sql] def applySchemaToPythonRDD(rdd: RDD[Array[Any]], schema: StructType) = {
val rowRdd = rdd.map(r => python.EvaluatePython.makeFromJava(schema).asInstanceOf[InternalRow])
Dataset.ofRows(self, LogicalRDD(schema.toAttributes, rowRdd)(self))
Dataset.ofRows(self, LogicalRDD(DataTypeUtils.toAttributes(schema), rowRdd)(self))
}

/** @inheritdoc */
Expand All @@ -198,11 +199,13 @@ class IgniteSparkSession private(
/** @inheritdoc */
override def createDataFrame(rowRDD: RDD[Row],
schema: StructType): DataFrame = {

val catalystRows = {
val encoder = RowEncoder(schema).createSerializer()
val encoder = Encoders.row(schema).asInstanceOf[ExpressionEncoder[Row]].createSerializer()
rowRDD.map(encoder.apply)
}
val logicalPlan = LogicalRDD(schema.toAttributes, catalystRows)(self)
val logicalPlan = LogicalRDD(DataTypeUtils.toAttributes(schema), catalystRows)(self)

Dataset.ofRows(self, logicalPlan)
}

Expand Down