)]}'
{
  "commit": "9c6e7777a526020924b550c932d6ad4e84739476",
  "tree": "aefef09039462357aaac7133463f72003dd3ad41",
  "parents": [
    "093e70d97bead98ab02d963a53726370343ca6c5"
  ],
  "author": {
    "name": "Zhang Li",
    "email": "richox@qq.com",
    "time": "Wed Nov 25 21:18:57 2026 +0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Nov 25 21:18:57 2026 +0800"
  },
  "message": "[AURON #2755] Use Spark\u0027s partition ID expression in native hash shuffle (#2756)\n\n# Which issue does this PR close?\n\nCloses #2755\n\n# Rationale for this change\n\nNative hash shuffle currently computes partition IDs using a hard-coded\nMurmur3 hash with seed 42, followed by positive modulo.\n\nSome customized Spark distributions may use a different hash expression,\nsuch as HiveHash. Reconstructing partition IDs with a fixed hash\nimplementation can assign rows to different partitions from Spark,\npotentially producing incorrect results when native and Spark shuffle\npaths are mixed.\n\nSpark\u0027s resolved partition ID expression should be the source of truth.\n\n# What changes are included in this PR?\n\n- Convert `HashPartitioning.partitionIdExpression` and pass the complete\nexpression to the native shuffle planner.\n- Evaluate that expression in native shuffle instead of hard-coding\nMurmur3 hashing and partition mapping.\n- Add native conversion for integer `Pmod` with a positive literal\ndivisor.\n- Validate that partition IDs are non-null Int32 values within the\nconfigured partition range, and propagate evaluation errors.\n- Add Rust tests for Pmod and scalar/array partition ID expressions,\nincluding invalid results.\n- Add a Spark regression comparing partition IDs for composite keys,\nnulls, negative values, and 1, 7, and 16 partitions, while verifying\nnative shuffle execution.\n\n# Are there any user-facing changes?\n\nNative hash shuffle follows Spark\u0027s resolved partition ID expression\nrather than assuming a fixed hash implementation.\n\nStandard Spark Murmur3 partitioning remains unchanged. Customized hash\nexpressions use the existing expression conversion and fallback\nmechanisms; this PR does not add native implementations for arbitrary\ncustom hash functions.\n\n# How was this patch tested?\n\nTested on macOS ARM64 with Spark 3.5.8, Scala 2.12, and JDK 11.\n\nPassed:\n- Rust formatting (`cargo fmt --check`).\n- Spark 3.5 Spotless, Scalafix CHECK, compilation, and installation for\nthe affected modules and their dependencies.\n- `cargo check -p auron-planner -p datafusion-ext-plans -p\ndatafusion-ext-functions`.\n- All three new Rust tests.\n- The new Spark regression, run independently: 1 passed, 0 failed.\n\n```bash\ncargo test -p datafusion-ext-functions pmod_partition_id_expr\ncargo test -p datafusion-ext-plans partition_id_expr\n\n./build/mvn -B -ntp -Ppre,spark-3.5,scala-2.12 \\\n  -pl spark-extension-shims-spark \\\n  -DskipBuildNative -Drat.skip\u003dtrue \\\n  \u0027-Dsuites\u003dorg.apache.auron.AuronQuerySuite @hash repartition uses Spark partition id expression\u0027 \\\n  scalatest:test\n```\n\nThe native library was rebuilt and installed before running the Spark\nregression.\n\nThe full AuronQuerySuite run completed with 60 passed and 1 failed. The\nremaining failure was `lpad/rpad basic`, reporting `capacity overflow`;\nit is outside the scope of this shuffle change.\n\nThe full `./dev/reformat --check` matrix was not completed. After\ncorrecting the reported Scala formatting violation, the Spark 3.5 checks\nabove passed. RAT was skipped for the local Maven install because eight\npre-existing untracked files lacked license headers.\n\n# Was this patch authored or co-authored using generative AI tooling?\n\n- [x] Yes\n- [ ] No\n\nGenerated-by: myflicker 0.3.37.3c3\n\nAI tooling corrected one Scala formatting violation and prepared the\nissue and PR text.\n\nASF guidance: https://www.apache.org/legal/generative-tooling.html\n\nCo-authored-by: zhangli20 \u003czhangli20@kuaishou.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "7e8bfc901a0fcbc7192edb4d0a1a2e8020451ed8",
      "old_mode": 33188,
      "old_path": "native-engine/auron-planner/proto/auron.proto",
      "new_id": "289d5fe3b1ebe1886a7343662ec17b83d7149dbe",
      "new_mode": 33188,
      "new_path": "native-engine/auron-planner/proto/auron.proto"
    },
    {
      "type": "modify",
      "old_id": "c831879d93bfb2ad5c3e43956edadf1ac748fa3a",
      "old_mode": 33188,
      "old_path": "native-engine/auron-planner/src/planner.rs",
      "new_id": "aeb191fe50ed71f36eaa1406034ae7fb694c8287",
      "new_mode": 33188,
      "new_path": "native-engine/auron-planner/src/planner.rs"
    },
    {
      "type": "modify",
      "old_id": "206e92df9d948e3f32772237c335a893048c1ac2",
      "old_mode": 33188,
      "old_path": "native-engine/datafusion-ext-functions/src/lib.rs",
      "new_id": "a23406596c79950413d2833f7db23f9c9dccc455",
      "new_mode": 33188,
      "new_path": "native-engine/datafusion-ext-functions/src/lib.rs"
    },
    {
      "type": "modify",
      "old_id": "08d03e128e5f98e30ab925ecbef4e4f930eb45eb",
      "old_mode": 33188,
      "old_path": "native-engine/datafusion-ext-plans/src/shuffle/buffered_data.rs",
      "new_id": "114e16a7ce30d2cb6006fe98da04128f9f76e2f0",
      "new_mode": 33188,
      "new_path": "native-engine/datafusion-ext-plans/src/shuffle/buffered_data.rs"
    },
    {
      "type": "modify",
      "old_id": "4eae3d9504969c3d5ee25b18b4d8288ecf4dd4e5",
      "old_mode": 33188,
      "old_path": "native-engine/datafusion-ext-plans/src/shuffle/mod.rs",
      "new_id": "94c4fa0dfb8028256feae3baa5af9a7dc530f2d8",
      "new_mode": 33188,
      "new_path": "native-engine/datafusion-ext-plans/src/shuffle/mod.rs"
    },
    {
      "type": "modify",
      "old_id": "b4dca2242954bdcbfa2162bc641e68b05b4fe324",
      "old_mode": 33188,
      "old_path": "spark-extension-shims-spark/src/main/scala/org/apache/spark/sql/auron/ShimsImpl.scala",
      "new_id": "88d9905698ee0eebd1c94386349af3e77359dc05",
      "new_mode": 33188,
      "new_path": "spark-extension-shims-spark/src/main/scala/org/apache/spark/sql/auron/ShimsImpl.scala"
    },
    {
      "type": "modify",
      "old_id": "b6b7f269a8350f8961d9237a5d81f35ba2e77148",
      "old_mode": 33188,
      "old_path": "spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronQuerySuite.scala",
      "new_id": "3f3a22988dc7a10c983c8ee0227502f950d5c9ac",
      "new_mode": 33188,
      "new_path": "spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronQuerySuite.scala"
    },
    {
      "type": "modify",
      "old_id": "7bf581764038ec8a4eb4540eedc58a9334aebd04",
      "old_mode": 33188,
      "old_path": "spark-extension-shims-spark/src/test/scala/org/apache/auron/NativeConvertersSuite.scala",
      "new_id": "3bd45cd026e50a70c7049673341cef4e1cb54a8e",
      "new_mode": 33188,
      "new_path": "spark-extension-shims-spark/src/test/scala/org/apache/auron/NativeConvertersSuite.scala"
    },
    {
      "type": "modify",
      "old_id": "4f01e4862be2472d2c7ccb9e3632bb03fa209a51",
      "old_mode": 33188,
      "old_path": "spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala",
      "new_id": "dc63dae63a6863406ef9787e966cff4a80603b66",
      "new_mode": 33188,
      "new_path": "spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala"
    },
    {
      "type": "modify",
      "old_id": "c46aab6d3e5c613b25135959cfb2d6f89d9b847b",
      "old_mode": 33188,
      "old_path": "spark-extension/src/main/scala/org/apache/spark/sql/execution/auron/plan/NativeShuffleExchangeBase.scala",
      "new_id": "08cd0be2c10f83dfe7696d2d5bfdc70cc5a404f5",
      "new_mode": 33188,
      "new_path": "spark-extension/src/main/scala/org/apache/spark/sql/execution/auron/plan/NativeShuffleExchangeBase.scala"
    }
  ]
}
