Skip to content

Commit

Permalink
Support Spark4 Column Node API
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Aug 20, 2024
1 parent 568eac0 commit d47f0b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package uk.co.gresearch.spark.diff.comparator

import org.apache.spark.extension.ExpressionExtension
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.encoders.encoderFor
import org.apache.spark.sql.catalyst.expressions.codegen.Block.BlockHelper
Expand All @@ -31,8 +32,7 @@ trait EquivDiffComparator[T] extends DiffComparator {

private trait ExpressionEquivDiffComparator[T] extends EquivDiffComparator[T] {
def equiv(left: Expression, right: Expression): EquivExpression[T]
def equiv(left: Column, right: Column): Column =
new Column(equiv(left.expr, right.expr).asInstanceOf[Expression])
def equiv(left: Column, right: Column): Column = equiv(left.expr, right.expr).toColumn
}

trait TypedEquivDiffComparator[T] extends EquivDiffComparator[T] with TypedDiffComparator
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/uk/co/gresearch/spark/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package uk.co.gresearch

import org.apache.spark.extension.ExpressionExtension
import org.apache.spark.internal.Logging
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.expressions.NamedExpression
Expand Down Expand Up @@ -271,7 +272,7 @@ package object spark extends Logging with SparkVersion with BuildVersion {
* result tick value column
*/
def timestampToDotNetTicks(timestampColumn: Column): Column =
unixEpochTenthMicrosToDotNetTicks(new Column(UnixMicros.unixMicros(timestampColumn.expr)) * 10)
unixEpochTenthMicrosToDotNetTicks(UnixMicros.unixMicros(timestampColumn.expr).toColumn * 10)

/**
* Convert a Spark timestamp to a .Net `DateTime.Ticks` timestamp. The input column must be of TimestampType.
Expand Down

0 comments on commit d47f0b7

Please sign in to comment.