Skip to content

Commit

Permalink
[SPARK-35115][SQL][TESTS] Check ANSI intervals in `MutableProjectionS…
Browse files Browse the repository at this point in the history
…uite`

### What changes were proposed in this pull request?
Add checks for `YearMonthIntervalType` and `DayTimeIntervalType` to `MutableProjectionSuite`.

### Why are the changes needed?
To improve test coverage, and the same checks as for `CalendarIntervalType`.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
By running the modified test suite:
```
$ build/sbt "test:testOnly *MutableProjectionSuite"
```

Closes #32225 from MaxGekk/test-ansi-intervals-in-MutableProjectionSuite.

Authored-by: Max Gekk <max.gekk@gmail.com>
Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
  • Loading branch information
MaxGekk authored and maropu committed Apr 18, 2021
1 parent 12abfe7 commit 074f770
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MutableProjectionSuite extends SparkFunSuite with ExpressionEvalHelper {

val fixedLengthTypes = Array[DataType](
BooleanType, ByteType, ShortType, IntegerType, LongType, FloatType, DoubleType,
DateType, TimestampType)
DateType, TimestampType, YearMonthIntervalType, DayTimeIntervalType)

val variableLengthTypes = Array(
StringType, DecimalType.defaultConcreteType, CalendarIntervalType, BinaryType,
Expand All @@ -41,13 +41,15 @@ class MutableProjectionSuite extends SparkFunSuite with ExpressionEvalHelper {
}

testBothCodegenAndInterpreted("fixed-length types") {
val inputRow = InternalRow.fromSeq(Seq(true, 3.toByte, 15.toShort, -83, 129L, 1.0f, 5.0, 1, 2L))
val inputRow = InternalRow.fromSeq(Seq(
true, 3.toByte, 15.toShort, -83, 129L, 1.0f, 5.0, 1, 2L, Int.MaxValue, Long.MinValue))
val proj = createMutableProjection(fixedLengthTypes)
assert(proj(inputRow) === inputRow)
}

testBothCodegenAndInterpreted("unsafe buffer") {
val inputRow = InternalRow.fromSeq(Seq(false, 1.toByte, 9.toShort, -18, 53L, 3.2f, 7.8, 4, 9L))
val inputRow = InternalRow.fromSeq(Seq(
false, 1.toByte, 9.toShort, -18, 53L, 3.2f, 7.8, 4, 9L, Int.MinValue, Long.MaxValue))
val numBytes = UnsafeRow.calculateBitSetWidthInBytes(fixedLengthTypes.length)
val unsafeBuffer = UnsafeRow.createFromByteArray(numBytes, fixedLengthTypes.length)
val proj = createMutableProjection(fixedLengthTypes)
Expand Down

0 comments on commit 074f770

Please sign in to comment.