suhuruli opened a new pull request, #60546:
URL: https://github.com/apache/spark/pull/60546
# [SDP] Add a Declarative Pipelines quick start and hello world example
This PR depends on two companion pull requests opened alongside it, both
small:
1. `[SDP] Keep table metadata across runs in projects generated by
spark-pipelines init`: the `spark-pipelines init` template sets
`spark.sql.catalogImplementation: hive`, so tables stay queryable after a run
and a second run does not fail.
2. `[SDP] Skip pipeline configurations that cannot be modified at runtime
when running flows`: a static setting in `spark-pipeline.yml` no longer fails
every flow, because the pipeline server skips settings that cannot change at
run time when it applies per-flow configuration.
Until both are merged, the commands in the quick start and in the example do
not run as written on master.
### What changes were proposed in this pull request?
This PR adds a quick start for Spark Declarative Pipelines (SDP) and a
runnable hello world example project. It also fixes errors in the programming
guide that stop its examples from running as written.
1. **Quick start page**: `docs/declarative-pipelines-quick-start.md`. It
covers installing `pyspark[pipelines]`, `spark-pipelines init`, `run`, and
querying the output tables with `spark-sql` and `pyspark`. It then adds a
streaming table that ingests JSON files and a materialized view that aggregates
it, and shows that a second run reads only the new file. It ends with
`dry-run`, `--full-refresh-all`, and how to reset pipeline state. The page is
linked from the "Programming Guides" menu in `docs/_layouts/global.html`, from
`docs/index.md`, and from the programming guide.
2. **Hello world example**:
`examples/src/main/python/pipelines/hello_world/`. It contains a Python
materialized view (`customers`), a Python streaming table that ingests JSON
files (`orders`), a SQL materialized view that joins them
(`revenue_by_country`), sample data in `data/orders/` and
`more-data/orders-2.json`, and a README that walks through an initial run, an
incremental run and a full refresh.
3. **Programming guide fixes** in
`docs/declarative-pipelines-programming-guide.md`:
- quote `pyspark[pipelines]` in the pip command, because zsh treats
unquoted brackets as a glob;
- fix the unbalanced parentheses in the `customer_orders` example, which
raises a `SyntaxError`;
- use `@dp.materialized_view` in the for-loop example, because
`@dp.table` with a batch query fails;
- add the missing `DataFrame` and `col` imports to the Kafka sink example;
- note that pyflakes-based linters (flake8, ruff F821) still report
`spark` when it has only a type annotation;
- say that `spark-pipelines` discovers only `spark-pipeline.yml` and
`spark-pipeline.yaml`;
- scope the list of forbidden Spark SQL operations to the functions that
define datasets;
- fix typos.
### Why are the changes needed?
A new user can install `pyspark[pipelines]`, run `spark-pipelines init` and
`spark-pipelines run`, and get one successful run. After that, the output
tables cannot be queried, and a second run fails with
`LOCATION_ALREADY_EXISTS`. No page in the docs shows the whole path from
install to a query result, and several guide examples do not run.
### Does this PR introduce _any_ user-facing change?
Yes. The docs gain a quick start page, a hello world example, and corrected
guide examples. The quick start and the example depend on the two changes
listed at the top of this description. Without them, the example's spec sets a
static setting, so every flow fails, and tables from a run cannot be queried.
### How was this patch tested?
I built PySpark from master with the two companion changes applied
(`build/sbt -Phive -Pconnect package`, then a source distribution installed
with the `pipelines` extra into a fresh virtual environment). I extracted every
`bash` block from the quick start page and from the hello world README, ran
them in order with an empty environment, and compared the output with the text
on the pages. All commands succeeded, every shown output matched, and no
`Failed to set` warning was printed.
The Jekyll docs build was not run, so table rendering and the new section
anchors are not checked.
### What still does not work
- Every `spark-pipelines` command prints the pandas 3 `FutureWarning` twice.
This comes from PySpark, not from the pipelines package.
- Java 17 fails in the shared Spark launcher. The quick start lists Java 21
or 25 as a prerequisite.
- The local Hive metastore (`metastore_db/`) and `spark-warehouse/` are
created in the directory where the command runs. Running from a subdirectory of
the project starts an empty metastore and fails with `LOCATION_ALREADY_EXISTS`.
The quick start says to run from the project directory.
- Most programming guide examples read `samples.*` tables, which Spark does
not ship. They show syntax only. The quick start and the example are the
runnable paths.
- Running against a separate Spark Connect server was not tested.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]