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-48061][SQL][TESTS] Parameterize max limits of spark.sql.test.randomDataGenerator #46305

Closed
wants to merge 1 commit into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Apr 30, 2024

What changes were proposed in this pull request?

This PR aims to parameterize MAX_ARR_SIZE, MAX_MAP_SIZE, and MAX_STR_LEN of spark.sql.test.randomDataGenerator by supporting.

  • spark.sql.test.randomDataGenerator.maxArraySize
  • spark.sql.test.randomDataGenerator.maxMapSize
  • spark.sql.test.randomDataGenerator.maxStrLen

Why are the changes needed?

Apache Spark already has the code which needs these parameters. We had better support these to allow the developers to use them without changing and recompiling the source code.

// To limit the golden file size under 10Mb, please set the final val MAX_STR_LEN: Int = 100
// and final val MAX_ARR_SIZE: Int = 4 in org.apache.spark.sql.RandomDataGenerator

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Manual.

BEFORE (golden file size: 269M)

$ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly *StreamingQueryHashPartitionVerifySuite"

$ ls -alh ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
-rw-r--r--  1 dongjoon  staff   269M Apr 30 09:55 ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds

AFTER (golden file size: 5.8M)

$ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly *StreamingQueryHashPartitionVerifySuite" \
-Dspark.sql.test.randomDataGenerator.maxStrLen=100 \
-Dspark.sql.test.randomDataGenerator.maxArraySize=4

$ ls -alh ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
-rw-r--r--  1 dongjoon  staff   5.8M Apr 30 09:56 ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Apr 30, 2024
@dongjoon-hyun
Copy link
Member Author

Hi, @viirya . Could you review this PR, please?

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @dongjoon-hyun

@dongjoon-hyun
Copy link
Member Author

Thank you, @viirya !

Since this is irrelevant to CI and I did manual verification. I'll merge this~

Merged to master for Apache Spark 4.0.0.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-48061 branch April 30, 2024 17:52
JacobZheng0927 pushed a commit to JacobZheng0927/spark that referenced this pull request May 11, 2024
…randomDataGenerator`

### What changes were proposed in this pull request?

This PR aims to parameterize `MAX_ARR_SIZE`, `MAX_MAP_SIZE`, and `MAX_STR_LEN` of `spark.sql.test.randomDataGenerator` by supporting.
- `spark.sql.test.randomDataGenerator.maxArraySize`
- `spark.sql.test.randomDataGenerator.maxMapSize`
- `spark.sql.test.randomDataGenerator.maxStrLen`

### Why are the changes needed?

Apache Spark already has the code which needs these parameters. We had better support these to allow the developers to use them without changing and recompiling the source code.

https://github.com/apache/spark/blob/0329479acb6758c4d3e53d514ea832a181d31065/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingQueryHashPartitionVerifySuite.scala#L155-L156

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

No.

### How was this patch tested?

Manual.

**BEFORE (golden file size: `269M`)**
```
$ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly *StreamingQueryHashPartitionVerifySuite"

$ ls -alh ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
-rw-r--r--  1 dongjoon  staff   269M Apr 30 09:55 ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
```

**AFTER (golden file size: `5.8M`)**
```
$ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly *StreamingQueryHashPartitionVerifySuite" \
-Dspark.sql.test.randomDataGenerator.maxStrLen=100 \
-Dspark.sql.test.randomDataGenerator.maxArraySize=4

$ ls -alh ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
-rw-r--r--  1 dongjoon  staff   5.8M Apr 30 09:56 ./sql/core/target/scala-2.13/test-classes/structured-streaming/partition-tests/rowsAndPartIds
```

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#46305 from dongjoon-hyun/SPARK-48061.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants