danny0405 commented on code in PR #20493: URL: https://github.com/apache/hudi/pull/20493#discussion_r4440089386
########## hudi-integ-test/spark-pipelines/phase1_acceptance.py: ########## @@ -0,0 +1,171 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Run RFC-112 Phase 1 acceptance using the #20402 Spark CLI/Connect harness.""" + +import argparse +import json +from pathlib import Path +import signal +import sys +import tempfile + + +SOURCE = '''from pyspark import pipelines as dp +from pyspark.sql import SparkSession + +spark = SparkSession.active() + [email protected]_view(name="input_events") +def input_events(): + return spark.readStream.schema("id INT, ts LONG, value STRING").json(spark.conf.get("hudi.test.input")) +''' + +# Only immutable identity belongs in the table properties. The operation is captured per flow. +FLOWS = '''SET spark.hoodie.datasource.write.operation=insert; +CREATE STREAMING TABLE insert_events USING hudi +TBLPROPERTIES ('type'='cow', 'primaryKey'='id', 'preCombineField'='ts') +AS SELECT id, ts, value FROM STREAM input_events; + +SET spark.hoodie.datasource.write.operation=upsert; +CREATE STREAMING TABLE upsert_events USING hudi +TBLPROPERTIES ('type'='cow', 'primaryKey'='id', 'preCombineField'='ts') Review Comment: Addressed in a3f88472c2d. Added `--table-type cow|mor`; MOR enables async compaction with a one-delta-commit threshold and requires a completed compaction commit on the upsert table before checking the unchanged restart timeline. Ran MOR with metadata both disabled and enabled on Spark 4.1.1 / JDK 17: both passed exact rows, deduplication, compaction, unchanged restart, and failure isolation. ########## hudi-integ-test/spark-pipelines/phase1_acceptance.py: ########## @@ -0,0 +1,171 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Run RFC-112 Phase 1 acceptance using the #20402 Spark CLI/Connect harness.""" + +import argparse +import json +from pathlib import Path +import signal +import sys +import tempfile + + +SOURCE = '''from pyspark import pipelines as dp +from pyspark.sql import SparkSession + +spark = SparkSession.active() + [email protected]_view(name="input_events") +def input_events(): + return spark.readStream.schema("id INT, ts LONG, value STRING").json(spark.conf.get("hudi.test.input")) +''' + +# Only immutable identity belongs in the table properties. The operation is captured per flow. +FLOWS = '''SET spark.hoodie.datasource.write.operation=insert; +CREATE STREAMING TABLE insert_events USING hudi +TBLPROPERTIES ('type'='cow', 'primaryKey'='id', 'preCombineField'='ts') +AS SELECT id, ts, value FROM STREAM input_events; + +SET spark.hoodie.datasource.write.operation=upsert; +CREATE STREAMING TABLE upsert_events USING hudi +TBLPROPERTIES ('type'='cow', 'primaryKey'='id', 'preCombineField'='ts') +AS SELECT id, ts, value FROM STREAM input_events; +''' + + +def verify(mode, remote, root): + from pyspark.sql import SparkSession + + spark = SparkSession.builder.remote(remote).getOrCreate() + try: + assert spark.conf.get("spark.hudi.test.run.id") == root.name + if mode == "healthy": + assert spark.range(3).count() == 3 + print("PASS: Connect server accepts queries after the failing flow") + return + old = (1, 1, "old") + new = (1, 2, "new") + for table, expected in ( + ("insert_events", [old, old] if mode == "first" else [old, old, new]), + ("upsert_events", [old] if mode == "first" else [new]), + ): + actual = [tuple(row) for row in spark.table(f"sdp_test.{table}") + .select("id", "ts", "value").orderBy("ts").collect()] + assert actual == expected, (table, actual, expected) + properties = dict(spark.sql(f"SHOW TBLPROPERTIES sdp_test.{table}").collect()) + assert not any("write.operation" in key for key in properties), properties + print(f"Verified {mode}: independent insert/upsert flows through SQL SET and Spark Connect") + finally: + spark.stop() + + +def scenario(harness): + input_dir = harness.root / "input" + input_dir.mkdir() + (harness.root / "source.py").write_text(SOURCE) + (harness.root / "flows.sql").write_text(FLOWS) + spec = { + "name": "hudi_flow_settings", + "storage": (harness.root / "checkpoints").as_uri(), + "catalog": "spark_catalog", + "database": "sdp_test", + "libraries": [{"glob": {"include": "source.py"}}, {"glob": {"include": "flows.sql"}}], + "configuration": { + "hudi.test.input": input_dir.as_uri(), + "spark.sql.shuffle.partitions": "2", + "spark.sql.pipelines.maxFlowRetryAttempts": "0", + "spark.hoodie.metadata.enable": "false", Review Comment: Addressed in a3f88472c2d. `ACCEPTANCE.md` now explicitly links #20491 as the caveat behind the metadata-disabled default, and `--metadata enabled` exercises the default metadata configuration. Ran all four COW/MOR × metadata disabled/enabled combinations successfully. These bounded enabled runs do not establish exhaustive metadata-writer lifecycle coverage or resolve #20491. -- 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]
