Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-35728][SQL][TESTS] Check multiply/divide of day-time intervals of any fields by numeric #33014

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,7 +28,7 @@ import org.apache.spark.sql.catalyst.util.{DateTimeTestUtils, IntervalUtils}
import org.apache.spark.sql.catalyst.util.DateTimeConstants._
import org.apache.spark.sql.catalyst.util.IntervalUtils.{safeStringToInterval, stringToInterval}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types.{DayTimeIntervalType, Decimal, DecimalType, YearMonthIntervalType}
import org.apache.spark.sql.types.{DataTypeTestUtils, DayTimeIntervalType, Decimal, DecimalType, YearMonthIntervalType}
import org.apache.spark.sql.types.DataTypeTestUtils.{dayTimeIntervalTypes, numericTypes, yearMonthIntervalTypes}
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}

Expand Down Expand Up @@ -361,7 +361,6 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
}
}

// TODO(SPARK-35728): Check multiply/divide of day-time intervals of any fields by numeric
test("SPARK-34850: multiply day-time interval by numeric") {
Seq(
(Duration.ofHours(-123), Literal(null, DecimalType.USER_DEFAULT)) -> null,
Expand All @@ -373,7 +372,9 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
(Duration.ofDays(9999), 0.0001d) -> Duration.ofDays(9999).dividedBy(10000),
(Duration.ofDays(9999), BigDecimal(0.0001)) -> Duration.ofDays(9999).dividedBy(10000)
).foreach { case ((duration, num), expected) =>
checkEvaluation(MultiplyDTInterval(Literal(duration), Literal(num)), expected)
DataTypeTestUtils.dayTimeIntervalTypes.foreach { dt =>
checkEvaluation(MultiplyDTInterval(Literal.create(duration, dt), Literal(num)), expected)
}
}

Seq(
Expand Down Expand Up @@ -433,7 +434,6 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
}
}

// TODO(SPARK-35728): Check multiply/divide of day-time intervals of any fields by numeric
test("SPARK-34875: divide day-time interval by numeric") {
Seq(
(Duration.ofDays(-123), Literal(null, DecimalType.USER_DEFAULT)) -> null,
Expand All @@ -447,7 +447,9 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
(Duration.ofDays(10080), 100d) -> Duration.ofDays(10080).dividedBy(100),
(Duration.ofMillis(2), BigDecimal(-0.1)) -> Duration.ofMillis(-20)
).foreach { case ((period, num), expected) =>
checkEvaluation(DivideDTInterval(Literal(period), Literal(num)), expected)
DataTypeTestUtils.dayTimeIntervalTypes.foreach { dt =>
checkEvaluation(DivideDTInterval(Literal.create(period, dt), Literal(num)), expected)
}
}

Seq(
Expand Down