Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
GideonPotok committed May 22, 2024
1 parent 51f397c commit 1fae9d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.spark.sql.catalyst.trees.UnaryLike
import org.apache.spark.sql.catalyst.types.PhysicalDataType
import org.apache.spark.sql.catalyst.util.{CollationFactory, GenericArrayData, UnsafeRowUtils}
import org.apache.spark.sql.errors.QueryCompilationErrors
import org.apache.spark.sql.types.{AbstractDataType, AnyDataType, ArrayType, BooleanType, DataType, StringType, StructType}
import org.apache.spark.sql.types.{AbstractDataType, AnyDataType, ArrayType, BooleanType, DataType, StringType}
import org.apache.spark.unsafe.types.UTF8String
import org.apache.spark.util.collection.OpenHashMap

Expand Down Expand Up @@ -53,15 +53,14 @@ case class Mode(
val defaultCheck = super.checkInputDataTypes()
if (defaultCheck.isFailure) {
defaultCheck
} else if (UnsafeRowUtils.isBinaryStable(child.dataType) ||
child.dataType.isInstanceOf[StringType]) {
defaultCheck
} else {
child.dataType match {
case _: StructType | _: ArrayType if !UnsafeRowUtils.isBinaryStable(child.dataType) =>
TypeCheckResult.TypeCheckFailure(
s"Input to function mode was a complex type" +
s" with non-binary collated fields," +
s" which is not yet supported by mode.")
case _ => TypeCheckResult.TypeCheckSuccess
}
TypeCheckResult.TypeCheckFailure(
"The input to the function 'mode' was a complex type with non-binary collated fields," +
" which are currently not supported by 'mode'."
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1510,8 +1510,8 @@ class CollationSQLExpressionsSuite
// Input to function mode was a complex type with strings collated on non-binary
// collations, which is not yet supported.. SQLSTATE: 42K09; line 1 pos 13;
val params = Seq(("sqlExpr", "\"mode(i)\""),
("msg", "Input to function mode was a complex type with non-binary collated fields" +
", which is not yet supported by mode."),
("msg", "The input to the function 'mode' was a complex type with non-binary collated" +
" fields, which are currently not supported by 'mode'."),
("hint", "")).toMap
checkError(
exception = intercept[AnalysisException] {
Expand Down Expand Up @@ -1559,8 +1559,8 @@ class CollationSQLExpressionsSuite
// Input to function mode was a complex type with strings collated on non-binary
// collations, which is not yet supported.. SQLSTATE: 42K09; line 1 pos 13;
val params = Seq(("sqlExpr", "\"mode(i)\""),
("msg", "Input to function mode was a complex type with non-binary collated fields" +
", which is not yet supported by mode."),
("msg", "The input to the function 'mode' was a complex type with non-binary collated" +
" fields, which are currently not supported by 'mode'."),
("hint", "")).toMap
checkError(
exception = intercept[AnalysisException] {
Expand Down Expand Up @@ -1606,8 +1606,8 @@ class CollationSQLExpressionsSuite
val query = s"SELECT lower(element_at(element_at(mode(i), 1).s1.a2, 1)) FROM ${tableName}"
if(t.collationId == "utf8_binary_lcase" || t.collationId == "unicode_ci") {
val params = Seq(("sqlExpr", "\"mode(i)\""),
("msg", "Input to function mode was a complex type with non-binary collated fields" +
", which is not yet supported by mode."),
("msg", "The input to the function 'mode' was a complex type with non-binary collated" +
" fields, which are currently not supported by 'mode'."),
("hint", "")).toMap
checkError(
exception = intercept[AnalysisException] {
Expand Down

0 comments on commit 1fae9d9

Please sign in to comment.