suhuruli commented on code in PR #60580:
URL: https://github.com/apache/spark/pull/60580#discussion_r4595967603
##########
python/pyspark/pipelines/init_cli.py:
##########
@@ -23,6 +23,10 @@
libraries:
- glob:
include: transformations/**
+configuration:
+ # Keep table metadata in a local Hive metastore (metastore_db/ in the
directory the pipeline
+ # is run from) so that tables survive across runs and can be queried after a
run.
+ spark.sql.catalogImplementation: hive
Review Comment:
Thanks, agreed: an installation without Hive cannot start a session with
this setting, and the error it gets points at HiveSessionStateBuilder rather
than at the spec. `init_cli.py` now has a `hive_is_available()` helper that
follows the launcher's rule and looks for a `spark-hive_` jar in
`SPARK_HOME/jars` or, in a source build, in
`assembly/target/scala-<version>/jars`; `init` appends the `configuration`
section, with its comment and `spark.sql.catalogImplementation: hive`, only
when the helper reports Hive, and writes the base template otherwise. Where
Hive is present the generated file is byte for byte what this branch wrote
before. In `test_init_cli.py`, `test_init` stubs the helper to report Hive and
checks the setting, `test_init_without_hive` stubs it to report no Hive and
checks an empty configuration, and `test_hive_is_available` checks the jar
lookup against a temporary `SPARK_HOME`. The Auto CDC requirement in the guide
now says the setting applies to projects created
on Spark builds with Hive support and that projects generated elsewhere keep
the in-memory session catalog. I also checked the change on a copy of the
build's jars directory without the Hive jars: `init` writes no `configuration`
section there, the first run completes, and a spec that sets the Hive catalog
by hand fails with the `HiveSessionStateBuilder` error you describe.
##########
python/pyspark/pipelines/tests/test_init_cli.py:
##########
@@ -50,6 +50,7 @@ def test_init(self):
spec_path = find_pipeline_spec(Path.cwd())
spec = load_pipeline_spec(spec_path)
assert spec.name == project_name
+ self.assertEqual(spec.configuration,
{"spark.sql.catalogImplementation": "hive"})
Review Comment:
Thanks, a run of a generated project was indeed missing from the suite.
`test_run_generated_project_twice` in `test_init_cli.py` now generates a
project with `init` and runs `bin/spark-pipelines run` twice from the project
directory in separate processes, in the style of the `spark-submit` tests in
`test_appsubmit.py`. It checks that both runs complete, that the second run
recomputes both materialized views from a changed source, and that the project
directory holds the shared `metastore_db/`, and it is skipped when the
installation has no Hive, because `init` writes no catalog setting there. With
the `configuration` section removed from the generated spec, the second run
fails with `LOCATION_ALREADY_EXISTS`, so the test observes metadata persisting
across processes and not only the template text. On this branch alone the test
fails in the first run with `CANNOT_MODIFY_STATIC_CONFIG`, as you describe,
because the companion change (apache/spark#60579) is not part of this branch, an
d it passes with that change applied on top. I left the test in place rather
than carry that change over here, and the PR description says so.
##########
python/pyspark/pipelines/init_cli.py:
##########
@@ -23,6 +23,10 @@
libraries:
- glob:
include: transformations/**
+configuration:
Review Comment:
Thanks, you are right that the snippet in "Choosing a Target Format"
produced a second top-level `configuration` block, and that `yaml.safe_load`
keeps only the last one without an error. The passage now has readers add
`catalog` and `database` as new top-level keys and put the connector's
`spark.sql.catalog.lakehouse` key inside the `configuration` mapping that
`init` wrote, or create that mapping when the generated spec has none, and it
lists `configuration` among the keys `init` writes on builds with Hive support.
The snippet shows the whole edited spec instead of a fragment to append. I
checked the instructions by applying them to a spec generated with the
`configuration` mapping and to one generated without it and loading each with
`yaml.safe_load` as `load_pipeline_spec` does: both hold the connector key, the
first keeps `spark.sql.catalogImplementation: hive`, and no top-level key
appears twice.
--
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]