From 74af613c933eaab3c68e5116185a0aba4c96ce49 Mon Sep 17 00:00:00 2001 From: Athena Wang Date: Mon, 23 Nov 2026 11:01:59 +0100 Subject: [PATCH 1/4] add withHudi() function and corresponding tests --- src/jsoniq/session.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/jsoniq/session.py b/src/jsoniq/session.py index 145227f..a02fe8e 100644 --- a/src/jsoniq/session.py +++ b/src/jsoniq/session.py @@ -91,6 +91,7 @@ def __init__(self): self._appendable_keys = { "spark.jars.packages", "spark.sql.extensions", + "spark.kryo.registrator", } def rumbleConfig(self, path, value): @@ -228,6 +229,45 @@ def withIceberg(self, catalog_names=None): .config("spark.sql.iceberg.check-ordering", "false") return self; + def withHudi(self): + """ + Configure Apache Hudi on the session catalog (spark_catalog). + + - Hudi works like Delta. Its HoodieCatalog wraps the session + catalog, so named catalogs are not supported. Tables are named or + .
(the default database is "default"). + - Because it takes over spark_catalog, it cannot be combined with withDelta() or + with withIceberg() without catalog names. withIceberg([...]) with named catalogs + can be combined with it. + - Managed tables are stored under ./hudi-warehouse/.db/
. + - Hudi needs the Kryo serializer, both Rumble's and Hudi's registrators are set. + - These are the default settings, which can be overridden with config() if needed. + """ + hudi_catalog = "org.apache.spark.sql.hudi.catalog.HoodieCatalog" + current_catalog = self._sparkbuilder._options.get("spark.sql.catalog.spark_catalog") + if current_catalog and current_catalog != hudi_catalog: + raise ValueError( + f"spark_catalog is already configured as {current_catalog}. Hudi also needs spark_catalog, " + "so it cannot be combined with withDelta() or with withIceberg() without catalog names. " + "Iceberg can be combined with Hudi by giving withIceberg() catalog names." + ) + self._sparkbuilder = self._sparkbuilder \ + .config("spark.sql.catalog.spark_catalog", hudi_catalog) + self._append_config("spark.jars.packages", "org.apache.hudi:hudi-spark4.0-bundle_2.13:1.2.1") + self._append_config("spark.sql.extensions", "org.apache.spark.sql.hudi.HoodieSparkSessionExtension") + # Rumble only installs its own Kryo registrator when spark.serializer is unset, + # so both registrators are listed here. + self._sparkbuilder = self._sparkbuilder \ + .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") + self._append_config("spark.kryo.registrator", "org.rumbledb.spark.RumbleKryoRegistrator") + self._append_config("spark.kryo.registrator", "org.apache.spark.HoodieSparkKryoRegistrar") + self._sparkbuilder = self._sparkbuilder \ + .config("spark.sql.warehouse.dir", "./hudi-warehouse") \ + .config("hoodie.schema.on.read.enable", "true") \ + .config("hoodie.datasource.write.schema.allow.auto.evolution.column.drop", "true") \ + .config("spark.hadoop.hive.metastore.disallow.incompatible.col.type.changes", "false") + return self; + def withMongo(self): self._append_config("spark.jars.packages", "org.mongodb.spark:mongo-spark-connector_2.13:10.5.0") return self; From a447453f1874783235435fce110d0598559ab81e Mon Sep 17 00:00:00 2001 From: Athena Wang Date: Mon, 23 Nov 2026 14:41:34 +0100 Subject: [PATCH 2/4] corresponding test --- tests/test_hudi_update.py | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/test_hudi_update.py diff --git a/tests/test_hudi_update.py b/tests/test_hudi_update.py new file mode 100644 index 0000000..8ba749d --- /dev/null +++ b/tests/test_hudi_update.py @@ -0,0 +1,70 @@ +from jsoniq import RumbleSession +from unittest import TestCase +import uuid + + +class TestHudiBuilderConfig(TestCase): + """ + Hudi wraps the session catalog (spark_catalog), like Delta, so it cannot be + combined with another format that also claims it. These tests only inspect the + builder and do not start a Spark session. + """ + def test_hudi_conflicts_with_delta(self): + with self.assertRaises(ValueError): + RumbleSession.Builder().withDelta().withHudi() + + def test_hudi_conflicts_with_iceberg_session_catalog(self): + with self.assertRaises(ValueError): + RumbleSession.Builder().withIceberg().withHudi() + + def test_hudi_with_named_iceberg_catalogs(self): + options = RumbleSession.Builder().withIceberg(["ice"]).withHudi()._sparkbuilder._options + self.assertEqual( + options["spark.sql.catalog.spark_catalog"], "org.apache.spark.sql.hudi.catalog.HoodieCatalog" + ) + self.assertEqual(options["spark.sql.catalog.ice"], "org.apache.iceberg.spark.SparkCatalog") + + +class TestHudiUpdate(TestCase): + """ + Hudi tables live in the session catalog:
or .
. + """ + @classmethod + def setUpClass(cls): + RumbleSession._rumbleSession = None + RumbleSession._builder = RumbleSession.Builder() + cls.rumble = ( + RumbleSession.builder + .withHudi() + .getOrCreate() + ) + + def _create_insert_count(self, table_name): + self.rumble.jsoniq(f'create collection hudi-table("{table_name}") with {{"k": 1}}').applyPUL() + self.rumble.jsoniq(f'insert {{"k": 2}} last into collection hudi-table("{table_name}")').applyPUL() + count_value = self.rumble.jsoniq(f'count(hudi-table("{table_name}"))').json() + self.assertEqual(count_value, (2,)) + + def test_unqualified_table(self): + self._create_insert_count(f"hudi_plain_{uuid.uuid4().hex}") + + def test_database_qualified_table(self): + self._create_insert_count(f"default.hudi_db_{uuid.uuid4().hex}") + + @staticmethod + def _cleanup_warehouses(): + import os + import shutil + + for dirname in ("hudi-warehouse", "spark-warehouse"): + path = os.path.join(os.getcwd(), dirname) + shutil.rmtree(path, ignore_errors=True) + + @classmethod + def tearDownClass(cls): + try: + if cls.rumble is not None: + cls.rumble._sparksession.stop() + finally: + RumbleSession._rumbleSession = None + cls._cleanup_warehouses() From 42c6b68ceaa104dfff84a5f277c658b9a4224469 Mon Sep 17 00:00:00 2001 From: Athena Wang Date: Thu, 26 Nov 2026 12:56:37 +0100 Subject: [PATCH 3/4] new jar with hudi --- src/jsoniq/jars/rumbledb-3.1.0.jar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jsoniq/jars/rumbledb-3.1.0.jar b/src/jsoniq/jars/rumbledb-3.1.0.jar index eb14178..72541ba 100644 --- a/src/jsoniq/jars/rumbledb-3.1.0.jar +++ b/src/jsoniq/jars/rumbledb-3.1.0.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5162c2e13d1e6315a2e3b3487e01d36ad442720d002e1d9d9f81e9792c7e99bd -size 82407887 +oid sha256:7667dd8fc59a442546f23d9ec177ac495b3f41240cda9cbc551e6763a724c959 +size 164351897 From 2949e565920fcd1d07d8aa81b890ebeb921e8814 Mon Sep 17 00:00:00 2001 From: Athena Wang Date: Thu, 26 Nov 2026 13:14:36 +0100 Subject: [PATCH 4/4] pin java version --- .github/workflows/python-app.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1532a4e..5893ed1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -21,6 +21,11 @@ jobs: - uses: actions/checkout@v4 with: lfs: true + - name: Set up Java 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" - name: Set up Python 3.11 uses: actions/setup-python@v3 with: