Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ case class NTile(buckets: Expression) extends RowNumberLike with SizeBasedWindow
// for each partition.
override def checkInputDataTypes(): TypeCheckResult = {
if (!buckets.foldable) {
DataTypeMismatch(
return DataTypeMismatch(
errorSubClass = "NON_FOLDABLE_INPUT",
messageParameters = Map(
"inputName" -> "buckets",
Expand All @@ -861,7 +861,7 @@ case class NTile(buckets: Expression) extends RowNumberLike with SizeBasedWindow
}

if (buckets.dataType != IntegerType) {
DataTypeMismatch(
return DataTypeMismatch(
errorSubClass = "UNEXPECTED_INPUT_TYPE",
messageParameters = Map(
"paramIndex" -> "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,40 @@ class AnalysisErrorSuite extends AnalysisTest {
"inputType" -> "\"BOOLEAN\"",
"requiredType" -> "\"INT\""))

errorClassTest(
"the buckets of ntile window function is not foldable",
testRelation2.select(
WindowExpression(
NTile(Literal(99.9f)),
WindowSpecDefinition(
UnresolvedAttribute("a") :: Nil,
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
UnspecifiedFrame)).as("window")),
errorClass = "DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE",
messageParameters = Map(
"sqlExpr" -> "\"ntile(99.9)\"",
"paramIndex" -> "1",
"inputSql" -> "\"99.9\"",
"inputType" -> "\"FLOAT\"",
"requiredType" -> "\"INT\""))


errorClassTest(
"the buckets of ntile window function is not int literal",
testRelation2.select(
WindowExpression(
NTile(AttributeReference("b", IntegerType)()),
WindowSpecDefinition(
UnresolvedAttribute("a") :: Nil,
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
UnspecifiedFrame)).as("window")),
errorClass = "DATATYPE_MISMATCH.NON_FOLDABLE_INPUT",
messageParameters = Map(
"sqlExpr" -> "\"ntile(b)\"",
"inputName" -> "buckets",
"inputExpr" -> "\"b\"",
"inputType" -> "\"INT\""))

errorClassTest(
"unresolved attributes",
testRelation.select($"abcd"),
Expand Down