[SPARK-62389][SQL][SS][TEST] Add streaming test coverage for time_bucket

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

This PR adds a streaming SQL golden test for the `time_bucket` function: `sql-tests/inputs/streaming/time-bucket.sql` and its two golden files.

The test has two flows that read the same streaming source table.

The first flow is a projection with `time_bucket`: a 15-minute bucket, a 1-month bucket, and a 1-hour bucket with an explicit origin. The sink gets the bucket start of each row, and NULL for a NULL timestamp.

The second flow is an aggregation with `GROUP BY time_bucket(...)` and a watermark on the timestamp column. The flow fails at start with `STREAMING_OUTPUT_MODE.UNSUPPORTED_OPERATION`. In append mode, a streaming aggregation needs a grouping column that carries the watermark, and a `time_bucket(...)` expression is not such a column.

### Why are the changes needed?

`time_bucket` has batch tests only. The `SQLQueryTestSuite` class documentation asks for a streaming test for each user-visible SQL feature.

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

No.

### How was this patch tested?

This PR adds only tests. `StreamingSQLQueryTestSuite` generated the golden files, and a second run of the suite passes against them:

```
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/testOnly org.apache.spark.sql.StreamingSQLQueryTestSuite -- -z time-bucket.sql"
build/sbt "sql/testOnly org.apache.spark.sql.StreamingSQLQueryTestSuite -- -z time-bucket.sql"
```

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

Generated-by: Isaac

This pull request and its description were written by Isaac.

Closes #60912 from vranes/time-bucket-streaming-tests.

Authored-by: Nikolina Vraneš <nikolina.vranes@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>


skip-checks: true
3 files changed
tree: 01d10faf2bf958c04329a02dbd662957fa44e06f
  1. .agents/
  2. .github/
  3. .mvn/
  4. assembly/
  5. bin/
  6. binder/
  7. build/
  8. common/
  9. conf/
  10. connector/
  11. core/
  12. data/
  13. dev/
  14. docs/
  15. examples/
  16. graph/
  17. graphx/
  18. hadoop-cloud/
  19. launcher/
  20. licenses/
  21. licenses-binary/
  22. mllib/
  23. mllib-local/
  24. project/
  25. python/
  26. repl/
  27. resource-managers/
  28. sbin/
  29. sql/
  30. streaming/
  31. tools/
  32. udf/
  33. ui-test/
  34. .asf.yaml
  35. .gitattributes
  36. .gitignore
  37. .ignore
  38. .nojekyll
  39. .pre-commit-config.yaml
  40. .sbtopts
  41. AGENTS.md
  42. CONTRIBUTING.md
  43. LICENSE
  44. LICENSE-binary
  45. NOTICE
  46. NOTICE-binary
  47. pom.xml
  48. pyproject.toml
  49. README.md
  50. scalastyle-config.xml
  51. SECURITY.md
README.md

Apache Spark

Spark is a unified analytics engine for large-scale data processing. It provides high-level APIs in Scala, Java, and Python, and an optimized engine that supports general computation graphs for data analysis. It also supports a rich set of higher-level tools including Spark SQL for SQL and DataFrames, pandas API on Spark for pandas workloads, MLlib for machine learning, GraphX for graph processing, and Structured Streaming for stream processing.

License Maven Central Java GitHub Actions Build PySpark Coverage PyPI Downloads

Online Documentation

You can find the latest Spark documentation, including a programming guide, on the project web page. This README file only contains basic setup instructions.

Build Pipeline Status

See the Apache CI dashboard for an overview of Spark's CI usage.

BranchStatus
masterGitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.xGitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.4GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.3GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.2GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.1GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-4.0GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
GitHub Actions Build
branch-3.5GitHub Actions Build
GitHub Actions Build
GitHub Actions Build

Building Spark

Spark is built using Apache Maven. To build Spark and its example programs, run:

./build/mvn -DskipTests clean package

(You do not need to do this if you downloaded a pre-built package.)

More detailed documentation is available from the project site, at “Building Spark”.

For general development tips, including info on developing Spark using an IDE, see “Useful Developer Tools”.

Interactive Scala Shell

The easiest way to start using Spark is through the Scala shell:

./bin/spark-shell

Try the following command, which should return 1,000,000,000:

scala> spark.range(1000 * 1000 * 1000).count()

Interactive Python Shell

Alternatively, if you prefer Python, you can use the Python shell:

./bin/pyspark

And run the following command, which should also return 1,000,000,000:

>>> spark.range(1000 * 1000 * 1000).count()

Example Programs

Spark also comes with several sample programs in the examples directory. To run one of them, use ./bin/run-example <class> [params]. For example:

./bin/run-example SparkPi

will run the Pi example locally.

You can set the MASTER environment variable when running examples to submit examples to a cluster. This can be spark:// URL, “yarn” to run on YARN, and “local” to run locally with one thread, or “local[N]” to run locally with N threads. You can also use an abbreviated class name if the class is in the examples package. For instance:

MASTER=spark://host:7077 ./bin/run-example SparkPi

Many of the example programs print usage help if no params are given.

Running Tests

Testing first requires building Spark. Once Spark is built, tests can be run using:

./dev/run-tests

Please see the guidance on how to run tests for a module, or individual tests.

There is also a Kubernetes integration test, see resource-managers/kubernetes/integration-tests/README.md

A Note About Hadoop Versions

Spark uses the Hadoop core library to talk to HDFS and other Hadoop-supported storage systems. Because the protocols have changed in different versions of Hadoop, you must build Spark against the same version that your cluster runs.

Please refer to the build documentation at “Specifying the Hadoop Version and Enabling YARN” for detailed guidance on building for a particular distribution of Hadoop, including building for particular Hive and Hive Thriftserver distributions.

Configuration

Please refer to the Configuration Guide in the online documentation for an overview on how to configure Spark.

Contributing

Please review the Contribution to Spark guide for information on how to get started contributing to the project.