You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2025/03/28 04:40:59 UTC
(datasketches-spark) 01/01: rename cast_to_binary to cast_as_binary
This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a commit to branch as_binary
in repository https://gitbox.apache.org/repos/asf/datasketches-spark.git
commit 3a4e900c9ad30d81866a83b2daec6b37eca0028f
Author: Jon <jm...@apache.org>
AuthorDate: Thu Mar 27 21:39:56 2025 -0700
rename cast_to_binary to cast_as_binary
---
python/src/datasketches_spark/common.py | 2 +-
python/tests/kll_test.py | 4 ++--
.../datasketches/common/{CastToBinary.scala => CastAsBinary.scala} | 6 +++---
.../sql/datasketches/common/DatasketchesFunctionRegistry.scala | 2 +-
.../scala/org/apache/spark/sql/datasketches/common/functions.scala | 2 +-
src/test/scala/org/apache/spark/sql/datasketches/kll/KllTest.scala | 4 ++--
6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/python/src/datasketches_spark/common.py b/python/src/datasketches_spark/common.py
index 31bc935..b0e477d 100644
--- a/python/src/datasketches_spark/common.py
+++ b/python/src/datasketches_spark/common.py
@@ -132,5 +132,5 @@ def _get_common_functions_class() -> JavaClass:
@try_remote_functions
-def cast_to_binary(col: "ColumnOrName") -> Column:
+def cast_as_binary(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns(_get_common_functions_class(), "cast_to_binary", col)
diff --git a/python/tests/kll_test.py b/python/tests/kll_test.py
index eb115fa..c530580 100644
--- a/python/tests/kll_test.py
+++ b/python/tests/kll_test.py
@@ -18,7 +18,7 @@
from pyspark.sql.types import StructType, StructField, BinaryType, DoubleType, IntegerType
#from datasketches import kll_doubles_sketch
-from datasketches_spark.common import cast_to_binary
+from datasketches_spark.common import cast_as_binary
from datasketches_spark.kll import *
def test_kll_build(spark):
@@ -48,7 +48,7 @@ def test_kll_build(spark):
df_types = df_agg.select(
"sketch",
- cast_to_binary("sketch").alias("asBinary")
+ cast_as_binary("sketch").alias("asBinary")
)
assert(df_types.schema["sketch"].dataType == KllDoublesSketchUDT())
assert(df_types.schema["asBinary"].dataType == BinaryType())
diff --git a/src/main/scala/org/apache/spark/sql/datasketches/common/CastToBinary.scala b/src/main/scala/org/apache/spark/sql/datasketches/common/CastAsBinary.scala
similarity index 94%
rename from src/main/scala/org/apache/spark/sql/datasketches/common/CastToBinary.scala
rename to src/main/scala/org/apache/spark/sql/datasketches/common/CastAsBinary.scala
index 5b51fc8..e8a373a 100644
--- a/src/main/scala/org/apache/spark/sql/datasketches/common/CastToBinary.scala
+++ b/src/main/scala/org/apache/spark/sql/datasketches/common/CastAsBinary.scala
@@ -27,17 +27,17 @@ import org.apache.spark.sql.catalyst.expressions.codegen.{CodeBlock, CodegenCont
_FUNC_(expr) - Returns the input as a BinaryType (Array[Byte]). """
//group = "misc_funcs",
)
-case class CastToBinary(sketchExpr: Expression)
+case class CastAsBinary(sketchExpr: Expression)
extends UnaryExpression
with ExpectsInputTypes {
override def child: Expression = sketchExpr
- override protected def withNewChildInternal(newChild: Expression): CastToBinary = {
+ override protected def withNewChildInternal(newChild: Expression): CastAsBinary = {
copy(sketchExpr = newChild)
}
- override def prettyName: String = "cast_to_binary"
+ override def prettyName: String = "cast_as_binary"
override def inputTypes: Seq[AbstractDataType] = Seq(AnyDataType)
diff --git a/src/main/scala/org/apache/spark/sql/datasketches/common/DatasketchesFunctionRegistry.scala b/src/main/scala/org/apache/spark/sql/datasketches/common/DatasketchesFunctionRegistry.scala
index 29207b0..bb0b970 100644
--- a/src/main/scala/org/apache/spark/sql/datasketches/common/DatasketchesFunctionRegistry.scala
+++ b/src/main/scala/org/apache/spark/sql/datasketches/common/DatasketchesFunctionRegistry.scala
@@ -62,6 +62,6 @@ trait DatasketchesFunctionRegistry {
// object for common functions
object CommonFunctionRegistry extends DatasketchesFunctionRegistry {
override val expressions: Map[String, (ExpressionInfo, FunctionBuilder)] = Map(
- expression[CastToBinary]("cast_to_binary"),
+ expression[CastAsBinary]("cast_to_binary"),
)
}
diff --git a/src/main/scala/org/apache/spark/sql/datasketches/common/functions.scala b/src/main/scala/org/apache/spark/sql/datasketches/common/functions.scala
index ff8fcf0..7150e61 100644
--- a/src/main/scala/org/apache/spark/sql/datasketches/common/functions.scala
+++ b/src/main/scala/org/apache/spark/sql/datasketches/common/functions.scala
@@ -22,7 +22,7 @@ import org.apache.spark.sql.Column
object functions extends DatasketchesScalaFunctionBase {
def cast_to_binary(expr: Column): Column = withExpr {
- new CastToBinary(expr.expr)
+ new CastAsBinary(expr.expr)
}
def sketch_to_binary(columnName: String): Column = {
diff --git a/src/test/scala/org/apache/spark/sql/datasketches/kll/KllTest.scala b/src/test/scala/org/apache/spark/sql/datasketches/kll/KllTest.scala
index acb8f0d..873fa68 100644
--- a/src/test/scala/org/apache/spark/sql/datasketches/kll/KllTest.scala
+++ b/src/test/scala/org/apache/spark/sql/datasketches/kll/KllTest.scala
@@ -26,7 +26,7 @@ import org.apache.datasketches.kll.KllDoublesSketch
import org.apache.spark.sql.datasketches.kll.functions._
import org.apache.spark.sql.datasketches.kll.types.KllDoublesSketchType
import org.apache.spark.sql.datasketches.common.{SparkSessionManager, CommonFunctionRegistry}
-import org.apache.spark.sql.datasketches.common.functions.cast_to_binary
+import org.apache.spark.sql.datasketches.common.functions.cast_as_binary
class KllTest extends SparkSessionManager {
import spark.implicits._
@@ -118,7 +118,7 @@ class KllTest extends SparkSessionManager {
val cdf_excl = Array[Double](0.2, 0.49, 1.0, 1.0)
compareArrays(cdf_excl, pmfCdfResult.getAs[Seq[Double]]("cdf_exclusive").toArray)
- val resultSchema = sketchDf.select($"sketch", cast_to_binary($"sketch").as("asBinary")).schema
+ val resultSchema = sketchDf.select($"sketch", cast_as_binary($"sketch").as("asBinary")).schema
assert(resultSchema.apply("sketch").dataType.equals(KllDoublesSketchType))
assert(resultSchema.apply("asBinary").dataType.equals(BinaryType))
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org