Skip to content

Commit 8b041a9

Browse files
authored
chore: use fixed seed in RNG in tests (#2917)
1 parent 619f368 commit 8b041a9

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
17731773
}
17741774

17751775
test("Decimal random number tests") {
1776-
val rand = scala.util.Random
1776+
val rand = new scala.util.Random(42)
17771777
def makeNum(p: Int, s: Int): String = {
17781778
val int1 = rand.nextLong()
17791779
val int2 = rand.nextLong().abs

spark/src/test/scala/org/apache/comet/parquet/ParquetReadSuite.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ abstract class ParquetReadSuite extends CometTestBase {
348348
}
349349

350350
test("mixed nulls and non-nulls") {
351-
val rand = scala.util.Random
351+
val rand = new scala.util.Random(42)
352352
val data = (0 to 100).map { i =>
353353
val row: (Boolean, Integer, java.lang.Long, java.lang.Float, java.lang.Double, String) = {
354354
if (rand.nextBoolean()) {
@@ -403,7 +403,7 @@ abstract class ParquetReadSuite extends CometTestBase {
403403
pageSize = pageSize,
404404
dictionaryPageSize = pageSize)
405405

406-
val rand = scala.util.Random
406+
val rand = new scala.util.Random(42)
407407
val expected = (0 until n).map { i =>
408408
if (rand.nextBoolean()) {
409409
None
@@ -626,7 +626,7 @@ abstract class ParquetReadSuite extends CometTestBase {
626626
dictionaryPageSize = dictionaryPageSize,
627627
pageRowCountLimit = pageRowCount)
628628

629-
val rand = scala.util.Random
629+
val rand = new scala.util.Random(42)
630630
val expected = (0 until n).map { i =>
631631
// use a single value for the first page, to make sure dictionary encoding kicks in
632632
val value = if (i < pageRowCount) i % 8 else i
@@ -814,7 +814,7 @@ abstract class ParquetReadSuite extends CometTestBase {
814814
dictionaryPageSize = pageSize,
815815
rowGroupSize = 1024 * 128)
816816

817-
val rand = scala.util.Random
817+
val rand = new scala.util.Random(42)
818818
val expected = (0 until n).map { i =>
819819
if (rand.nextBoolean()) {
820820
None
@@ -1564,7 +1564,7 @@ abstract class ParquetReadSuite extends CometTestBase {
15641564
pageSize = pageSize,
15651565
dictionaryPageSize = pageSize)
15661566

1567-
val rand = scala.util.Random
1567+
val rand = new scala.util.Random(42)
15681568
val expected = (0 until n).map { i =>
15691569
if (rand.nextBoolean()) {
15701570
None
@@ -1662,7 +1662,7 @@ abstract class ParquetReadSuite extends CometTestBase {
16621662
dictionaryPageSize = dictionaryPageSize,
16631663
pageRowCountLimit = pageRowCount)
16641664

1665-
val rand = scala.util.Random
1665+
val rand = new scala.util.Random(42)
16661666
val expected = (0 until n).map { i =>
16671667
// use a single value for the first page, to make sure dictionary encoding kicks in
16681668
val value = if (i < pageRowCount) i % 8 else i

spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ abstract class CometTestBase
694694

695695
val idGenerator = new AtomicInteger(0)
696696

697-
val rand = scala.util.Random
697+
val rand = new scala.util.Random(42)
698698
val data = (begin until end).map { i =>
699699
if (nullEnabled && rand.nextBoolean()) {
700700
None
@@ -788,7 +788,7 @@ abstract class CometTestBase
788788
rowGroupSize = rowGroupSize)
789789
val div = if (dictionaryEnabled) 10 else n // maps value to a small range for dict to kick in
790790

791-
val rand = scala.util.Random
791+
val rand = new scala.util.Random(42)
792792
val expected = (0 until n).map { i =>
793793
if (rand.nextBoolean()) {
794794
None
@@ -842,7 +842,7 @@ abstract class CometTestBase
842842
rowGroupSize = rowGroupSize)
843843
val div = if (dictionaryEnabled) 10 else n // maps value to a small range for dict to kick in
844844

845-
val rand = scala.util.Random
845+
val rand = new scala.util.Random(42)
846846
val expected = (0 until n).map { i =>
847847
if (rand.nextBoolean()) {
848848
None
@@ -1240,7 +1240,7 @@ abstract class CometTestBase
12401240
val schema = MessageTypeParser.parseMessageType(schemaStr)
12411241
val writer = createParquetWriter(schema, path, dictionaryEnabled = true)
12421242

1243-
val rand = scala.util.Random
1243+
val rand = new scala.util.Random(42)
12441244
val expected = (0 until total).map { i =>
12451245
// use a single value for the first page, to make sure dictionary encoding kicks in
12461246
if (rand.nextBoolean()) None

0 commit comments

Comments
 (0)