Skip to content

Commit

Permalink
fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed May 4, 2024
1 parent 9cdb571 commit c62a7b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object CometCast {
"instead of 1.4E-45"))
case DataTypes.BinaryType =>
// https://github.com/apache/datafusion-comet/issues/377
Unsupported
Incompatible(Some("Only works for binary data representing valid UTF-8 strings"))
case _ => Unsupported
}
}
Expand Down
16 changes: 15 additions & 1 deletion spark/src/test/scala/org/apache/comet/CometCastSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,12 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
// CAST from BinaryType

ignore("cast BinaryType to StringType") {
// TODO implement this
// https://github.com/apache/datafusion-comet/issues/377
castTest(generateBinary(), DataTypes.StringType)
}

test("cast BinaryType to StringType - valid UTF-8 inputs") {
castTest(generateStrings(numericPattern, 8).toDF("a"), DataTypes.StringType)
}

// CAST from DateType
Expand Down Expand Up @@ -831,6 +835,16 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
Range(0, dataSize).map(_ => generateString(r, chars, maxLen))
}

private def generateBinary(): DataFrame = {
val r = new Random(0)
val bytes = new Array[Byte](8)
val values: Seq[Array[Byte]] = Range(0, dataSize).map(_ => {
r.nextBytes(bytes)
bytes.clone()
})
values.toDF("a")
}

private def withNulls[T](values: Seq[T]): Seq[Option[T]] = {
values.map(v => Some(v)) ++ Seq(None)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ class CometExecSuite extends CometTestBase {
dataTypes.map { subqueryType =>
withSQLConf(
CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true",
CometConf.COMET_COLUMNAR_SHUFFLE_ENABLED.key -> "true") {
CometConf.COMET_COLUMNAR_SHUFFLE_ENABLED.key -> "true",
CometConf.COMET_CAST_ALLOW_INCOMPATIBLE.key -> "true") {
withParquetTable((0 until 5).map(i => (i, i + 1)), "tbl") {
var column1 = s"CAST(max(_1) AS $subqueryType)"
if (subqueryType == "BINARY") {
Expand Down

0 comments on commit c62a7b0

Please sign in to comment.