)]}'
{
  "log": [
    {
      "commit": "63f51e692ebba328466f5952b4c30c628713712f",
      "tree": "79619f5f6a980cf10f965db78ff2bd3748784189",
      "parents": [
        "fcb293b74097d2ffe3ad6e769711740040a2e956"
      ],
      "author": {
        "name": "Nikolina Vraneš",
        "email": "nikolina.vranes@databricks.com",
        "time": "Mon Nov 30 16:27:27 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Mon Nov 30 16:27:27 2026 +0000"
      },
      "message": "[SPARK-62390][SQL][SS][TEST] Add streaming test coverage for BIN BY\n\n### What changes were proposed in this pull request?\n\nThis PR adds streaming tests for the BIN BY relation operator.\n\n`sql-tests/inputs/streaming/bin-by.sql` has three flows that read `STREAM(source)`:\n\n- A stateless BIN BY. The sink gets the same rows as the batch query, which the file also runs.\n- BIN BY, then `GROUP BY bin_start`, with a watermark on `ts_start`. `REFRESH FLOW` fails with `STREAMING_OUTPUT_MODE.UNSUPPORTED_OPERATION`, because `bin_start` does not carry the watermark.\n- BIN BY, then `GROUP BY ts_start, bin_start`, with a watermark on `ts_start`. The sink gets a group after a later row moves the watermark past the `ts_start` of that group.\n\n`UnsupportedOperationsSuite` gets a case that a `BinBy` node above a streaming relation passes `checkForStreaming`.\n\n### Why are the changes needed?\n\nBIN BY has batch tests only. The `SQLQueryTestSuite` class doc asks for a test under `sql-tests/inputs/streaming` for each new SQL syntax. These tests record how BIN BY behaves on a streaming input, including the aggregation that append mode rejects.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. This PR changes tests only.\n\n### How was this patch tested?\n\nGenerated the golden files with `SPARK_GENERATE_GOLDEN_FILES\u003d1 build/sbt \"sql/testOnly org.apache.spark.sql.StreamingSQLQueryTestSuite -- -z bin-by.sql\"`, then ran the same suite without the variable. Also ran it with `SPARK_ANSI_SQL_MODE\u003dfalse` and `SPARK_CODEGEN_COMPILER\u003djdk`. Ran `UnsupportedOperationsSuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac (Claude Fable 5.2)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60911 from vranes/bin-by-streaming-tests.\n\nAuthored-by: Nikolina Vraneš \u003cnikolina.vranes@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "fcb293b74097d2ffe3ad6e769711740040a2e956",
      "tree": "01d10faf2bf958c04329a02dbd662957fa44e06f",
      "parents": [
        "3ee4a120147bc9828b2c08a6a1d9f67f9896be7c"
      ],
      "author": {
        "name": "Nikolina Vraneš",
        "email": "nikolina.vranes@databricks.com",
        "time": "Mon Nov 30 16:25:27 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Mon Nov 30 16:25:27 2026 +0000"
      },
      "message": "[SPARK-62389][SQL][SS][TEST] Add streaming test coverage for time_bucket\n\n### What changes were proposed in this pull request?\n\nThis PR adds a streaming SQL golden test for the `time_bucket` function: `sql-tests/inputs/streaming/time-bucket.sql` and its two golden files.\n\nThe test has two flows that read the same streaming source table.\n\nThe first flow is a projection with `time_bucket`: a 15-minute bucket, a 1-month bucket, and a 1-hour bucket with an explicit origin. The sink gets the bucket start of each row, and NULL for a NULL timestamp.\n\nThe second flow is an aggregation with `GROUP BY time_bucket(...)` and a watermark on the timestamp column. The flow fails at start with `STREAMING_OUTPUT_MODE.UNSUPPORTED_OPERATION`. In append mode, a streaming aggregation needs a grouping column that carries the watermark, and a `time_bucket(...)` expression is not such a column.\n\n### Why are the changes needed?\n\n`time_bucket` has batch tests only. The `SQLQueryTestSuite` class documentation asks for a streaming test for each user-visible SQL feature.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nThis PR adds only tests. `StreamingSQLQueryTestSuite` generated the golden files, and a second run of the suite passes against them:\n\n```\nSPARK_GENERATE_GOLDEN_FILES\u003d1 build/sbt \"sql/testOnly org.apache.spark.sql.StreamingSQLQueryTestSuite -- -z time-bucket.sql\"\nbuild/sbt \"sql/testOnly org.apache.spark.sql.StreamingSQLQueryTestSuite -- -z time-bucket.sql\"\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac\n\nThis pull request and its description were written by Isaac.\n\nCloses #60912 from vranes/time-bucket-streaming-tests.\n\nAuthored-by: Nikolina Vraneš \u003cnikolina.vranes@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "3ee4a120147bc9828b2c08a6a1d9f67f9896be7c",
      "tree": "df64a03b9e3199fdad755c5da0982586fdcfbf56",
      "parents": [
        "d363e805f3b67c5edd6493a996860fb563d804be"
      ],
      "author": {
        "name": "Peter Toth",
        "email": "peter.toth@gmail.com",
        "time": "Mon Nov 30 14:01:25 2026 +0100"
      },
      "committer": {
        "name": "Peter Toth",
        "email": "peter.toth@gmail.com",
        "time": "Mon Nov 30 14:01:25 2026 +0100"
      },
      "message": "[SPARK-62421][CORE] Add `BloomFilter` V3 that keeps the expected false positive probability of small filters, and use it as default\n\n### What changes were proposed in this pull request?\n\nThis PR adds a `BloomFilter` binary format V3 and makes it the default, as #50933 did with V2.\n\nV3 has the binary format of V2, with the version number 3. It takes each bit position of an item from its own mix of the item\u0027s 64-bit hash. The mix is the 64-bit finalizer of MurmurHash3 over the hash plus `i` times the 64-bit golden ratio. SplitMix64 steps its state by the same constant. An unsigned multiply-high then maps the mix below the number of bits, without a division. V2 takes all positions as `h1 * Integer.MAX_VALUE + i * h2` modulo the number of bits.\n\n- `BloomFilterImplV3` extends `BloomFilterImplV2`. It overrides only how an item sets and checks its bits, and the version number.\n- `BloomFilterImplV2` leaves `equals` to `BloomFilterBase`, which compares classes. Its merge check compares classes instead of using `instanceof`. So a V2 and a V3 filter are neither equal nor mergeable. It writes and reads the version number of its class.\n- `BloomFilter.create` builds a V3 filter by default. `BloomFilter.create(Version, ...)` still builds V1 and V2 filters, and `BloomFilter.readFrom` still reads them.\n- `BloomFilterImplV2` pins its `serialVersionUID` to the value Java computed before. So V2 filters that an earlier version serialized with Java serialization still read back. `BloomFilterImplV3` pins its own.\n- `bloom_filter_agg`, which runtime bloom filter joins and `DataFrameStatFunctions.bloomFilter` use, builds the version of the new legacy conf `spark.sql.legacy.bloomFilterAggregate.version`, 3 by default.\n- `BloomFilterAggregate.serialize` sizes its buffer for the 16-byte header of V2 and V3. It sized it for 8 bytes, so the buffer grew and was copied once more for every filter.\n- The SQL migration guide says that V3 is the default now, and names the conf.\n\n### Why are the changes needed?\n\nV2 is far over its expected false positive probability (fpp) when it is small and that probability is low. Measured with random long items, in filters sized for exactly those items with `BloomFilter.optimalNumOfBits`, as a multiple of the expected fpp:\n\n| fpp | items | V1 | V2 | V3 |\n|---|---|---|---|---|\n| 1e-3 | 16 | 1.9 | 5.3 | 0.5 |\n| 1e-4 | 16 | 6.9 | 43.1 | 0.8 |\n| 1e-4 | 100 | 2.0 | 9.7 | 1.0 |\n| 1e-5 | 16 | 54.0 | 469.0 | 1.0 |\n| 1e-5 | 100 | 7.0 | 51.5 | 0.8 |\n| 1e-5 | 1000 | 1.6 | 7.9 | 1.0 |\n| 1e-5 | 100000 | 1.0 | 1.3 | 0.8 |\n\nAt the default 3%, all three versions are as expected.\n\nTwo things add up in V2:\n- When `h2` and the number of bits share a large factor, the positions repeat after a few steps. The item then sets and checks only a few bits. The number of bits is always a multiple of 64, so such factors are common.\n- Any scheme that takes all positions from two values modulo the number of bits has only as many patterns of positions as the square of the number of bits. A probe with the pattern of an item always passes. Enhanced double hashing, which adds `(i^3 - i) / 6` to each position, removes the first but keeps the second. It measured 7.0 at 16 items and 1e-5.\n\nV3 mixes each position on its own for the same reason. Stepping all positions from two mixed 64-bit values of the item, with the same multiply-high, checks only about 8% faster. But it measured 51 times the expected fpp at 16 items and 1e-5, and 7.5 times at 100 items, where V3 stays at or under it.\n\nRuntime bloom filter joins already build such filters when the creation side has a row count. They size the filter of n items with `BloomFilter.optimalNumOfBits(n, maxNumItems, maxNumBits)`, for an fpp of 7.5e-9 times n at the defaults. Measured with random long items over 200 filters, as a multiple of that fpp:\n\n| items | bits | hash functions | V2 | V3 |\n|---|---|---|---|---|\n| 16 | 576 | 23 | 22217 | 0.2 |\n| 100 | 2944 | 20 | 511 | 0.9 |\n| 1000 | 24576 | 17 | 8.8 | 1.0 |\n| 10000 | 197696 | 14 | 1.1 | 1.0 |\n\nPer-partition runtime bloom filters (SPARK-60541) are for creation sides over the size threshold. Each gets an even share of the creation side\u0027s items over its partition keys. With a row count, each share goes through the same formula. So with 1,000 rows per partition key, they get filters of 1,000 items, as in the third row. SPARK-62098 proposes applying them in the scan. Skipping a row group or a page there needs a low fpp.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. `BloomFilter.create` without a version and `DataFrameStatFunctions.bloomFilter` build V3 filters now. So do runtime bloom filter joins, whose filters do not leave the query. Setting `spark.sql.legacy.bloomFilterAggregate.version` to 2 makes the latter two build V2 filters again.\n- A Spark version without V3 cannot read them. For example, a Spark Connect client of an earlier version cannot read what `bloomFilter` returns from a server with this change.\n- A V2 filter, such as one read from bytes an earlier version wrote, cannot be merged with them. Their bit patterns differ.\n\n#50933 had the same effects with V2.\n\n### How was this patch tested?\n\n- `BloomFilterSuite` runs its accuracy, merge and intersect tests for every version, not only for the default one. New tests:\n  - V3 stays under 1.5 times the expected fpp for 16 items at 1e-3 and 1e-4, and for 100 items at 1e-4. V2 is 5 to 43 times over at these points;\n  - V3 maps a 64-bit value below the number of bits as the unsigned product does, up to the largest bit array;\n  - V2 keeps its earlier `serialVersionUID`, and V3 its pinned one;\n  - V3 keeps its bit pattern, checked against the bytes of a small filter;\n  - every `create` without a version builds V3;\n  - each version reads back as itself with Java serialization;\n  - V2 and V3 filters are neither compatible, equal nor mergeable.\n- `BloomFilterAggregateQuerySuite` checks `might_contain` over a constant V3 filter. It also checks that `bloom_filter_agg` and `DataFrameStatFunctions.bloomFilter` build a filter equal to the one `BloomFilter.create` builds with the same sizes and seed 0. That is a V3 filter by default, and a V2 filter with the legacy conf.\n- `DataFrameStatSuite` and `JavaDataFrameSuite` allow an `expectedFpp` of up to 3.2% for a 3% filter of its expected items, instead of 3.1%. `expectedFpp` estimates the probability from the share of set bits. For such a filter that is 2.9% on average, with a deviation of about 0.1%. The filter of `id * 3` gives 3.13% with V3. V2 stayed under 3.1% in part because its repeated positions set fewer bits.\n- `SparkBloomFilterSuite` tests V3 instead of V2, whose bit positions do not change. It runs only with `SPARK_TEST_SPARK_BLOOM_FILTER_SUITE_ENABLED\u003dtrue`, and no CI job runs it. `build_non_ansi` sets it, but skips the sketch module. So these results come from a run by hand. Its random test now also checks that the filter finds every inserted item. At 350 million items and 3%, V3 measured 3.0010% and 3.0008%. V2 measured 3.0005% and 3.0010% in the same run.\n- `SparkBloomFilterBenchmark` has V3 cases. The benchmark workflow regenerated its results files:\n  - with JDK 21, on an Intel Xeon 6975P-C, V3 takes 5% to 19% less time than V2 for long items. For example, it takes 41.1 ns against 45.6 ns to put an item into a filter of 1 million items, and 25.1 ns against 27.5 ns to check one. Binary items take about the same time;\n  - with JDK 25, on an AMD EPYC 9V74, V3 checks inserted long items in up to 1.22 times the time of V2. For example, it takes 19.1 ns against 15.7 ns in a filter of 10,000 items, and 24.1 ns against 19.8 ns at a hit rate of 90%. It puts long items into a filter of 10,000 items in 1.17 times the time. Filters of 1 million items take at most 5% longer, and binary items about the same time.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code with Claude Opus 5.5\n\nCloses #60943 from peter-toth/SPARK-62421-bloom-filter-v3.\n\nAuthored-by: Peter Toth \u003cpeter.toth@gmail.com\u003e\nSigned-off-by: Peter Toth \u003cpeter.toth@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d363e805f3b67c5edd6493a996860fb563d804be",
      "tree": "8790ee090558b118649f504d394b411cb589622b",
      "parents": [
        "debe6ff21426c5a817aedfee1b81b3aa1ef75a97"
      ],
      "author": {
        "name": "Anshul Baliga",
        "email": "baligaanshul@gmail.com",
        "time": "Mon Nov 30 17:19:06 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Mon Nov 30 17:19:06 2026 +0800"
      },
      "message": "[SPARK-62073][PYTHON] Fix ClassCastException in classic randomSplit with int weights\n\n### What changes were proposed in this pull request?\r\n\r\nThis PR fixes `ClassCastException` in the classic `DataFrame.randomSplit` for int weights. Like `_validate_approx_quantile_probabilities` (SPARK-61464), a new helper `_validate_random_split_weights` in `python/pyspark/sql/dataframe.py` validates and converts the weights for both the classic and the Spark Connect implementations, so they stay in sync. The helper:\r\n\r\n- reads the weights once and returns them as a `list` of `float`, which classic passes to the JVM;\r\n- rejects `bool` and non-real values with `NOT_EXPECTED_TYPE`, as the `approxQuantile` helpers do;\r\n- rejects a negative weight and a non-positive sum with `VALUE_NOT_POSITIVE`, as Spark Connect already did;\r\n- divides the weights by their exact sum when an int is beyond the range of a double, as Spark Connect already did.\r\n\r\nIn addition, classic calls `PythonUtils.toList` directly instead of `_to_list`, which is a helper for a list of Columns, and the `randomSplit` docstring mentions that int weights are accepted.\r\n\r\n### Why are the changes needed?\r\n\r\nPy4J sends a Python `int` as `java.lang.Integer`, or as `java.lang.Long` from `2**31`, and the classic `randomSplit(weights: List[Double], seed: Long)` fails when it unboxes them:\r\n\r\n```python\r\n\u003e\u003e\u003e spark.range(10).randomSplit([1, 2], 24)\r\npy4j.protocol.Py4JJavaError: An error occurred while calling o30.randomSplit.\r\n: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Double\r\n```\r\n\r\nThe signature is `weights: List[float]`, which accepts ints, and Spark Connect accepts them because it divides the weights by their sum. The two implementations also validated the weights differently, so some other inputs behaved differently.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nYes.\r\n\r\n- In classic, int weights, including a mix such as `[1, 2.0]` and ints beyond the range of a double, now split the rows like the equal float weights, instead of failing with `ClassCastException`.\r\n- In classic, weights that do not sum to a positive value, such as `[0, 0]`, now fail with `PySparkValueError` (`VALUE_NOT_POSITIVE`), as in Spark Connect, instead of the JVM\u0027s `IllegalArgumentException`.\r\n- In both, `Decimal` weights now fail with `PySparkTypeError` (`NOT_EXPECTED_TYPE`). Classic failed with `ClassCastException` and Spark Connect with a plain `TypeError`.\r\n- In both, `bool` weights now fail with `PySparkTypeError` (`NOT_EXPECTED_TYPE`), as `approxQuantile` rejects them. Classic failed with `ClassCastException`, while Spark Connect counted `True` as `1`.\r\n\r\n### How was this patch tested?\r\n\r\nTwo new test cases in `DataFrameTestsMixin`, which also run in the Spark Connect parity suite:\r\n\r\n- `test_random_split_int_weights`: int weights, ints that Py4J sends as `java.lang.Long` (`[2**40, 2**41]`), a mix of int and float, and ints beyond the range of a double split the rows exactly like the equal float weights with the same seed, and no row is lost.\r\n- `test_random_split_invalid_weights`: the errors for a negative weight, a non-positive sum, and `Decimal` and `bool` weights.\r\n\r\nWithout the fix, the int cases fail with the `ClassCastException` above in classic.\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-by: Claude claude-opus-4-8\n\nCloses #60714 from anshulbaliga7/SPARK-randomsplit-int-weights.\n\nAuthored-by: Anshul Baliga \u003cbaligaanshul@gmail.com\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "debe6ff21426c5a817aedfee1b81b3aa1ef75a97",
      "tree": "591616aa3b502da65255048157068bd8cb748502",
      "parents": [
        "43cfbd71f164700b1633dbdc41b70b0463b9d521"
      ],
      "author": {
        "name": "raviston",
        "email": "raviston.6296@gmail.com",
        "time": "Mon Nov 30 15:48:31 2026 +0800"
      },
      "committer": {
        "name": "yangjie01",
        "email": "yangjie01@baidu.com",
        "time": "Mon Nov 30 15:48:31 2026 +0800"
      },
      "message": "[SPARK-60916][SQL] Fix Parquet IN filter pushdown with NULL on a BOOLEAN column\n\n### What changes were proposed in this pull request?\n\n`ParquetFilters.createFilterHelper` converts `sources.In` with more values than `spark.sql.parquet.pushdown.inFilterThreshold` into a Parquet `in` predicate. When the list contains NULL, the pushed filter is `col \u003d NULL OR col IN (non-null values)`, built as `Seq(eq, in).flatten.reduceLeftOption(or)`.\n\n`makeInPredicate` had no case for BOOLEAN, the only type that `makeEq` supports and `makeInPredicate` does not. So for a BOOLEAN column the `in` disjunct was `None`, `flatten` dropped it, and the pushed filter became `col \u003d NULL` alone. That is stricter than the original predicate, so Parquet skipped every row group without NULLs, including the ones holding the matching rows.\n\nThis PR:\n1. Adds a BOOLEAN case to `makeInPredicate`. It builds an OR of `FilterApi.eq` per distinct value rather than `FilterApi.in`: the bloom filter level of parquet-java 1.18.1 fails on an `in` over a BOOLEAN column (`BloomFilterImpl.visit(In)` calls `BlockSplitBloomFilter.hash`, which throws `Parquet Bloom filter: Not supported type` for a Boolean), while it treats an `eq` that it cannot hash as might match. A BOOLEAN column has at most two distinct values, so the filter is the same, and it is the form that IN lists below the threshold are already pushed as.\n2. Pushes `col IS NULL OR col IN (...)` only when both disjuncts can be built, and pushes nothing otherwise. The IN never keeps a NULL row, so the IS NULL disjunct alone would be stricter than the IN.\n3. Pushes the IS NULL disjunct alone when the list has only NULLs, as below the threshold. Such an IN matches no row, and `FilterApi.in` does not accept an empty set.\n\n### Why are the changes needed?\n\nIt is a correctness bug: the query silently returns fewer rows when Parquet filter pushdown is on (the default).\n\n```python\npath \u003d \"/tmp/bool_in_null\"\nspark.sql(\"SELECT * FROM VALUES (true), (false) AS t(b)\").coalesce(1).write.mode(\"overwrite\").parquet(path)\nspark.sql(\"SELECT CAST(NULL AS BOOLEAN) AS b\").write.mode(\"append\").parquet(path)\nspark.read.parquet(path).createOrReplaceTempView(\"t\")\n\nq \u003d \"SELECT b FROM t WHERE b IN (true, NULL)\"\nspark.sql(q).show()   # one row: true\nspark.conf.set(\"spark.sql.parquet.pushdown.inFilterThreshold\", \"1\")\nspark.sql(q).show()   # before: no row; after: one row, true\n```\n\n`b IN (true, false, NULL)` with threshold 2 also returned no row. It reproduces on 3.5.8, 4.0.0, 4.1.1, 4.2.0 and master.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, a bug fix. `IN` lists containing NULL on a BOOLEAN Parquet column now return the matching rows when the list is longer than `spark.sql.parquet.pushdown.inFilterThreshold`.\n\nBOOLEAN `IN` lists longer than the threshold, with or without NULL, are now also pushed down to Parquet, as an OR of equalities, including on shredded variant fields read as BOOLEAN (DSv1). Before this PR, those without NULL were not pushed at all.\n\nAn `IN` list of only NULLs that is longer than the threshold, which only reaches the Parquet filter when `OptimizeIn` is excluded, no longer fails filter creation with `values in SetColumnFilterPredicate shouldn\u0027t be empty!` for any type.\n\n### How was this patch tested?\n\nNew tests in `ParquetFilterSuite` (run by both `ParquetV1FilterSuite` and `ParquetV2FilterSuite`), which fail without this change:\n- `SPARK-60916: Pushdown IN predicate on a BOOLEAN column`: the pushed filter for `IN (true, false, true)` and `IN (true, NULL)`.\n- `SPARK-60916: IN with NULL on a BOOLEAN column above the IN filter threshold`: the end-to-end example above, with thresholds 1 and 10.\n- `SPARK-60916: IN on a BOOLEAN column with a bloom filter above the IN filter threshold`: a top-level and a struct-nested BOOLEAN column written with `parquet.bloom.filter.enabled\u003dtrue`, with both readers.\n- `SPARK-60916: IN with only NULLs above the IN filter threshold`: the pushed filter for BOOLEAN and INT columns, and the end-to-end result with `OptimizeIn` excluded.\n- `filter pushdown - boolean` now has IN lists with and without NULL, above and below the threshold, through the per-type `checkFilterPredicate` harness (top-level and nested columns, record-level filtering, V1 and V2).\n\nNew test in `VariantShreddingFilterPushdownSuite`: `SPARK-60916: BOOLEAN IN above the IN filter threshold with a bloom filter`, on a variant field shredded as BOOLEAN, for DSv1 and DSv2 and both readers.\n\n```\nbuild/sbt \u0027sql/testOnly *ParquetV1FilterSuite *ParquetV2FilterSuite *VariantShreddingFilterPushdownSuite\u0027 sql/scalastyle sql/Test/scalastyle\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60132 from raviston/SPARK-60916.\n\nLead-authored-by: raviston \u003craviston.6296@gmail.com\u003e\nCo-authored-by: raviston.t \u003craviston.t@zohocorp.com\u003e\nSigned-off-by: yangjie01 \u003cyangjie01@baidu.com\u003e\n"
    },
    {
      "commit": "43cfbd71f164700b1633dbdc41b70b0463b9d521",
      "tree": "8aaaa04737397f141b2c8894ac61b05ce23a2a25",
      "parents": [
        "0392ed61c66c4fa6bc8495e2b732a8248c1944a7"
      ],
      "author": {
        "name": "Eames Trinh",
        "email": "eamestrinh@gmail.com",
        "time": "Mon Nov 30 06:50:00 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Mon Nov 30 06:50:00 2026 +0000"
      },
      "message": "[SPARK-59538][SQL] Resolve evolved nested fields positionally in column-list inserts\n\n### What changes were proposed in this pull request?\r\n\r\nThis PR fixes column-list inserts so nested fields continue resolving positionally when they occur inside arrays or maps, including when schema evolution makes the input and target structs have different numbers of fields.\r\n\r\n`createProjectForByNameQuery` now recursively renames matching nested fields to their target names by ordinal. When the input contains additional fields, the matching prefix is renamed positionally while the extra fields retain their original names for downstream schema evolution.\r\n\r\nCollection traversal is unconditional, preserving positional resolution for equal-arity structs inside arrays and maps. Positional resolution for structs with different field counts is controlled by the internal configuration `spark.sql.insertInto.columnList.differentArityStructsResolveByPosition.enabled`, which defaults to `true`.\r\n\r\nThe rewrite also rejects duplicate field names introduced by positional renaming while preserving the existing handling of duplicates already present in the input.\r\n\r\n```text\r\ncolumn-list INSERT\r\n-\u003e createProjectForByNameQuery\r\n-\u003e recursively rename nested fields by ordinal\r\n-\u003e reject rename-created collisions or construct the cast\r\n-\u003e schema evolution and output resolution\r\n```\r\n\r\n### Why are the changes needed?\r\n\r\nA column list determines the mapping of top-level columns, but values within those columns are resolved positionally. Previously, positional renaming was skipped when nested structs had different numbers of fields.\r\n\r\nFor example:\r\n\r\n```sql\r\nCREATE TABLE t (s STRUCT\u003cx: INT, y: INT\u003e) USING \u003cv2-provider\u003e;\r\n\r\nINSERT WITH SCHEMA EVOLUTION INTO t (s)\r\nSELECT named_struct(\u0027y\u0027, 1, \u0027x\u0027, 2, \u0027z\u0027, 3);\r\n```\r\n\r\nThe first two input fields should map positionally to `x` and `y`, while `z` should be added through schema evolution.\r\n\r\nPositional renaming can also manufacture duplicate names. For example, mapping source `{y, x, z}` to target `{x}` produces `{x, x, z}`. These collisions must be rejected before schema evolution mutates the table or a connector receives the invalid schema.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nYes. Previously, the schema-evolution example produced `{x: 2, y: 1, z: 3}` because the unequal nested structs were effectively resolved by name. With the configuration enabled, it produces the positional result `{x: 1, y: 2, z: 3}`.\r\n\r\nSetting `spark.sql.insertInto.columnList.differentArityStructsResolveByPosition.enabled\u003dfalse` restores the previous unequal-arity behavior. Equal-arity structs inside arrays and maps continue resolving positionally regardless of this setting.\r\n\r\nThe change also reports `INCOMPATIBLE_DATA_FOR_TABLE.AMBIGUOUS_COLUMN_NAME` when positional renaming itself introduces a duplicate field name.\r\n\r\n### How was this patch tested?\r\n\r\nAdded coverage for:\r\n\r\n- Positional schema evolution with wider and narrower nested structs under both configuration values.\r\n- Equal-arity structs inside arrays and maps when the configuration is disabled.\r\n- Rename-created collisions, including schema-mutation prevention, arrays, map keys and values, and case-sensitive resolution.\r\n- Existing input duplicates and `ACCEPT_ANY_SCHEMA` behavior.\n\nCloses #58831 from EamesTrinh/eames-trinh_data/fix-v2writes-merge-options-assert.\n\nAuthored-by: Eames Trinh \u003ceamestrinh@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "0392ed61c66c4fa6bc8495e2b732a8248c1944a7",
      "tree": "ee52e3d4e3a6c2630c5ff4df951702745e99f07e",
      "parents": [
        "96d0c97a7627d4ed8ef8cbd82a9827ea8d0c2fd1"
      ],
      "author": {
        "name": "YangJie",
        "email": "yangjie01@baidu.com",
        "time": "Mon Nov 30 14:36:15 2026 +0800"
      },
      "committer": {
        "name": "yangjie01",
        "email": "yangjie01@baidu.com",
        "time": "Mon Nov 30 14:36:15 2026 +0800"
      },
      "message": "[SPARK-62387][R] Drop SparkR support\n\n### What changes were proposed in this pull request?\n\nThis PR removes SparkR from Apache Spark 5.0.0: the R package, `bin/sparkR*`, the JVM-side R backend and ML wrappers, the R paths in spark-submit, YARN and Kubernetes, and related build, CI and docs.\n\nThese parts are not plain deletions:\n\n- spark-submit rejects `.R`/`.r` files, `sparkr-shell` and `sparkr-shell-main` (sent by the 4.x `bin/sparkR`) with an error instead of treating them as jars. `docker-image-tool.sh -R` also fails.\n- `RMainAppResource` and `Constants.APP_RESOURCE_TYPE_R` (Kubernetes, `Stable DeveloperApi`) are kept as `deprecated`, and `KubernetesDriverBuilder` rejects an `RMainAppResource` before any feature step runs. apache/spark-kubernetes-operator creates `RMainAppResource` for the `sparkRFiles` field, so deleting the class would break the operator\u0027s build on Spark 5.0.\n- The release scripts skip their R steps for 5.0 and later. `spark-rm/Dockerfile.base` keeps R, because the release workflow uses master\u0027s copy of it for branch-4.x, which still ships SparkR.\n- `spark.sql.execution.arrow.sparkr.enabled` is not added to `removedSQLConfigs`, so a leftover `true` does not fail jobs.\n\n### Why are the changes needed?\n\nThe [VOTE] \"Deprecate SparkR\" called on 2024-08-21 asked to \"deprecate the SparkR module in Apache Spark with the upcoming Spark 4 release and remove it in the next major release Spark 5\". It [passed](https://lists.apache.org/thread/y2k6jjvqy7y1rq3l220okj7qqrtywycs) on 2024-08-26 with 19 +1 votes (12 binding), no 0 and no -1.\n\n- DISCUSS thread: https://lists.apache.org/thread/qjgsgxklvpvyvbzsx1qr8o533j4zjlm5\n- VOTE thread: https://lists.apache.org/thread/3c8qxks26kqflsjh0gtjo3nldk686vtq\n\nSPARK-49347 deprecated SparkR in 4.0.0, and this PR does the removal for Spark 5. sparklyr is the recommended way to use Spark from R.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, compared to Spark 4.x. There is no SparkR package, `bin/sparkR`, or R API docs. `spark-submit app.R` fails with `R applications are not supported: SparkR was removed in Apache Spark 5.0.0`. Spark K8s operator apps that use `sparkRFiles` fail at submission once the operator runs on Spark 5.0. The core migration guide has a new 5.0 entry.\n\n**This PR is for master (5.0.0) only. It should not be backported to branch-4.x**, where SparkR is deprecated but still supported.\n\n### How was this patch tested?\n\nNew tests:\n\n- `SparkSubmitSuite` \"SPARK-62387: reject R applications\": `app.R`, `app.r`, `sparkr-shell` and `sparkr-shell-main` are rejected.\n- `DriverCommandFeatureStepSuite` \"SPARK-62387: reject R resource\" and `KubernetesDriverBuilderSuite` \"SPARK-62387: reject R applications before any feature step uploads files\": the second also checks that no local file is uploaded, with and without `DriverCommandFeatureStep` excluded.\n\nPR CI does not run the release scripts. Their changes were checked with `bash -n` and sample version strings. After merge, the scheduled release dry run on master runs the tag and package steps, but not the upload step that holds the `cp SparkR*` guard.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Opus 5.5)\n\nCloses #60913 from LuciferYang/SPARK-62387.\n\nAuthored-by: YangJie \u003cyangjie01@baidu.com\u003e\nSigned-off-by: yangjie01 \u003cyangjie01@baidu.com\u003e\n"
    },
    {
      "commit": "96d0c97a7627d4ed8ef8cbd82a9827ea8d0c2fd1",
      "tree": "f6947b32349be24d60cb5aad9fa6bdb93ecdbbdf",
      "parents": [
        "e6c5a854e332caf91fefbc687c2f880ade085a07"
      ],
      "author": {
        "name": "ChuckLin2025",
        "email": "lzequn@gmail.com",
        "time": "Mon Nov 30 11:14:09 2026 +0800"
      },
      "committer": {
        "name": "Yi Wu",
        "email": "yi.wu@databricks.com",
        "time": "Mon Nov 30 11:14:09 2026 +0800"
      },
      "message": "[SPARK-62400][CORE] Keep a local block when its disk read is interrupted\n\n### What changes were proposed in this pull request?\n\n`BlockManager.getLocalValues` removes a block when reading it from disk fails with an IO error (SPARK-39152). This PR keeps the block when the failed read was caused by an interrupt: the cause chain contains `ClosedByInterruptException`, `InterruptedIOException` or `InterruptedException`, the current thread is interrupted, or the task context is interrupted (Spark marks the context before it interrupts the thread). The exception is still rethrown. IO errors on reads that are not interrupted still remove the block, as before.\n\n### Why are the changes needed?\n\nWhen a task is killed (task cancellation, speculation, or AQE cancelling stages it no longer needs), its thread is interrupted. If the thread is blocked in an interruptible channel read, the JDK closes the channel and throws `ClosedByInterruptException`, which is an `IOException`. `getLocalValues` then deletes a block file that is not damaged.\n\nFor a cached RDD block this costs a recompute. For a block written by `localCheckpoint()`, the deleted block is the only copy and its lineage has been cut, so the next reader fails with `CHECKPOINT_RDD_BLOCK_ID_NOT_FOUND`, even though no executor was lost and the RDD was not unpersisted. We hit this in production after a stage cancellation interrupted reads of local-checkpoint blocks.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, a bug fix. Previously, a local block whose disk read was interrupted was removed, which could make a later job using a local checkpoint fail with `CHECKPOINT_RDD_BLOCK_ID_NOT_FOUND`. Now the block is kept. A block whose read fails during a task kill is kept even if the file is bad, until a later read that is not interrupted fails and removes it.\n\n### How was this patch tested?\n\nNew tests in `BlockManagerSuite`, with a disk read that fails with an injected exception:\n- `ClosedByInterruptException`: the block stays on disk and registered.\n- A plain `IOException` while the task context is interrupted: the block stays.\n- A plain `IOException` while the reading thread is interrupted: the block stays.\n- A plain `IOException` in a live task that is not interrupted: the block is removed and the removal is reported to the driver.\n- `isInterruptRelated` is checked directly for each trigger, including a nested interrupt cause and a cyclic cause chain.\n\nWith the fix disabled, the three keep-block tests fail. The existing \"check KryoException when getting disk blocks\" test still passes.\n\n```\nbuild/sbt \"core/testOnly org.apache.spark.storage.BlockManagerSuite -- -z SPARK-62400 -z \\\"check KryoException\\\"\"\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60925 from ChuckLin2025/SPARK-62400.\n\nAuthored-by: ChuckLin2025 \u003clzequn@gmail.com\u003e\nSigned-off-by: Yi Wu \u003cyi.wu@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "e6c5a854e332caf91fefbc687c2f880ade085a07",
      "tree": "91c9f5fb61517941956ed9273e1b8142f5a5659f",
      "parents": [
        "82c9dbaf6fdcb44a652acfacb90db8c6be1e5c57"
      ],
      "author": {
        "name": "Gangavarapu Vivek",
        "email": "gangavarapu.0104@gmail.com",
        "time": "Sun Nov 29 16:10:29 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Sun Nov 29 16:10:29 2026 +0100"
      },
      "message": "[SPARK-58965][SQL][PYTHON] Add gcd and lcm math functions\n\n### What changes were proposed in this pull request?\n\nThis PR adds two new built-in math functions, `gcd` and `lcm`:\n\n```sql\ngcd(expr1, expr2) -- returns BIGINT\nlcm(expr1, expr2) -- returns BIGINT\n```\n\nBoth arguments are implicitly cast to BIGINT and the result is BIGINT, matching the existing\n`factorial` expression, which likewise takes an integral argument and returns BIGINT.\n\nSemantics:\n\n| Case | `gcd` | `lcm` |\n|---|---|---|\n| either argument is NULL | NULL | NULL |\n| both arguments are 0 | 0 | 0 |\n| one argument is 0 | `abs(other)` | 0 |\n| negative arguments | result is non-negative | result is non-negative |\n| result not representable as BIGINT | `ARITHMETIC_OVERFLOW` under ANSI mode, NULL otherwise | `ARITHMETIC_OVERFLOW` under ANSI mode, NULL otherwise |\n\nThe greatest common divisor is computed with the Euclidean algorithm. The least common multiple\ndivides by the greatest common divisor before multiplying, so a representable result never\noverflows on the way there — for example `lcm(4611686018427387904, 2)` returns `4611686018427387904`\neven though the naive product `4611686018427387904 * 2` would not fit.\n\nOverflow arises in exactly two places, and in both PostgreSQL raises as well:\n\n* `gcd` where the result would be `-Long.MinValue`, which is not representable — that is, the\n  input pairs `(0, x)`, `(x, 0)` and `(x, x)` for `x \u003d Long.MinValue`.\n* `lcm` where `abs(a) / gcd(a, b) * abs(b)` exceeds `Long.MaxValue`.\n\nBoth are reported with the existing `ARITHMETIC_OVERFLOW` error condition, so no new error\ncondition is introduced. Overflow is gated on ANSI mode as it is elsewhere in Spark — `conv` in the\nsame file takes the same approach — raising under ANSI mode and returning NULL otherwise.\n\nBoth helpers live in `MathUtils` and are shared by the interpreted and codegen paths so the two\ncannot diverge.\n\nThe functions are exposed through SQL, the Scala/Java `functions` API, PySpark, and Spark Connect.\n\n### Why are the changes needed?\n\nSpark SQL currently has no way to compute either value. There is no expression for it, and no\ncombination of existing built-ins produces the result, so users have to fall back to a UDF — which\nfor PySpark means a Python round trip per row and no whole-stage codegen.\n\nBoth functions are standard in comparable engines:\n\n* PostgreSQL 13+: `gcd(a, b)`, `lcm(a, b)` for `integer`, `bigint` and `numeric`\n* DuckDB: `gcd(a, b)`, `lcm(a, b)` (aliases `greatest_common_divisor`, `least_common_multiple`)\n\nCommon uses include reducing fractions and ratios to lowest terms, aligning batch or partition\nsizes, computing the repeat period of overlapping schedules, and normalizing denominators before\naggregation.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Two new built-in functions are available in SQL, the Scala/Java `functions` API, PySpark and\nSpark Connect. Previously `gcd` and `lcm` were unresolved function names:\n\n```sql\n-- Before\nspark-sql\u003e SELECT gcd(24, 36);\n[UNRESOLVED_ROUTINE] Cannot resolve routine `gcd` on search path\n[`system`.`builtin`, `system`.`session`, `spark_catalog`.`default`]. SQLSTATE: 42883\n\n-- After\nspark-sql\u003e SELECT gcd(24, 36);\n12\nspark-sql\u003e SELECT lcm(4, 6);\n12\n```\n\nNo existing behavior changes; the change is purely additive.\n\n### How was this patch tested?\n\nNew tests:\n\n* `MathExpressionsSuite` — unit tests for both expressions covering ordinary values, negative\n  inputs, zero, NULL, the boundary values around `Long.MinValue` / `Long.MaxValue`, and overflow in\n  both ANSI and non-ANSI mode, plus interpreted-vs-codegen consistency checks.\n* `math.sql` golden-file tests, regenerated for the ANSI and non-ANSI results and the analyzer\n  results.\n* `PlanGenerationTestSuite` function tests, with the regenerated Spark Connect plan and explain\n  golden files.\n* PySpark doctests for `gcd` and `lcm`.\n\nExisting suites re-run and passing: `MathExpressionsSuite`, `SQLQueryTestSuite` (`math.sql`),\n`ExpressionsSchemaSuite`, `PlanGenerationTestSuite`, `ProtoToParsedPlanTestSuite`.\n\n`dev/lint-scala` and `dev/lint-python` both pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5)\n\nCloses #58242 from Vivek1106-04/SPARK-58965-gcd-lcm.\n\nAuthored-by: Gangavarapu Vivek \u003cgangavarapu.0104@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "82c9dbaf6fdcb44a652acfacb90db8c6be1e5c57",
      "tree": "8aba971dc99c7a1bc5d3ce3a304ba3b22ed13169",
      "parents": [
        "dc29ce923edc81eedd4ba7a21d76386b16a6d02e"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Sun Nov 29 10:07:39 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Sun Nov 29 10:07:39 2026 +0000"
      },
      "message": "[SPARK-62246][SQL][FOLLOWUP] Keep both key columns when a DataFrame as-of join with using columns has a streaming side\n\n### What changes were proposed in this pull request?\n`Dataset.joinAsOf(..., usingColumns, ...)` now builds the old plan (`left(name) \u003d\u003d\u003d right(name)`) when either side is streaming, so a streaming join keeps the key column of both sides. A batch join keeps the one-key output of #60796.\nA new internal config `spark.sql.legacy.asOfJoin.keepBothUsingColumns` (default `false`) gives batch joins the old output too. Both migration guides and the PySpark `_joinAsOf` docstrings say so.\n\nThe streaming offset log now keeps the value a query starts with. A checkpoint written before this config reads `true`: no Spark release has the one-key output yet, so every such checkpoint holds both key columns. That holds only if this change reaches `branch-4.4` before 4.4.0 ships; a separate PR will port it there.\n`Dataset.joinAsOf` marks a batch join on column names (`AsOfJoin.fromDataFrameUsingColumns`). When the value is `true` and the query has a streaming deduplication or Distinct, the query start gives a marked join both key columns back only when that operator keys its state on a key column the join gives back. `MicroBatchExecution` then removes the one-key Project above that join, above each join on top of it, and above each join that shares a key-hiding Project with it, before the dedup keys are computed. A filter or join condition that names the right key through the right DataFrame, such as `quotes(\"sym\")`, does not stop this. The query output keeps the DataFrame\u0027s columns.\nEvery other join, and every other query restarted from an earlier checkpoint, keeps its plan, so it still reads its cached static side. A cached join that does get both key columns back no longer reads its cache: its cached rows have no right key values, so it is recomputed in every micro-batch.\n\n```\nstream.joinAsOf(quotes, ts, ts, usingColumns \u003d Seq(\"sym\"))\nmaster now:  sym, ts, qty, ts, bid\nthis PR:     ts, sym, qty, ts, sym, bid   (same as Spark 4.3)\n```\n\n### Why are the changes needed?\nA streaming query with this join and a stateful operator above it, such as `dropDuplicates()`, stores rows with the old columns in its state. With the one-key output it cannot restart from its checkpoint: `STATE_STORE_KEY_SCHEMA_NOT_COMPATIBLE`.\n\n### Does this PR introduce _any_ user-facing change?\nNo, compared to Spark 4.3 for streaming joins. Compared to unreleased master and `branch-4.4`, a join with a streaming side returns both key columns again.\nA batch as-of join on column names inside a streaming query gets both key columns back when the query restarts from an earlier checkpoint and a deduplication keeps them in its state. It keeps one key column in these cases:\n- a step with its own column list is between the join and the stateful step: `select`, `withColumn`, `drop`, `withColumnRenamed`, `toDF`, `selectExpr` or a regular join on column names;\n- two steps above the join, one above the other, each name a right key through the right DataFrame, such as two filters on `quotes(\"sym\")`, or one on `quotes(\"sym\")` with one on `quotes(\"ex\")` above it (left as a TODO);\n- a stream-stream join is above the batch join: it stores its rows with one key column;\n- one as-of join of the query is under a union, INTERSECT, EXCEPT or CTE: then every as-of join of the query keeps one key column.\n\nSuch a query fails to restart only when its state holds the join\u0027s key columns. Setting the legacy config before building the DataFrame fixes it for a checkpoint from an earlier version.\nA query restarted from a checkpoint written before this config runs with the config `true` in its stream session. So a DataFrame as-of join on column names that its `foreachBatch` function builds returns both key columns, as in Spark 4.3. With a new checkpoint, it returns one column per name.\n\n### How was this patch tested?\n- `StreamingAsOfJoinSuite`: two stream-static queries whose as-of join has a streaming side restart from Spark 4.3.0 checkpoints with the state used: a join then `dropDuplicates()`, and the same with `withColumn` in between. Both fail with `STATE_STORE_KEY_SCHEMA_NOT_COMPATIBLE` on current master. Also the columns of a streaming left and right side, with the legacy config off and on.\n- `StreamingAsOfJoinSuite`, a batch join inside a stream: it restarts from a Spark 4.3.0 checkpoint (both analyzers); a new checkpoint pins `false`; the pinned value wins over the session; chained joins, unions, a CTE, `dropDuplicates(\"sym\")`, `dropDuplicatesWithinWatermark()` and `foreachBatch`. A filter or a join condition on `quotes(\"sym\")` restarts with both key columns. With `withColumn` or a join on column names above the join, the restart fails loudly, and the legacy config fixes it. A cached static side still reads the cache after the restart: with no state, with an aggregation, and when another join of the query is restored.\n- `DataFrameAsOfJoinSuite`: with the legacy config, the output equals the join on key equality (both analyzers, sort-merge on and off, ANSI on and off). The restore gives back exactly the right-side keys, restores only the joins asked for, those above them and those that share a key-hiding Project with them (also above chained joins), and one join under a union keeps every join as it is. `SparkConnectProtoSuite`: a Connect streaming join keeps both key columns. `OffsetSeqLogSuite`: the config is pinned, and an old checkpoint reads `true`.\n- Also ran `SortMergeAsOfJoinSuite`, `WholeStageCodegenSuite` and `SparkConfigBindingPolicySuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60920 from LukaZdravic/asof-62246-followup-d2.\n\nLead-authored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nCo-authored-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "dc29ce923edc81eedd4ba7a21d76386b16a6d02e",
      "tree": "2ffc569b7c1f620037c29f80ba87845df97b3d71",
      "parents": [
        "09c2936165fcdb58e42049c38b4bf92448f4b5c9"
      ],
      "author": {
        "name": "Sepuri Sai Krishna",
        "email": "saik20533@gmail.com",
        "time": "Sun Nov 29 11:01:42 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Sun Nov 29 11:01:42 2026 +0100"
      },
      "message": "[SPARK-60418][SQL] Skip subexpression elimination for a conditional IN list element\n\n### What changes were proposed in this pull request?\n\n`In` evaluates `value` and then the list elements until one of them matches, in\n`eval` and in generated code alike. An element past the match is never evaluated,\nand no element is evaluated at all when `value` is NULL.\n\n`EquivalentExpressions.skipForShortcut` already peels `And`/`Or` down to the\nsingle operand that is always evaluated, so that a subexpression shared by\nshort-circuited operands is not hoisted out and evaluated eagerly. `In` was not\npeeled, so recursing into its children counted the conditional list elements as\nalways evaluated.\n\nThis PR:\n\n- Peels `In` down to `value`, next to the existing `And`/`Or` cases, and updates\n  the config doc to list `IN`. The `In` expression itself is still eliminated as a\n  whole when it repeats, because it carries its own short-circuit; only its list\n  elements stop being candidates.\n- Adds the operand the peel lands on as a candidate itself. `updateExprTree` used\n  to recurse straight into that operand\u0027s children, so the operand was never\n  counted. With `In` peeled to `value`, that would have made\n  `SELECT upper(s) IN (\u0027A\u0027, \u0027B\u0027), upper(s) FROM t` evaluate `upper(s)` twice, where\n  it was evaluated once before. `updateExprTree` now calls itself on the operand\n  when the peel moves, so the operand is counted and its own children are guarded\n  as before. The same gap existed for the leftmost operand of an `And`/`Or` chain\n  since the shortcut was added, and this closes it too.\n\nThe scope is deliberately the same as the existing cases: the peel stays behind\n`spark.sql.subexpressionElimination.skipForShortcutExpr`, which is `false` by\ndefault, so `IN` now behaves exactly like `AND`/`OR` under that config rather\nthan differently from them. Whether that default should change is a separate\nquestion that applies equally to `AND`/`OR`.\n\n### Why are the changes needed?\n\nA query that must return rows fails instead. In ANSI mode:\n\n```sql\nCREATE OR REPLACE TEMP VIEW t AS\n  SELECT cast(id as int) AS b, cast(2147483647 - id as int) AS y FROM range(1);\n\nSELECT b IN (b, y + 1), b IN (b, y + 1, 7) FROM t;\n```\n\n`b` matches the first element of both lists, so `y + 1` is never needed, but the\nquery fails with `[ARITHMETIC_OVERFLOW]`. Either `IN` on its own returns `true`,\nand so does the query with `spark.sql.subexpressionElimination.enabled` set to\n`false`, so the error comes from the elimination and not from the query. It fails\nwith whole-stage codegen both on and off.\n\n`In` short-circuits the same way `And` and `Or` do, and is already listed\nalongside them as conditionally evaluated in `OptimizeCsvJsonExprs`.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, with `spark.sql.subexpressionElimination.skipForShortcutExpr` set to `true`.\nA query whose `IN` list element is a common subexpression no longer evaluates that\nelement before the comparison, so it no longer raises an error that the\nshort-circuit should have avoided. The query above returns `true, true` instead of\nfailing. An `IN` `value`, or the leftmost operand of an `AND`/`OR`, that also\noccurs elsewhere is now evaluated once instead of once per occurrence. Nothing\nchanges under the default configuration, and no result that was already correct\nchanges.\n\n### How was this patch tested?\n\nNew tests, all of which fail without the change:\n\n- `SubexpressionEliminationSuite`:\n  - A unit test over `EquivalentExpressions` covering a subexpression in a\n    conditional element in each position, `value` staying eligible, the peel\n    reaching `value` through an `And` chain and an `In` inside an `And`, two `In`s\n    sharing an element (the reported shape), and a repeated `In` still being\n    eliminated as a whole.\n  - A unit test where the operand the peel lands on is shared with an expression\n    outside it: an `In` `value`, directly and behind an `And`, two `In`s sharing\n    only their `value`, and the leftmost operand of an `And` and of an `Or` chain.\n- `SQLQuerySuite`: an end-to-end test next to the existing `SPARK-58211` and\n  `SPARK-59579` tests, in the same shape, which raises `[DIVIDE_BY_ZERO]` without\n  the change.\n\nRan `SubexpressionEliminationSuite`, `CodegenSubexpressionEliminationSuite`,\n`SubExprEvaluationRuntimeSuite`, `PredicateSuite` and `OptimizeInSuite`, and the\n`SPARK-58211`, `SPARK-59579` and `SPARK-60418` tests of `SQLQuerySuite`, all\npassing.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #59668 from SEPURI-SAI-KRISHNA/SPARK-60418-in-cse-shortcut.\n\nAuthored-by: Sepuri Sai Krishna \u003csaik20533@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "09c2936165fcdb58e42049c38b4bf92448f4b5c9",
      "tree": "95b1b88894ae5630829d052d3c40e44f137bf766",
      "parents": [
        "64f053a035c2662c3697c0d48ebbb951099f4c3b"
      ],
      "author": {
        "name": "dustin",
        "email": "dustin.william.smith@gmail.com",
        "time": "Sun Nov 29 10:54:13 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Sun Nov 29 10:54:13 2026 +0100"
      },
      "message": "[SPARK-62352][SQL] Compare decimals without building a Scala BigDecimal\n\n### What changes were proposed in this pull request?\n\n`Decimal.compare` uses `java.math.BigDecimal` when the two values aren\u0027t both longs with the same scale.\n\n### Why are the changes needed?\n\nIt built a Scala `BigDecimal` for a long on every call. Scala\u0027s `compare` only hands over to the Java one, so the answer is the same.\n\n`DecimalComparisonBenchmark`, ns per row:\n\n| Case | master, JDK 21 | this PR, JDK 21 | master, JDK 25 | this PR, JDK 25 |\n|---|---|---|---|---|\n| filter on decimal(15,2) | 235.2 | 92.2 | 248.4 | 98.0 |\n| filter on decimal(20,2) | 118.7 | 108.6 | 126.2 | 104.1 |\n| max of decimal(20,2) | 65.8 | 63.6 | 65.9 | 61.8 |\n\nAll runs used an AMD EPYC 7763, one run each. The `DECIMAL(20,2)` rows do the same work before and after, so their movement is noise between runs.\n\nThe gain is for `IN` lists of up to 10 literals and for range checks. Longer lists use a hash lookup, which this doesn\u0027t touch. The `DECIMAL(20,2)` rows are there as a control, since both sides already hold a `BigDecimal`.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nA new `DecimalSuite` test compares values in both forms, at the same and at different scales. New `DecimalComparisonBenchmark`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nNo\n\nCloses #60877 from dwsmith1983/perf/decimal-compare.\n\nAuthored-by: dustin  \u003cdustin.william.smith@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "64f053a035c2662c3697c0d48ebbb951099f4c3b",
      "tree": "ebcf2d4218d8ff7fe4db212c3c1878b05bb11016",
      "parents": [
        "d95f1e070bcb547c6d224e4b8458d61490a94597"
      ],
      "author": {
        "name": "Sepuri Sai Krishna",
        "email": "saik20533@gmail.com",
        "time": "Sun Nov 29 10:45:15 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Sun Nov 29 10:45:15 2026 +0100"
      },
      "message": "[SPARK-60910][SQL] Fail on overflow in datediff instead of wrapping around\n\n### What changes were proposed in this pull request?\n\nThis PR makes `datediff` / `date_diff` with two date arguments (`DateDiff`) fail with `DATETIME_OVERFLOW` when the number of days between the dates does not fit in an `Int`, instead of silently wrapping around. It adds `DateTimeUtils.daysBetween`, which uses `Math.subtractExact`, and uses it in both the interpreted and the generated code.\n\nIt also makes subtracting a date from a date (`SubtractDates`, for example `d1 - d2`) raise the same `DATETIME_OVERFLOW` error instead of a raw `java.lang.ArithmeticException` when the difference does not fit in the day-time interval result. The new `DateTimeUtils.subtractDatesToMicros` subtracts the day counts as `Long`s, so a single `Math.multiplyExact` detects every overflow.\n\nBoth errors carry the query context of the expression, so they show which `datediff` or `d1 - d2` overflowed. `DateDiff` and `SubtractDates` mix in a new `DateArithmeticQueryContext`, a `SupportQueryContext` whose query context is that of the expression (`SubtractDates` has none with `spark.sql.legacy.interval.enabled`, where it cannot overflow). With ANSI mode off, `d1 - d2` is first resolved into a `Subtract`, which has no query context as it cannot fail. Since #60285, `SupportQueryContext.copyTagsFrom` does not copy that missing context onto the `SubtractDates` that replaces it, so it keeps its own. The trait is the same as in #59135.\n\nThe error message formats its dates with the new `QueryExecutionErrors.toSQLDate`, in the proleptic Gregorian calendar of DATE values, whatever `spark.sql.legacy.timeParserPolicy` is. Under `LEGACY`, `toSQLValue(_, DateType)` uses the legacy formatter, whose rebasing to the Julian calendar overflows for the dates within about 44,500 days of the minimum DATE, so building the error would throw a raw `java.lang.ArithmeticException` instead. The `next_day`, `last_day` and `trunc` overflow errors of SPARK-60929 use the helper too: `trunc` overflows only at the minimum DATE, so under `LEGACY`, for example, `trunc(date_from_unix_date(-2147483648), \u0027QUARTER\u0027)` failed the same way.\n\n### Why are the changes needed?\n\n`DateDiff` subtracts the two day counts as `Int`s, so the result wraps around for dates far apart, with ANSI mode on or off:\n\n```sql\nSELECT datediff(date_from_unix_date(2147483647), date_from_unix_date(-1));\n-- -2147483648, should be 2147483648\n\nSELECT datediff(date_from_unix_date(2147483647), date_from_unix_date(-2147483648));\n-- -1, should be 4294967295\n```\n\nThis is the same class of bug as SPARK-59859 (`date_add` / `date_sub`), and was raised in the review of #59135. Subtracting the same dates (`d1 - d2`) already fails, but with `java.lang.ArithmeticException: integer overflow` (or `long overflow`) without an error class.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. When the number of days between the two dates does not fit in an `Int`, `datediff` / `date_diff` now fail instead of returning a wrapped value, regardless of `spark.sql.ansi.enabled`:\n\n```\norg.apache.spark.SparkArithmeticException: [DATETIME_OVERFLOW] Datetime operation overflow: subtract DATE \u00271969-12-31\u0027 from DATE \u0027+5881580-07-11\u0027. SQLSTATE: 22008\n\u003d\u003d SQL (line 1, position 8) \u003d\u003d\nSELECT datediff(date_from_unix_date(2147483647), date_from_unix_date(-1))\n       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n```\n\nSubtracting a date from a date fails with the same error instead of `java.lang.ArithmeticException` in that case, and `try_subtract` on dates still returns `NULL`. Results that fit are unchanged; for dates between 0001-01-01 and 9999-12-31 the difference always fits. There is no configuration to restore the wrapped `datediff` result; the SQL migration guide (4.4 to 4.5) documents the change and how to get the previous result (`unix_date(end) - unix_date(start)` with ANSI mode off) or `NULL` (`try_subtract(unix_date(end), unix_date(start))`). The `datediff` usage says that it fails with `DATETIME_OVERFLOW` in that case.\n\nUnder `spark.sql.legacy.timeParserPolicy\u003dLEGACY`, the dates in a `DATETIME_OVERFLOW` message of `datediff`, date subtraction, `next_day`, `last_day` and `trunc` are now formatted as under the other policies, for example `DATE \u0027+5881580-07-11\u0027` instead of `DATE \u00275881580-07-11\u0027`, and a date near the minimum DATE no longer makes `trunc` fail with `java.lang.ArithmeticException` instead of `DATETIME_OVERFLOW`.\n\n`timestampdiff` and `months_between` on such dates are not changed: they cast the dates to timestamps first, and that cast fails for dates outside the timestamp range.\n\n### How was this patch tested?\n\n- New tests in `DateExpressionsSuite`: `datediff` overflow in both directions, the largest and smallest differences that still fit, and the interpreted vs codegen consistency check for `DateDiff`; `SubtractDates` overflow just past the largest day-time interval (106751991 days) and far past it, and the largest differences that still fit; the `datediff` overflow at both ends of the DATE range, and the date subtraction and `trunc` overflows at the minimum DATE, under each `spark.sql.legacy.timeParserPolicy` (fails without the `toSQLDate` change with `java.lang.ArithmeticException: integer overflow` from `RebaseDateTime.localRebaseGregorianToJulianDays` under `LEGACY`).\n- New queries at the end of `date.sql` (also imported by `nonansi/date.sql` and `datetime-legacy.sql`), golden files regenerated; two of them (`datediff` and `-`) overflow at the minimum DATE, which `datetime-legacy.sql` runs under `LEGACY`. Without this change, the `datediff` cases return the wrapped values `-2147483648` and `2147483647`, and the subtraction case fails with `java.lang.ArithmeticException: integer overflow` (checked on master).\n- Updated the date subtraction overflow check in `ColumnExpressionSuite` (SPARK-34896), which expected the raw `ArithmeticException`, to expect `DATETIME_OVERFLOW` with the DataFrame query context.\n- A new `DateFunctionsSuite` test that the error has the query context of the overflowing expression, for `datediff` and `e - s` in SQL and `datediff` in the DataFrame API, with ANSI mode on and off, and that the replacements in the migration guide give the previous result and `NULL`. The golden files show the query context of each overflow in `date.sql`, `nonansi/date.sql` and `datetime-legacy.sql`.\n- Ran `DateExpressionsSuite`, `DateTimeUtilsSuite`, `DateFunctionsSuite`, `ColumnExpressionSuite`, and the date, `datetime-legacy`, timestamp and interval tests in `SQLQueryTestSuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\n\n\nCloses #60134 from SEPURI-SAI-KRISHNA/datediff-overflow.\n\nAuthored-by: Sepuri Sai Krishna \u003csaik20533@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d95f1e070bcb547c6d224e4b8458d61490a94597",
      "tree": "9275df47cc01ff0e15d5edeb35826a4ff7d2b6aa",
      "parents": [
        "9e70dedef78b594d6467826c95a111c191981e12"
      ],
      "author": {
        "name": "Avery",
        "email": "averyqi115@gmail.com",
        "time": "Sun Nov 29 05:55:26 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Sun Nov 29 05:55:26 2026 +0000"
      },
      "message": "[SPARK-59681][SQL] Guaranteed CTE shuffle reuse\n\n## TL;DR\n\nGuarantees that a CTE marked non-inlinable (`CTERelationDef.forceSkipInline \u003d true`) is **materialized exactly once and physically reused** across all of its references. When a batch query\u0027s plan holds two or more copies of such a CTE\u0027s body, each reference is turned into a `CTEReuseExchange` node wrapped over a single shuffle of the CTE body. With Adaptive Query Execution (AQE) enabled, execution respects the `CTEReuseExchange` and every reference reads the **same shuffle** rather than recomputing the CTE. With AQE off, reuse is achieved through the stock `ReuseExchangeAndSubquery` (canonical matching) and is best-effort rather than a hard guarantee — `VerifyCTEReuse` detects a miss and logs it, or throws when `spark.sql.cteReuse.failOnMissWithoutAQE` is on (only the suites that check reuse turn it on). This closes the gap where stock `ReuseExchangeAndSubquery` cannot guarantee reuse for a non-deterministic CTE body — since shuffles introduced for the materialized CTE might be removed or changed during physical planning, other operation like runtime filter injection, empty relation propagation could also break the canonical equivalence in previous approach. No code in Apache Spark sets `forceSkipInline` yet, so the new path runs only for plans that a producer outside this PR marks.\n\n### Why it is needed\n\nA CTE referenced multiple times can be either inlined (recomputed per reference) or materialized once. For a **non-deterministic** body (e.g. `rand()`, `monotonically_increasing_id()`, non-deterministic UDFs), recomputation is not just wasteful but **semantically wrong** — each reference would observe different rows. Stock reuse keys on canonical equality of the physical subtrees, which non-determinism and per-reference `exprId` remapping defeat. This change introduces a `cteId`-keyed mechanism so all references provably share one materialized exchange.\n\n---\n\n## Life cycle\n\nThe feature threads one identity — the `cteId` — from the logical plan down to a single physical shuffle. This `cteId`, in `CTEReuseRelation`, `CTEReuseExchange` and `LOCAL_SHUFFLE_FOR_CTE`, is the plan-reuse id, which sealed definitions with canonically equal deterministic bodies share; it is not the `CTERelationDef` id that plans print.\n\n```\nCTERelationDef / CTERelationRef            (analyzer; forceSkipInline \u003d true)\n        │  ReplaceCTERefWithRepartition\n        ▼\nRepartitionByExpression (plan-reuse id)    (optimizer; body inlined + deduplicated)\n        │  ReplaceRepartitionWithCTEReuse\n        ▼\nCTEReuseRelation(cteId, partitioning, …)   (optimizer; only when the plan holds \u003e\u003d 2 copies)\n        │  SparkStrategies\n        ▼\nCTEReuseExchange(cteId, shuffle)           (physical leaf; shuffle held as metadata)\n        │\n        ├── AQE on  ─▶  CTEReuseQueryStageExec ─▶ inner AdaptiveSparkPlanExec ─▶ Shuffle\n        └── AQE off ─▶  LOCAL_SHUFFLE_FOR_CTE shuffle ─▶ ReusedExchangeExec (canonical reuse)\n```\n\n### Logical → physical (common to both modes)\n\n- **`ReplaceCTERefWithRepartition`** seals only a `forceSkipInline` definition whose body a **batch** query\u0027s lowered plan holds **two or more copies** of. Copies are counted through unsealed enclosing bodies and subqueries: a sealed enclosing body counts once, and a definition nothing reads counts zero. Each reference to a sealed definition becomes a copy of the inlined body under a *plan-reuse* `RepartitionByExpression` (a non-zero `repartitionId`, assigned by `RepartitionIdGenerator`). The inlined body is run through `DeduplicateRelations` so each copy gets fresh `exprId`s — the `repartitionId`, not `exprId` equality, is what ties the copies together.\n  - A root that already plans to one shuffle carries the id in place: a `RepartitionByExpression` as is, a shuffling `REPARTITION(n)` as a `RepartitionByExpression` to n partitions, and a rebalance as a `RepartitionByExpression` with its keys, partition count and advisory size. A coalesce root is wrapped in a repartition to its own partition count, and any other root (including a body under a subquery) in a round-robin repartition over `spark.sql.shuffle.partitions`.\n  - Forced definitions with canonically equal deterministic bodies share one id, and a body that only selects another shared forced CTE keeps that CTE\u0027s id.\n  - A definition the plan reads but does not seal on its own, such as a forced CTE read once or an ordinary `MATERIALIZED` CTE, is sealed with a sealed forced definition when its deterministic body equals that definition\u0027s root, and shares its plan-reuse id, so the body is still computed once.\n  - A sealed forced definition whose body only selects an unsealed CTE that the plan also reads elsewhere, such as a `MATERIALIZED` CTE, seals that CTE together with it, deterministic or not: both share that CTE\u0027s plan-reuse id, so its rows are shuffled once, and that CTE\u0027s direct readers then read the shared shuffle\u0027s fixed layout. A repartition above that CTE\u0027s root remains only as a fallback, when sealing it would not leave it sharing the forced definition\u0027s id.\n  - Every other definition keeps the plain lowering it had before this change, including a forced definition with a single copy and no such sealed twin, and every definition of a **streaming** query, so per-micro-batch rewrites such as reseeding random expressions keep reaching every copy.\n  - `CTERelationDef.forcePartitioning` lets a producer pin the materialized partitioning. It is honored only on a `forceSkipInline` definition while `spark.sql.cteReuse.enabled` is on, sealed or not: a `HashPartitioning` pin repartitions the body on its keys and partition count, and CTE column pruning keeps the pin\u0027s key columns. Any other partitioning raises `UnsupportedOperationException`. A pin on a definition that is not `forceSkipInline`, or any pin with the flag off, is ignored and leaves the plan unchanged.\n- **`ReplaceRepartitionWithCTEReuse`** (main-query pass only) seals each plan-reuse id into `CTEReuseRelation(cteId, partitioning, sharedSubplan)` nodes, counting copies across the whole plan including subqueries. `sharedSubplan` is deliberately **not a child** of `CTEReuseRelation`, so outer-plan re-optimization treats the reference as a leaf and never descends into (or diverges) the shared body. As defensive fallbacks, an id left with a single copy is reset to an ordinary repartition, and if the sealed plan fails `LogicalPlanIntegrity.validateCTEReuseRelations` (one `cteId` with different canonical bodies, nested relations included), nothing is sealed.\n- **`SparkStrategies`** plans `CTEReuseRelation` eagerly (not via `planLater`, since the shuffle lives in metadata that the placeholder collector cannot see) into a `ShuffleExchangeExec` over the body, and wraps it as a `CTEReuseExchange(cteId, shuffle)` leaf. The shuffle\u0027s `LOCAL_SHUFFLE_FOR_CTE(cteId)` origin is derived from the logical plan-reuse `RepartitionByExpression`, so every AQE replan of the shared body keeps it. The shuffle is stored in `innerChildren`, not `children`, so AQE\u0027s bottom-up stage creation does not redundantly plan its substages. Every reference still plans the shared body on its own, as the base branch planned each inlined copy. Under AQE, each later reference of a body that holds a subquery also compiles that subquery again, which the base branch compiled once. Planning each shared body, its subqueries included, once per plan-reuse id is deferred to a follow-up.\n\n### AQE on: `CTEReuseExchange → CTEReuseQueryStageExec → inner AdaptiveSparkPlanExec → Shuffle`\n\n- **`PlanCTEReuse`** (a preprocessing rule alongside `PlanAdaptiveSubqueries`) builds **one shared inner `AdaptiveSparkPlanExec` per `cteId`**, registered in `AdaptiveExecutionContext.cteAQERegistry`. The registry lives on the shared execution context, so the identical inner AQE instance is reused across every reference — main query and subqueries — and across re-plans, preventing duplicate replanning or plan divergence of the shared body.\n- **`createNonResultQueryStages`** replaces each `CTEReuseExchange` with a `CTEReuseQueryStageExec(id, innerAQE, output)`. All references\u0027 stages point at the same inner AQE; each stage remaps the inner AQE\u0027s (primary reference\u0027s) attribute ids into its own reference\u0027s id space, mirroring `ReusedExchangeExec`. Execution and statistics delegate to the inner AQE\u0027s post-iteration `executedPlan`, so the shared body is iterated once.\n- A `CTEReuseQueryStageExec` that an adaptive replan drops (for example after empty-relation propagation) is not cancelled. Its later failure is ignored, as for an uncancelled obsolete exchange stage, while every reference the plan still reads is its own stage and fails the query with the body\u0027s error.\n- When `PlanCTEReuse` cannot wrap a CTE subplan in an inner AQE, because the shared body does not support adaptive execution or holds a subquery or nested CTE reference that cannot be planned adaptively, the whole query backs off AQE by design: it falls back to non-AQE execution, and the AQE-off path below handles the CTE.\n\n### AQE off: `CTEReuseExchange → LOCAL_SHUFFLE_FOR_CTE shuffle → ReusedExchangeExec`\n\n- **`UnwrapCTEReuseExchange`** (early in the preparation pipeline, in both the main and subquery batches) replaces each `CTEReuseExchange` with its underlying `LOCAL_SHUFFLE_FOR_CTE(cteId)` shuffle. From there all normal preparation rules run per copy.\n- Because every copy of a `cteId` is planned from the same canonicalized `sharedSubplan` and the shuffle is protected from `EnsureRequirements`, the copies normally stay **canonically equal**, and the stock **`ReuseExchangeAndSubquery`** deduplicates them into `ReusedExchangeExec`. A preparation rule that carries a consumer\u0027s context through an exchange, such as `DisableUnnecessaryBucketedScan` for a body over a bucketed table, can still plan two copies differently, and `VerifyCTEReuse` then reports the miss.\n- **`VerifyCTEReuse`** runs on the main query only, right after `ReuseExchangeAndSubquery`, and only when the optimized plan seals a CTE; it checks that at most one live shuffle per `cteId` remains. Under `spark.sql.cteReuse.failOnMissWithoutAQE` (default off, in tests too; the suites that check reuse turn it on) a miss throws; otherwise it logs.\n- A miss, for example with `spark.sql.exchange.reuse\u003dfalse`, means a non-deterministic forced CTE runs once per reference, so its references can see different rows. A fail-closed guarantee for the AQE-off route, one owner per `cteId` that materializes the CTE once whatever exchange reuse does, is deferred to a follow-up (TODO at `VerifyCTEReuse`).\n\n---\n\n## Design considerations and details\n\n### When AQE is on\n\n**1. Deadlock avoidance (dedicated thread pool).** The inner AQE is materialized via `materialize()` / lazy `materializeFuture`, which calls `withFinalPlanUpdate(skipResultStage \u003d true)` on a **dedicated** `cteExecutionContext` thread pool (sized by the static `spark.sql.cteReuse.maxThreadThreshold`, 1 to 1024, default 1024). The outer AQE\u0027s stage-materialization threads block waiting on the CTE stage to finish; if the inner AQE materialized on the same shared `QueryStageCreator` pool, nested materialization could exhaust that pool while outer threads hold slots waiting on it — a classic thread-pool deadlock. A separate pool keeps those waits off `QueryStageCreator`, but it is bounded too: a nested forced CTE\u0027s inner AQE needs a thread from it while its parent\u0027s thread waits, so a small threshold or many concurrent parents can still exhaust it. A progress guarantee for nested materialization is a follow-up (TODO at `cteExecutionContext`), and so is cancelling the shared inner AQE when the outer query fails or no longer needs it (TODO at `CTEReuseQueryStageExec`); until then the inner plan runs its stages to completion. Jobs on this pool carry the initiating query\u0027s thread-locals (execution id, job tags and group, scheduler properties, artifact state), as subquery execution does. `skipResultStage \u003d true` materializes the shared body\u0027s stages without wrapping a `ResultQueryStageExec`, since the CTE stage is an input to other stages, not a query result.\n\n**2. Runtime filters.** The CTE body is materialized once and shared across all consumers, so consumer-specific runtime filters (dynamic partition pruning, bloom filters) must **not** be pushed below the reuse boundary — doing so would specialize the single shared result to one consumer and corrupt the others. Runtime filters are applied per consumer *above* the `CTEReuseExchange`; the shared subplan itself is never specialized. This is a deliberate limitation of guaranteed reuse: correctness of the shared materialization takes precedence over consumer-local filter pushdown.\n\n**3. Shuffle planning (`EnsureRequirements`).** The reuse shuffle\u0027s partitioning is fixed at the logical level (`CTEReuseRelation.partitioning`, the sealed root\u0027s own partitioning: a `forcePartitioning` pin, a root repartition or rebalance carrying the id in place, or the repartition wrapped around any other root, as described above; nothing derives it from the consumers). `EnsureRequirements` must not rewrite it, because re-deriving partitioning per consumer would make the copies diverge and defeat reuse. The guard is `case s: ShuffleExchangeExec if !s.isCreatedForSubplanReuse \u003d\u003e s.copy(outputPartitioning \u003d …)`, where `isCreatedForSubplanReuse` is true for the `LOCAL_SHUFFLE_FOR_CTE` origin. The protected shuffle is an immutable boundary: consumer-dependent operators are added *above* it, keeping the subtree below canonically identical across copies. The same origin also keeps the shuffle out of the AQE `supportedShuffleOrigins` allowlists (coalesce / local read / skew join), and every consumer reads the shared stage through `CTEReuseQueryStageExec`, which those rules do not wrap, so its partition layout stays frozen. Likewise, with the internal local pipelined shuffle on, `AQEEnablePipelinedShuffle` never pipelines a `LOCAL_SHUFFLE_FOR_CTE` shuffle or an exchange that reads a CTE reference, and it treats a CTE reference as a regular prefix, so the pipelined rewrite stays off the reuse boundary.\n\n**4. Costs of the frozen layout.** Every consumer stage reads all of the shared shuffle\u0027s planned partitions. That includes a deterministic forced CTE whose copies exchange reuse already shared before this change, with each consumer\u0027s read coalesced: such a CTE now runs one task per planned partition in every consumer stage. Results are unaffected. Giving each consumer its own adaptive read of the shared map output (coalescing, local reads, skew splitting), while a `forcePartitioning` pin keeps its exact layout, is deferred to a follow-up (TODO at `CTEReuseQueryStageExec`).\n\nThe protected root has a second cost: a forced CTE whose root is a user hash repartition that its body already satisfies, such as `REPARTITION(k)` over `GROUP BY k`, keeps that root as a protected shuffle that `EnsureRequirements` no longer removes, so it shuffles its output once more than on the base branch. Results are unaffected.\n\n**5. Inner plans that outlive their query.** Because the shared inner plan is not cancelled with its query, it can still submit jobs under the query\u0027s execution id after the query has ended and released the scheduler\u0027s per-query job entries for that id. `SQLExecution` keeps an execution-scoped registry of the shared inner CTE plans that run under each execution id: an inner plan registers before its first job, and when it finishes after its execution has ended, it releases the scheduler\u0027s per-query job entries of that id again. This covers an inner plan in any adaptive context, including a cached relation\u0027s, and one that starts only after its execution ended. The end of each execution is a constant-time registry update, and no entry outlives an ended execution and its inner plans. The SQL UI handles such late events too: when an adaptive SQL metric update arrives for an execution that has already ended, `SQLAppStatusListener` now rebuilds the live entry from the stored record instead of replacing that record with a blank running entry, and that restore path, which a late job also takes, now keeps the stored error message.\n\n### When AQE is off\n\n**1. Interaction with `planSubqueries`.** With AQE off, subqueries are prepared **separately** — `PlanSubqueries` calls `QueryExecution.prepareExecutedPlan → preparations(subquery \u003d true)`, applying the preparation rules recursively to each subquery plan on its own. So `UnwrapCTEReuseExchange` is registered in **both** the main and subquery preparation batches, ensuring CTE references *inside subqueries* are unwrapped too. Conversely, `VerifyCTEReuse` runs **only on the final main-query pass**: during the per-subquery `PlanSubqueries` invocations, reuse across the whole plan is not yet complete, so verifying there would produce false negatives. Reuse itself is achieved entirely through the stock `ReuseExchangeAndSubquery` (canonical matching) — this change adds no new dedup engine for the AQE-off path, only the protected `LOCAL_SHUFFLE_FOR_CTE` boundary that keeps the copies canonically equal for the stock rule to find.\n\n## Testing\n\nAdds `CTEReuseWithAQESuite`, `CTEReuseWithoutAQESuite`, and `ReplaceCTERefAndRepartitionWithCTEReuseSuite` covering the optimizer rewrites, the AQE-on inner-AQE path, and the AQE-off canonical-reuse path (including reuse across subqueries). The internal `spark.sql.cteReuse.enabled` defaults to **on**, but it only changes plans for CTEs marked `forceSkipInline`, which no code in Apache Spark sets yet, so plans for ordinary CTEs are unaffected. Turning `spark.sql.cteReuse.enabled` off restores the base branch\u0027s lowering of forced CTEs, so the flag is a complete rollback. `spark.sql.cteReuse.failOnMissWithoutAQE` defaults to off, in tests too; the suites that check reuse turn it on.\n\n---\n\nCo-authored-by: Maryann Xue \u003cmaryann.xuegmail.com\u003e\nCo-authored-by: Juliusz Sompolski \u003cjulekdatabricks.com\u003e\n\nThis pull request and its description were written by Isaac.\n\n\nCloses #58924 from AveryQi115/cte-reuse-guaranteed.\n\nLead-authored-by: Avery \u003caveryqi115@gmail.com\u003e\nCo-authored-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "9e70dedef78b594d6467826c95a111c191981e12",
      "tree": "fd81b9c00e807a9057da69a9e638cab453bb815b",
      "parents": [
        "e55fe54b5aa6a44b56af1a24124d5b458245324c"
      ],
      "author": {
        "name": "Anurag Mantripragada",
        "email": "amantripragada@apple.com",
        "time": "Sat Nov 28 17:26:39 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Sat Nov 28 17:26:39 2026 -0800"
      },
      "message": "[SPARK-58111][SQL] Scan and write schema narrowing for column-level UPDATE in DSv2\n\n### What changes were proposed in this pull request?\n\nFor SPIP: [SPARK-56599](https://issues.apache.org/jira/browse/SPARK-56599)\n\nThis PR adds an opt-in DSv2 mix-in that lets a connector receive narrow rows for a column-level UPDATE, so it can avoid reading and writing full-table rows when only some columns change.\n\nPublic API additions (since 4.4.0):\n\n- `SupportsColumnUpdates` (`Experimental`), a mix-in on `RowLevelOperation`. The connector declares in `requiredDataAttributes()` every top-level data column it needs in the rows it receives: the updated columns plus any columns it needs for row lookup, routing or planning, such as partition source columns and the columns of its required distribution and ordering. For an UPDATE, Spark rejects an invalid declaration at analysis time with dedicated error conditions, except for missing columns of the required distribution and ordering, which Spark checks when it builds the write. Other commands do not use the declaration. If the declaration is empty, Spark does not narrow the write and the operation receives full-width rows. An UPDATE that sets a column is still rejected, because the declaration misses it.\n- `RowLevelOperationInfo.updatedColumns()`: the columns the UPDATE assigns, at root-column granularity for nested fields. Identity assignments such as `SET a \u003d a` are excluded, with two exceptions: a self-assignment on a column whose type contains `CHAR` or `VARCHAR` at any depth, such as `ARRAY\u003cCHAR(3)\u003e`, when Spark pads or length-checks the assigned value, as it does by default; and a nested self-assignment such as `SET s.c1 \u003d s.c1`, which reports `s`. Metadata columns are never reported. Other commands report an empty array.\n- `LogicalWriteInfo.columnUpdateSchema()` (`Evolving`): the schema of updated, copied and reinserted rows of a column-level update. When it is present, `schema()` covers only newly inserted rows. It is present only for an `UPDATE` whose operation mixes in `SupportsColumnUpdates` and declares at least one column. Its default throws `DATA_SOURCE_COLUMN_UPDATE_SCHEMA_NOT_IMPLEMENTED`, like `rowIdSchema()` and `metadataSchema()`.\n- `DataWriter.writeColumnUpdate(record)` and `writeColumnUpdate(metadata, record)` (`Evolving`): the write path for updated and copied rows of a group-based operation when `columnUpdateSchema()` is present. Delta-based operations receive narrow rows through the existing `DeltaWriter.update` and `DeltaWriter.reinsert`. When `columnUpdateSchema()` is present, writers for operations that represent `UPDATE` as delete and insert must override `reinsert`, whose default passes the narrow row to `insert`.\n\nWhen an UPDATE runs against an operation that mixes in `SupportsColumnUpdates`:\n\n- Write side: `RewriteUpdateTable` narrows only the write relation to the declared columns, in declared order. `V2Writes` rejects a write relation that no longer matches the operation, for example after a rule replaced the operation, with an internal error.\n- Read side: `RowLevelWrite.references` is exactly the operation column plus the query columns the write\u0027s projections read. When the write relation\u0027s data column names differ from the table\u0027s, as in a column update, `ColumnPruning` prunes every other query column and remaps the projections. Other row-level writes keep every query column, as before, and so does a column update that declares every data column in table order, like a full-width write. For a narrow write, copy-on-write scans are planned from the columns the write query reads, at the top level only, so a struct referenced through a nested field is read in full. Other copy-on-write scans still read every column. Delta-based scans are pruned by the existing pushdown, including nested fields.\n- Validation: a write whose required distribution or ordering references a column that is not passed to the write, at any depth, is rejected after `build()` with `COLUMN_UPDATE_UNDECLARED_WRITE_REQUIREMENT_COLUMNS`, whether or not column pruning ran. Required metadata columns and, for delta-based operations, row ID columns are exempt. For an operation that represents UPDATE as delete and insert, the reinserted row carries only the declared columns, and Spark does not relate it to the deleted row.\n- A group-based connector should locate original rows through metadata columns preserved on update, or build an operation without the mix-in when the UPDATE assigns the data column it looks rows up by. A connector that represents updates as deletes and inserts and relates the two rows through a data column can do the same, since the reinserted row carries the assigned value.\n\nMERGE and DELETE are not narrowed yet. Following review, the MERGE follow-up will keep the write relation full width and carry the narrow layout in a `columnUpdateProjection` of the write\u0027s projections, and a separate follow-up will check the names and types of the projected columns. The API is keyed on whether `columnUpdateSchema()` is present rather than on the command, so MERGE can be narrowed later without API changes.\n\n### Why are the changes needed?\n\nSchema narrowing lets connectors request only the columns an UPDATE needs, which enables efficient column-level updates of wide tables.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, new public DSv2 connector APIs:\n\n- `RowLevelOperation` mix-in `SupportsColumnUpdates` (`requiredDataAttributes()`)\n- `RowLevelOperationInfo.updatedColumns()`\n- `LogicalWriteInfo.columnUpdateSchema()`\n- `DataWriter.writeColumnUpdate(...)`\n- New error conditions:\n  - `COLUMN_UPDATE_NESTED_REQUIRED_DATA_ATTRIBUTE`\n  - `COLUMN_UPDATE_DUPLICATE_REQUIRED_DATA_ATTRIBUTE`\n  - `COLUMN_UPDATE_METADATA_REQUIRED_DATA_ATTRIBUTE`\n  - `COLUMN_UPDATE_UNKNOWN_REQUIRED_DATA_ATTRIBUTE`\n  - `COLUMN_UPDATE_REQUIRED_DATA_ATTRIBUTES_MISSING_UPDATED_COLUMNS`\n  - `COLUMN_UPDATE_UNDECLARED_WRITE_REQUIREMENT_COLUMNS`\n  - `DATA_SOURCE_WRITE_COLUMN_UPDATE_NOT_IMPLEMENTED`, raised by a data writer that does not override `writeColumnUpdate(record)`\n  - `DATA_SOURCE_COLUMN_UPDATE_SCHEMA_NOT_IMPLEMENTED`, raised by a `LogicalWriteInfo` implementation that does not override `columnUpdateSchema()`\n\nConnectors that do not mix in `SupportsColumnUpdates` receive the same rows and schemas as before, apart from the new `RowLevelOperationInfo.updatedColumns()`, which is a new abstract method on an interface that Spark implements and passes to connectors. A delta-based UPDATE or MERGE that does not represent updates as deletes and inserts no longer carries the original row ID values for a row ID column that is assigned to itself through an alias; the written rows are unchanged.\n\nSource compatibility for Spark extensions: `RowLevelOperationInfoImpl` takes the updated columns as a new required parameter. `RowLevelWrite` has two new abstract members, `projections` (a `RowLevelWriteProjections`, which `ReplaceDataProjections` and `WriteDeltaProjections` now extend) and `withRemappedQuery`, and a final `withPrunedQuery`; it overrides `references` from the projections, where `ReplaceData` and `WriteDelta` used `query.outputSet`. The `Option` overload of `LogicalWriteInfoImpl.apply` takes a required `columnUpdateSchema`, so the compiler flags its callers. The case-class constructor, which takes `Optional`s, defaults it to `Optional.empty`, so an extension that rebuilds the info with the previous five arguments still compiles but drops the schema, as does one that also passes `isStreaming` by name; it must forward `columnUpdateSchema()`, as `FileTable.mergedWriteInfo` does. `ReplaceDataExec`, `DataAndMetadataWritingSparkTask` and `DataWithProjectionWritingSparkTask` take a new required `useWriteColumnUpdate` parameter. A node that replaces `ReplaceDataExec` must send UPDATE and COPY rows to `writeColumnUpdate` when `useWriteColumnUpdate` is set, or not replace the node. A rule that rebuilds the operation after the rewrite, such as Iceberg\u0027s `ResolveBranch`, must build one that declares the same `requiredDataAttributes()`, or `V2Writes` fails with an internal error. The plan keeps no `RowLevelOperationInfo`, so such a rule has to rebuild the info, including the updated columns, itself.\n\n### How was this patch tested?\n\nNew suites:\n- `DeltaBasedColumnUpdateTableSuite` (extends `DeltaBasedUpdateTableSuiteBase`), `GroupBasedColumnUpdateTableSuite` and `DeltaBasedNoMetadataColumnUpdateTableSuite` (extend `UpdateTableSuiteBase`), so the existing UPDATE tests also run against narrow writes, through both delta writing tasks. They share `ColumnUpdateTableSharedTests`. They cover the rows, row IDs and metadata the connector receives, every error condition above, an empty declaration, scan schemas, CHECK constraints, subquery conditions, runtime group filtering, case-sensitive analysis, tables that accept any schema, a replaced operation, and DELETE and MERGE falling back to full-width rows.\n- `RowLevelWriteColumnPruningSuite`: plan tests for the `ColumnPruning` case and the projection remapping, including that a write the rewrite did not narrow is left unchanged, and so is one that declares every data column of a table whose output includes metadata columns.\n\nUpdated:\n- `UpdateTableSuiteBase`: two tests now create their tables with the suite\u0027s properties, so they also run narrow in the new suites and delta-based in the existing delta suites.\n- `RowLevelOperationSuiteBase`: `executeAndCheckScan` checks every scan of the target table in the main plan, not the one of the runtime group filter. It and `executeAndCheckScans` now check the spelling of field names. New helpers check the column update schema, `updatedColumns()` and the write log in the narrow layout.\n- The in-memory test connectors (`InMemoryRowLevelOperationTable`, `InMemoryBaseTable`, `txns.scala`).\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Opus 5.5). I reviewed the generated code and tests.\n\n\n\n\n\nCloses #55518 from anuragmantri/dsv2-required-data-attrs.\n\nLead-authored-by: Anurag Mantripragada \u003camantripragada@apple.com\u003e\nCo-authored-by: x \u003ca@b.c\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "e55fe54b5aa6a44b56af1a24124d5b458245324c",
      "tree": "59e50cee44a7564a8fda6d42ac29244be2ee3cda",
      "parents": [
        "06cc08c0c02d52d1d2121be4a5b75db3a976524f"
      ],
      "author": {
        "name": "YangJie",
        "email": "yangjie01@baidu.com",
        "time": "Sat Nov 28 21:02:57 2026 +0800"
      },
      "committer": {
        "name": "yangjie01",
        "email": "yangjie01@baidu.com",
        "time": "Sat Nov 28 21:02:57 2026 +0800"
      },
      "message": "[SPARK-62418][CORE][SQL] Use Log4j builder setters instead of the withXxx methods deprecated in 2.26.0\n\n### What changes were proposed in this pull request?\n\nThis PR changes the 6 calls to Log4j builder methods deprecated in Log4j 2.26.0 to the setters added in the same release:\n\n- `PatternLayout.Builder.withPattern` -\u003e `setPattern`, in `DriverLogger.scala` (2 calls) and `CLIServiceUtils.java` (2 calls)\n- `FileAppender.Builder.withAppend` -\u003e `setAppend` and `withFileName` -\u003e `setFileName`, in `DriverLogger.scala`\n\n### Why are the changes needed?\n\nSpark has used Log4j 2.26 since SPARK-57604, and each of these calls produces a deprecation warning. In Log4j 2.26.1 each deprecated method and its setter assign the same builder field.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nNo test is added. `DriverLoggerSuite` covers the driver log appender. No test reads the two layouts in `CLIServiceUtils`, which the Thrift server uses for operation logs. I loaded the class and checked that both layouts have the conversion patterns written in the source.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60938 from LuciferYang/SPARK-62418.\n\nAuthored-by: YangJie \u003cyangjie01@baidu.com\u003e\nSigned-off-by: yangjie01 \u003cyangjie01@baidu.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "06cc08c0c02d52d1d2121be4a5b75db3a976524f",
      "tree": "eb7284ea2d1774b2f2a9ce78d11ab1f24438187f",
      "parents": [
        "a0dcf6856d2cffba2b2ffce596fcc7b9125cab31"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Sat Nov 28 01:29:49 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Sat Nov 28 01:29:49 2026 +0000"
      },
      "message": "[SPARK-62408][SQL] Use the cursor scan for nearest ASOF joins\n\n### What changes were proposed in this pull request?\n`SortMergeAsOfJoinExec` read the right side once with a cursor only for backward and forward joins. Now a nearest join takes the cursor scan too, when it allows exact matches and has no tolerance and no extra ON condition. Its as-of condition is then `TRUE`, so the cursor checks no condition.\n\nThe cursor keeps a copy of the first right row of the largest key below the left key. It stops at the first right row at or above the left key, and does not read it in, since the next left row may need it. That row wins on an exact match or a strictly smaller gap; otherwise the kept row wins. This is the row the buffered scan picks, with the same key order and gap compare, so two decimal keys of different scales take the cursor too. Like the buffered scan, it reads the left key of every left row, also when its ON key has no right rows, so both scans fail on the same rows.\n\nExample, one group with right keys `3, 7, 7, 12` and left keys `5, 7, 9`: 5 matches 3 (a tie with 7, the row before wins), 7 matches the first 7, and 9 matches the first 7 again (2 below, against 3 above). Each right row is read once.\n\nThere is no new config. The internal `spark.sql.join.sortMergeAsOfJoin.cursorScan.enabled` (default `true`) still turns the cursor scan off; then nearest joins take the buffered scan, as before. `AsOfJoinBenchmark` gets nearest cases with each scan.\n\n### Why are the changes needed?\nThe buffered scan reads the right group again from its start for every left row, up to the first row above the left key. So a group with N left rows and M right rows costs up to N x M key reads, and a large group spills to disk.\n\nNearest DataFrame `joinAsOf`, best of 3 runs, JDK 21, buffered scan (cursor scan off) and then cursor scan, measured before the review fix (which only removes work from the cursor):\n- 2M rows a side, 1000 groups: 14.2 s and 1.41 s.\n- 20,000 rows a side, no ON key: 1165 ms and 19 ms.\n- `AsOfJoinBenchmark`, 10,000 rows a side: 10 groups 46 ms and 15 ms, no ON key 291 ms and 10 ms.\n\n### Does this PR introduce _any_ user-facing change?\nNo. Rows, NULL handling and errors stay the same. For these joins, the SQL UI metric `number of cursor scan tasks` now counts their tasks, and their `spill size` is 0.\n\n### How was this patch tested?\n- `SortMergeAsOfJoinScannerSuite`: which nearest conditions and key types take the cursor; the cursor reads 20 right keys where the buffered scan reads 65; it keeps a copy of the first row of its best key while the right input reuses one row object; a scanner built by hand with another condition fails; the cursor reads the ON key of a waiting right row only when it moves (7 reads with 1 and with 4 left rows per ON key).\n- `SortMergeAsOfJoinSuite`: the existing plain nearest tests now run both scans and check that the cursor ran and spilled nothing. New tests: fixed rows (ties, equal right keys, NULL keys, ON keys with one side, INNER and LEFT, ANSI on and off); ANSI errors from the left and right keys, where both scans fail with the same error; random rows against a plain join that takes the smallest gap and the row before on a tie, with INT, DOUBLE (with NaN, -0.0 and 0.0) and two-scale DECIMAL keys, exact matches on and off, with and without a tolerance, and the cursor scan off and on.\n- Ran `SortMergeAsOfJoinScannerSuite`, `SortMergeAsOfJoinSuite`, `AsOfJoinSortMergeSQLSuite`, `AsOfJoinSQLSuite`, `DataFrameAsOfJoinSuite`, `StreamingAsOfJoinSuite`, `TimestampNanosJoinAnsiOnSuite`, `TimestampNanosJoinAnsiOffSuite`, `WholeStageCodegenSuite`, `SQLMetricsSuite` and `UnionCodegenSuite`, as is and with `SPARK_ANSI_SQL_MODE\u003dfalse`. With ANSI off, one `WholeStageCodegenSuite` test fails (`SPARK-60403: MergeRows compiles with its function spilled to a nested class`); it runs no ASOF join and fails the same way without this change. After the review fix, reran `SortMergeAsOfJoinScannerSuite`, `SortMergeAsOfJoinSuite`, `DataFrameAsOfJoinSuite` and `AsOfJoinSortMergeSQLSuite`, as is and with `SPARK_ANSI_SQL_MODE\u003dfalse`: all pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60935 from LukaZdravic/SPARK-62408-asof-nearest-cursor.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n"
    },
    {
      "commit": "a0dcf6856d2cffba2b2ffce596fcc7b9125cab31",
      "tree": "31d732108cb1304cf30393ca9e523f62648991c1",
      "parents": [
        "e0c980c904a54d37a2d63530163b09ab34e5fbc1"
      ],
      "author": {
        "name": "Peter Toth",
        "email": "peter.toth@gmail.com",
        "time": "Fri Nov 27 14:35:55 2026 +0100"
      },
      "committer": {
        "name": "Peter Toth",
        "email": "peter.toth@gmail.com",
        "time": "Fri Nov 27 14:35:55 2026 +0100"
      },
      "message": "[SPARK-62392][YARN] Accept file: URIs in yarn.nodemanager.local-dirs when validating executor local dirs\n\n### What changes were proposed in this pull request?\n\n`YarnShuffleService` strips a `file:` scheme from `yarn.nodemanager.local-dirs` before it passes them to the local dir validator as roots. `initRecoveryDb` does the same for this setting.\n\n### Why are the changes needed?\n\nThe YARN shuffle service validates the local dirs an executor registers against `yarn.nodemanager.local-dirs`. That setting can hold `file:` URIs, e.g. `file:///data/1/yarn/local` (SPARK-13622 fixed the recovery path for them). Such a root canonicalizes to a path relative to the working directory. No executor dir is under it, so the shuffle service rejects every executor registration.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Executors can register with the YARN shuffle service again when `yarn.nodemanager.local-dirs` uses `file:` URIs.\n\n### How was this patch tested?\n\nTwo new tests in `YarnShuffleServiceSuite`. The first fails without the fix. The second checks that a dir outside a `file:` URI root is still rejected. Also ran the YARN `*YarnShuffle*` suites.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60915 from peter-toth/SPARK-62392-yarn-local-dirs-file-uri.\n\nAuthored-by: Peter Toth \u003cpeter.toth@gmail.com\u003e\nSigned-off-by: Peter Toth \u003cpeter.toth@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "e0c980c904a54d37a2d63530163b09ab34e5fbc1",
      "tree": "02f33cd15bf5fe28e7a952960647add37bcb7cc3",
      "parents": [
        "686f6dc858546e6e5a08fa7c5ae63af40f092525"
      ],
      "author": {
        "name": "Ganesha S",
        "email": "ganeshashree2@gmail.com",
        "time": "Fri Nov 27 13:30:37 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Fri Nov 27 13:30:37 2026 +0000"
      },
      "message": "[SPARK-61646][PYTHON][SQL] Support write distribution and ordering in the Python Data Source API\n\n### What changes were proposed in this pull request?\n\nPython data source writers can now tell Spark how their input rows should be grouped and sorted. Spark then adds the needed repartition and sort before the write, the same way it already does for Scala/Java (DSv2) sinks.\n\n`DataSourceWriter` gets five optional methods: `requiredDistribution`, `requiredOrdering`, `requiredNumPartitions`, `distributionStrictlyRequired` and `advisoryPartitionSizeInBytes`. Small value classes (`ClusteredDistribution`, `OrderedDistribution`, `UnspecifiedDistribution`, `SortOrder`, `SortDirection`, `NullOrdering`) describe the requirements. They can only name plain or nested columns; transforms such as `bucket` or `days`, which Scala/Java sinks can request, are not supported.\n\n```python\nclass MyWriter(DataSourceWriter):\n    def requiredDistribution(self):\n        return ClusteredDistribution(((\"region\",),))   # one region per task\n\n    def requiredOrdering(self):\n        return [SortOrder((\"event_time\",))]           # sorted within each task\n\n    def write(self, iterator): ...\n```\n\nThe feature is behind the internal config `spark.sql.python.writeDistributionAndOrdering.enabled`, off by default. When it is on, Spark calls `DataSource.writer()` one extra time on the driver while planning each batch write, to ask for the requirements, so sinks should avoid side effects there. When it is off, a writer that overrides any of the new methods fails the write with an error that names the config, rather than having its requirements silently ignored. Filter and limit pushdown already work this way.\n\nOnly batch writes use the requirements, including batch writes inside `foreachBatch`. Streaming writes are unchanged; Spark tells them apart with a new internal streaming flag on the DSv2 write info.\n\n### Why are the changes needed?\n\nWithout this, a Python sink gets rows in whatever layout the query happened to produce. A sink that writes partitioned or sorted output ends up with many small files or requests, or has to ask every user to call `repartition()` / `sortWithinPartitions()` before writing.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, new optional `DataSourceWriter` methods and value classes in `pyspark.sql.datasource`. Existing writers behave the same, since they do not override the new methods and the feature is off by default.\n\n### How was this patch tested?\n\nNew Python tests check how rows reach each write task (clustering, ordering, null ordering, nested columns, partition count, invalid requirements, the config being off, and streaming writes with micro-batch and continuous triggers). New Scala tests cover the planned shuffle and sort and the disabled case.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60451 from ganeshashree/SPARK-61646.\n\nLead-authored-by: Ganesha S \u003cganeshashree2@gmail.com\u003e\nCo-authored-by: Ganesha S \u003cganesha.s@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "686f6dc858546e6e5a08fa7c5ae63af40f092525",
      "tree": "34a0100242472d63bd55afba4eaf1d74c1071207",
      "parents": [
        "3da24ed5846072150f29d4e584c3d3665d83e222"
      ],
      "author": {
        "name": "Mihailo Aleksic",
        "email": "mihailo.aleksic@databricks.com",
        "time": "Fri Nov 27 12:25:17 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Fri Nov 27 12:25:17 2026 +0000"
      },
      "message": "[SPARK-62361][SQL] Move by-name Union column alignment into UnionByNameTransformer\n\n### What changes were proposed in this pull request?\r\n\r\n  This PR moves the column alignment that `ResolveUnion` does for a by-name `Union` (`unionByName`) into a new `UnionByNameTransformer` object, next to `PivotTransformer` and `UnpivotTransformer`. The alignment\r\n  logic is unchanged. The new entry point, `UnionByNameTransformer.alignChildrenByName`, differs from the old private methods in three ways:\r\n\r\n  - It takes the child outputs (`leftOutput`, `rightOutput`) as parameters instead of reading `left.output` / `right.output` from the child plans.\r\n  - It takes the function that builds new columns (`newAlias: (Expression, String) \u003d\u003e Alias`) as a parameter instead of calling `Alias(...)()` directly. The function builds the null columns added for missing\r\n  columns and the columns rebuilt to add or reorder nested fields.\r\n  - It returns the aligned children together with their outputs (`AlignedUnionChildren`).\r\n\r\n  The column name duplication check moves into `alignChildrenByName` as well and still runs before the alignment. `ResolveUnion` now only folds the children of a by-name `Union` into nested by-position `Union`s.\r\n  It calls `alignChildrenByName` with `left.output`, `right.output` and `Alias(child, name)()`, so the fixed-point analyzer produces the same plans as before.\r\n\r\n  ### Why are the changes needed?\r\n\r\n  So that the single-pass analyzer can support `unionByName` by reusing this code instead of copying it. The single-pass resolver must not read `.output` from a resolved child, because that walks the child\u0027s\r\n  subtree; it keeps the child outputs in its name scopes and passes them in. It also has to create new aliases through its own alias provider, which registers each new expression ID with the resolver\u0027s\r\n  `ExpressionIdAssigner`. And it needs the aligned outputs to continue resolving the `Union` (type widening, expression ID deduplication) without reading `.output` again.\r\n\r\n  ### Does this PR introduce _any_ user-facing change?\r\n\r\n  No. This is a refactoring: the fixed-point analyzer runs the moved code with the same inputs as before.\r\n\r\n  ### How was this patch tested?\r\n  \r\n  Existing tests:\r\n  - `build/sbt \"catalyst/testOnly org.apache.spark.sql.catalyst.analysis.ResolveUnionSuite org.apache.spark.sql.catalyst.analysis.AnalysisSuite\"`: all pass.\r\n  - `build/sbt \"catalyst/scalastyle\" \"catalyst/Test/scalastyle\"`: no errors or warnings.\r\n\r\n  ### Was this patch authored or co-authored using generative AI tooling?\r\n\r\n  Generated-by: Isaac (Claude Opus 5.5)\n\nCloses #60893 from mihailoale-db/union-by-name-transformer.\n\nAuthored-by: Mihailo Aleksic \u003cmihailo.aleksic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "3da24ed5846072150f29d4e584c3d3665d83e222",
      "tree": "922461354fc285af92b2dbd3f4aee05e2ca2f31a",
      "parents": [
        "448ec3c54d98dfdff431cf21eea40bbbf85b8fb5"
      ],
      "author": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Fri Nov 27 18:29:40 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Fri Nov 27 18:29:40 2026 +0800"
      },
      "message": "[MINOR][INFRA] Add GRAPH label to the PR labeler\n\n### What changes were proposed in this pull request?\n\nAdd a `GRAPH` rule to `.github/labeler.yml` for files matching `graph/**/*`.\n\n### Why are the changes needed?\n\nPRs changing the new graph module currently do not receive an automatic graph component label.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nValidated YAML parsing, alphabetical label ordering, matching graph paths, nonmatching GraphX and unrelated paths, and preservation of existing label rules. `git diff --check` passed.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Codex (GPT-6)\n\nCloses #60933 from zhengruifeng/infra-graph-label.\n\nAuthored-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "448ec3c54d98dfdff431cf21eea40bbbf85b8fb5",
      "tree": "0290128866822dec8366a9ba0bb8e96be6a4ac48",
      "parents": [
        "9f317318b4633f7ccaf0e092c1327805afe526b3"
      ],
      "author": {
        "name": "Sem",
        "email": "ssinchenko@apache.org",
        "time": "Fri Nov 27 14:33:50 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Fri Nov 27 14:33:50 2026 +0800"
      },
      "message": "[SPARK-61794][GRAPH] indexed graph view\n\n### What changes were proposed in this pull request?\nAn implementation of the IndexedGraphView that exists over graph with `STRING` IDs.\n\n#### Differences from GraphFrames origin\nThis is the right (by my opinion) approach with a clear caller contract and explicit ownership on caller. In GF it is `private[graphframes] lazy val indexedVertices: DataFrame` that is literally owned by none. GF itself is owned by user while the indexed view is not even accessible to user, so user has no real control over it. There is no explicit contract as well. The method is called from inside algorithms over `GraphFrames` that is passed by refernce (\"just two DataFrame\" object silently and implicitly get an owned persisted attribute none is able to release properly). That was a constant source of bugs and problem with \"persist\" more like a workaround on top. See [934](https://github.com/graphframes/graphframes/pull/934), [189](https://github.com/graphframes/graphframes/pull/189), [453](https://github.com/graphframes/graphframes/issues/453) and other. Persist is wrong design there as well the `private lazy val` is wrong (imo) design as well. This PR do the same job (convert string IDs to long IDs) but with explicit ruleset, ownership and on top of provided checkpointer.\n\n### Why are the changes needed?\nPart of SPARK-61746.\n\n### Does this PR introduce _any_ user-facing change?\nNo. The new API is 100% internal. We can consider to make it \"developer API\" one day in the future to make custom graph algorithms easier, but maybe later (and maybe behind another top-level user-facing API, since I do not want to expose `GraphCheckpointer` for now).\n\n### How was this patch tested?\n- scalatest\n- checks\n\n### Was this patch authored or co-authored using generative AI tooling?\nClaude Code (Opus 5.5)\n\nCloses #60916 from SemyonSinchenko/SPARK-61794-long-id-conversion.\n\nAuthored-by: Sem \u003cssinchenko@apache.org\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "9f317318b4633f7ccaf0e092c1327805afe526b3",
      "tree": "2fa8baaeb4d1f765abc81b5895319f214b5ce272",
      "parents": [
        "ac13b69b8a1d16a43b3a0ee3559d3c0e936242aa"
      ],
      "author": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Thu Nov 26 21:43:11 2026 -0800"
      },
      "committer": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Thu Nov 26 21:43:11 2026 -0800"
      },
      "message": "[SPARK-62109][CONNECT] Keep server errors that the Spark Connect Scala client cannot render\n\n### What changes were proposed in this pull request?\n\nThe Spark Connect Scala client rebuilds most server errors in `GrpcExceptionConverter.errorFactory` by rendering their message again from the client\u0027s own bundled `error-conditions.json`. When the client cannot render the server\u0027s error, rendering throws `SparkException.internalError`, and that `INTERNAL_ERROR` replaces the server\u0027s error. The client cannot render it when its definitions lack the server\u0027s condition or subcondition, or when the condition\u0027s message template uses a parameter the server did not send (the template gained a placeholder in the client\u0027s version).\n\nThis PR keeps the server\u0027s error in those cases:\n\n- `GrpcExceptionConverter`: every entry that rebuilds the error from the client\u0027s definitions now goes through one helper, `renderOrKeepServerMessage`. If the client can render the error (`SparkThrowableHelper.isValidErrorClass`, and every parameter of the template from `SparkThrowableHelper.getMessageParameters` was sent), the exception is built exactly as before. Otherwise it is built from the message the server rendered, with the server\u0027s condition, message parameters, SQLSTATE and, where the type has one, query context. The SQLSTATE comes from the converter\u0027s existing resolution: the server\u0027s SQLSTATE when it sent one, otherwise the client\u0027s SQLSTATE for the main condition, otherwise XXKCM. This covers `ParseException`, `AnalysisException`, the catalog exceptions (`NamespaceAlreadyExistsException`, `TableAlreadyExistsException`, `TempTableAlreadyExistsException`, `NoSuchDatabaseException`, `NoSuchNamespaceException`, `NoSuchTableException`) and `SparkNumberFormatException`, `SparkIllegalArgumentException`, `SparkArithmeticException`, `SparkUnsupportedOperationException`, `SparkArrayIndexOutOfBoundsException`, `SparkDateTimeException`, `SparkRuntimeException` and `SparkUpgradeException`. `StreamingQueryException` and `SparkException` already keep the server\u0027s message.\n- Each of those exception classes gets a non-public factory, `withRenderedMessage` (`private[sql]` or `private[spark]`), that passes a message rendered elsewhere to its private primary constructor without rendering. For `ParseException`, `getMessage` then returns that message unchanged, because the server\u0027s message already contains the query context summary. `AnalysisException` uses its existing constructor that accepts a message as is. The private primary constructors of `ParseException` and the six catalog exceptions gain a SQLSTATE parameter, passed to `AnalysisException`. No public constructor is added or removed.\n\nThe decision is made per error from the client\u0027s own definitions, not by comparing client and server versions.\n\n### Why are the changes needed?\n\nThe client and server can run different Spark versions, and error conditions change between versions. SPARK-61835 renames the `_LEGACY_ERROR_TEMP_*` conditions in batches (the first is #60588), so each batch adds names that older clients lack and removes legacy names that older servers still raise. Earlier renames already do this. For example, SPARK-59040 renamed `_LEGACY_ERROR_TEMP_1166` to `BUCKET_COLUMN_IN_PARTITION_COLUMNS`, so a client built from master that talks to a Spark 4.3.0 server and runs `df.write.partitionBy(\"a\").bucketBy(2, \"a\").saveAsTable(\"t\")` fails with `INTERNAL_ERROR`: `Cannot find main error class \u0027_LEGACY_ERROR_TEMP_1166\u0027`. With a parse error from #60588 it fails with `Error class \u0027INVALID_SQL_SYNTAX\u0027 has no \u0027SET_TIME_ZONE_INVALID_VALUE\u0027 subclass.` The statement fails either way, but the error says the user hit a bug in Spark (SQLSTATE XX000), and code that catches `AnalysisException` or `ParseException`, or checks the condition or SQLSTATE, stops matching. PySpark Connect keeps the server\u0027s message and is not affected.\n\nThis was raised in the review of #60588.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, for a Spark Connect Scala client that cannot render a server error with its own error definitions. The client now throws the server\u0027s exception type with the server\u0027s condition, SQLSTATE, message parameters, query context and message, instead of `SparkException` with `INTERNAL_ERROR`. Nothing changes when the client can render the error.\n\n### How was this patch tested?\n\nNew tests in `SparkConnectClientSuite`, run against each `errorFactory` entry that rebuilds the error from the client\u0027s definitions:\n\n- The client cannot render the error, in four cases: a subcondition the client lacks, with a server SQLSTATE that differs from the one the client would derive; the same without a server SQLSTATE, which falls back to the main condition\u0027s SQLSTATE; a main condition the client lacks, which falls back to XXKCM; and a condition the client defines whose template uses a parameter the server did not send. Each yields the entry\u0027s exception type with the server\u0027s condition, SQLSTATE, parameters and query context (for types that carry one), and `getMessage` returns the server\u0027s message exactly once. Without the converter change, this test fails with `[INTERNAL_ERROR] Error class \u0027INVALID_SQL_SYNTAX\u0027 has no \u0027SUBCONDITION_NOT_DEFINED_BY_CLIENT\u0027 subclass.`\n- The client can render the error: each entry still renders the message from the client\u0027s definitions and reports the client\u0027s SQLSTATE.\n\n`SparkConnectClientSuite`, `SparkThrowableSuite`, `ErrorParserSuite` and `ParserUtilsSuite` pass, `sql` compiles, and scalastyle and scalafmt are clean.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCloses #60736 from dtenedor/connect-parse-exception-fallback.\n\nAuthored-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\nSigned-off-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "ac13b69b8a1d16a43b3a0ee3559d3c0e936242aa",
      "tree": "9c6b42239bc9526a0908564827a07eb0e0fef653",
      "parents": [
        "7825553e766f6a4a52df4242e532c11bdf0eea03"
      ],
      "author": {
        "name": "aleksandar-trajkovic-db",
        "email": "aleksandar.trajkovic@databricks.com",
        "time": "Fri Nov 27 03:50:08 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Fri Nov 27 03:50:08 2026 +0000"
      },
      "message": "[SPARK-58372][SQL] Truncate fractional to integral casts pushed down to JDBC sources\n\n### What changes were proposed in this pull request?\nTakes over #57564, which was approved but closed as stale. A fractional to integral cast pushed down to JDBC truncates like Spark. Dialects whose database rounds wrap the value in their truncating function (`JdbcDialect.truncateFractionalValue`, which receives the source type: Postgres, Oracle, Snowflake, H2, and SQL Server for `MONEY`). DB2, Derby, Teradata and Databricks, whose casts already truncate, push the plain cast, and other dialects keep the cast in Spark. Unmapped targets of these casts are spelled `SMALLINT`/`INTEGER`/`BIGINT` instead of Spark\u0027s `short`/`long`; casts from other types keep Spark\u0027s names for now (SPARK-62090). MySQL\u0027s only signed integral CAST target is 64-bit `SIGNED`, so it receives these casts only from `DECIMAL`s whose values fit the target. Casts of `TIMESTAMP` and `TIME` values to numeric types stay in Spark unless the dialect converts them like Spark (`JdbcDialect.castsDatetimeToNumericLikeSpark`, Databricks). Pushdown and tasks compile casts under the legacy conf value that the scan\u0027s JDBC options resolved.\n\n### Why are the changes needed?\nA pushed cast should return Spark\u0027s result, but Spark truncates and these databases round, so rows are silently dropped or miscounted:\n```sql\nSELECT * FROM pg.public.t WHERE CAST(d AS INT) \u003d 2   -- d \u003d 2.6\n```\nBefore: `CAST(\"d\" AS integer) \u003d 2` (Postgres rounds 2.6 to 3, so the row is dropped). Target: `CAST(TRUNC(\"d\") AS INTEGER) \u003d 2`. A pushed fractional cast to `BIGINT` was also sent as `CAST(.. AS long)`, which Postgres, SQL Server and DB2 reject.\n\n### Does this PR introduce _any_ user-facing change?\nYes. Pushed fractional to integral casts truncate like Spark instead of rounding, or are evaluated by Spark on dialects that can\u0027t truncate. `spark.sql.legacy.jdbc.roundIntegralCastPushdown.enabled` restores the SQL Spark 4.4 pushed. Casts of `TIMESTAMP` and `TIME` values to numeric types are no longer pushed down, except to Databricks. Custom dialects opt back into pushing these casts through two new `JdbcDialect` developer APIs, `truncateFractionalValue` and `castsDatetimeToNumericLikeSpark`.\n\n### How was this patch tested?\nNew tests in `JDBCSuite`, `JDBCV2Suite` and the JDBC docker integration suites.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60455 from aleksandar-trajkovic-db/jdbc-fractional-to-integral-cast.\n\nLead-authored-by: aleksandar-trajkovic-db \u003caleksandar.trajkovic@databricks.com\u003e\nCo-authored-by: Marko Sisovic \u003cmarko.sisovic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "7825553e766f6a4a52df4242e532c11bdf0eea03",
      "tree": "784d1ba97e2fbabb21f5ce80dd8df59830cba066",
      "parents": [
        "0047379a0f77fa424420210690f7d652c8967ad0"
      ],
      "author": {
        "name": "Dejan Krakovic",
        "email": "dejan.krakovic@databricks.com",
        "time": "Fri Nov 27 03:35:34 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Fri Nov 27 03:35:34 2026 +0000"
      },
      "message": "[SPARK-62112][SQL][FOLLOWUP] Fix the @since version of the FILE value APIs\n\n### What changes were proposed in this pull request?\n\nA follow-up of #60741. It changes the `since` tag of the APIs that #60741 added from 4.4.0 to 4.5.0: `FileRef`, `Encoders.FILE`, the implicit `newFileRefEncoder` in `SQLImplicits`, `FileTypeApiOps` and `FileTypeOps`.\n\n### Why are the changes needed?\n\n#60741 was merged to master and branch-4.x after branch-4.4 was cut, so these APIs first ship in 4.5.0. `FileType` and `FileTypeMode` are in branch-4.4 and keep 4.4.0.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, documentation only.\n\n### How was this patch tested?\n\nNot needed, comment changes only.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\nCloses #60919 from dejankrak-db/SPARK-62112-followup-since.\n\nAuthored-by: Dejan Krakovic \u003cdejan.krakovic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "0047379a0f77fa424420210690f7d652c8967ad0",
      "tree": "026a82cc3a0dcc21be489819209fd55063bf9b62",
      "parents": [
        "d1286ba2c169696d6b55efa12055561773d22cf9"
      ],
      "author": {
        "name": "Ivan",
        "email": "7788766+sadikovi@users.noreply.github.com",
        "time": "Fri Nov 27 10:47:37 2026 +0800"
      },
      "committer": {
        "name": "yangjie01",
        "email": "yangjie01@baidu.com",
        "time": "Fri Nov 27 10:47:37 2026 +0800"
      },
      "message": "[SPARK-61894][CORE] Fail the request when a response success callback throws in TransportResponseHandler\n\n### What changes were proposed in this pull request?\n\nWhen a response success callback throws, fail the request instead of leaving it untracked:\n\n- `TransportResponseHandler`: if `onSuccess` throws for a `ChunkFetchSuccess`, `RpcResponse` or `MergedBlockMetaSuccess`, or `onComplete` throws for a zero-byte `StreamResponse`, call `onFailure` with the same error, release the body, and rethrow so the channel is still closed. Anything `onFailure` throws, `Exception` or `Error`, is added to the rethrown error as suppressed.\n- `RetryingBlockTransferor`: if the parent\u0027s success callback throws, report a failure for that block to the parent and rethrow; an error from the failure callback is added as suppressed.\n- `ShuffleBlockFetcherIterator`: ignore a failure for a block whose result was already queued, so the block isn\u0027t failed or fetched twice, but still enqueue any requests deferred after a Netty OOM. Ignore a repeated failure for a block of the same request. Take the buffer reference right before queuing the result and release it if queuing throws.\n- Document on the callback interfaces that `onFailure` can follow an `onSuccess` or `onComplete` that threw.\n\n### Why are the changes needed?\n\n`TransportResponseHandler` stops tracking a request before calling its success callback. If the callback throws (e.g. `OutOfMemoryError`), nothing ever fails that request, so its caller waits forever. For a shuffle fetch, the task hangs on `results.take()` with no fetch failure or retry. SPARK-57709 fixed the same problem for stream callbacks.\n\nWith `spark.shuffle.io.maxRetries\u003d0` no `RetryingBlockTransferor` drops repeated failures, and `OneForOneBlockFetcher` fails every block from a failed chunk onwards, so a block can be failed more than once. A repeated failure re-fetched a Netty-OOM-deferred block, and for a push-merged shuffle chunk it fell back twice and failed the task with `NoSuchElementException`.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nNew tests:\n- `TransportResponseHandlerSuite`: for chunk fetch, RPC and merged block meta responses, a throwing success callback gets `onFailure` with the same error, the body is released, the error is rethrown and no request stays outstanding. When `onFailure` also throws an `Exception`, an `Error` or the same error, the original error is rethrown with the other one suppressed. A throwing `onComplete` for an empty stream gets `onFailure` and is rethrown.\n- `RetryingBlockTransferorSuite`: a throwing parent success callback reaches the parent as exactly one failure for that block; an error from the failure callback is suppressed on the rethrown one, and a failure callback that rethrows the same error does not hit self-suppression.\n- `ShuffleBlockFetcherIteratorSuite`: a failure for an already delivered block is ignored (including a Netty OOM, which must not re-fetch the block); a success callback that throws before queuing the result fails the fetch without leaking the buffer reference; repeated failures from failing every remaining chunk neither re-fetch a Netty-OOM-deferred block nor fall back twice for a push-merged chunk.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nYes. Generated-by: Claude Opus 5.5\n\nCloses #60639 from sadikovi/SPARK-61894.\n\nLead-authored-by: Ivan \u003c7788766+sadikovi@users.noreply.github.com\u003e\nCo-authored-by: ivan.sadikov \u003civan.sadikov@databricks.com\u003e\nSigned-off-by: yangjie01 \u003cyangjie01@baidu.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d1286ba2c169696d6b55efa12055561773d22cf9",
      "tree": "510977e484e27fde914c6bda9d458053b7cd8d88",
      "parents": [
        "8afe148ec721c567ada43f5031f0179ffe901668"
      ],
      "author": {
        "name": "Mihailo Aleksic",
        "email": "mihailo.aleksic@databricks.com",
        "time": "Thu Nov 26 13:50:30 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Thu Nov 26 13:50:30 2026 +0000"
      },
      "message": "[SPARK-62358][SQL] Make lambda variable names in by-name Union resolution deterministic\n\n### What changes were proposed in this pull request?\r\n  \r\n  When a by-name `Union` (`unionByName`) reorders or fills struct fields inside an array, `ResolveUnion` rewrites the array column with `transform(arr, lambdafunction(...))`. The lambda variable was named with `UnresolvedNamedLambdaVariable.freshVarName(\"x\")`,\r\n  which reads a counter shared by the whole JVM. The same query therefore got a different variable name (`x_0`, `x_1`, ...) depending on how many lambdas the JVM had named before.\r\n\r\n  This PR names the variable after its nesting depth in the generated expression instead: `x_0` for the outermost array, `x_1` for an array of structs nested inside it, and so on. The name is only for display. The lambda binds by expression ID, so results, the\r\n  output schema and column names do not change. Only the plan string changes.\r\n\r\n  ### Why are the changes needed?\r\n  \r\n  The analyzed plan of a `unionByName` query should not depend on what ran before it in the same JVM. With the counter, resolving the same plan twice gives two different plans (`x_0`/`x_1` the first time, `x_2`/`x_3` the second time), and any golden file that\r\n  records such a plan depends on the tests that run before it.\r\n\r\n  It is also needed before the single-pass analyzer can support `unionByName` by reusing this code. In dual-run mode both analyzers resolve the query, and the plan comparison normalizes the lambda variable\u0027s expression ID but not its name. With the counter, a\r\n  prototype that reuses this code got `x_0` from the fixed-point analyzer and `x_1` from the single-pass analyzer for the same query, which raised `HYBRID_ANALYZER_EXCEPTION.LOGICAL_PLAN_COMPARISON_MISMATCH`:\r\n\r\n  ```\r\n  Fixed-point analyzer output:\r\n  +- Project [id#x, transform(arr#x, lambdafunction(if (isnull(lambda x_0#x)) null else named_struct(a, lambda x_0#x.a, b, lambda x_0#x.b), lambda x_0#x, false)) AS arr#x]\r\n  Single-pass analyzer output:\r\n  +- Project [id#x, transform(arr#x, lambdafunction(if (isnull(lambda x_1#x)) null else named_struct(a, lambda x_1#x.a, b, lambda x_1#x.b), lambda x_1#x, false)) AS arr#x]\r\n  ```\r\n\r\n  ### Does this PR introduce _any_ user-facing change?\r\n  \r\n  No. Only the lambda variable name in the plan string changes. Query results, the output schema and column names are the same.\r\n\r\n  ### How was this patch tested?\r\n\r\n  New tests:\r\n  - `ResolveUnionSuite`, \"Lambda variables for nested arrays of structs are named by nesting depth\". It resolves a by-name union of `array\u003cstruct\u003cs: array\u003cstruct\u003ca, b\u003e\u003e\u003e\u003e` against `array\u003cstruct\u003cs: array\u003cstruct\u003cb, a\u003e\u003e\u003e\u003e` twice, checks that the two plans are equal,\r\n  and checks that the lambda variables are named `x_0` and `x_1`.\r\n  - Two Spark Connect golden files, generated by `PlanGenerationTestSuite` and checked by `ProtoToParsedPlanTestSuite`:\r\n    - `unionByName_nested_arrays_of_structs`: the innermost struct fields are in a different order on the right side, so `arr` is rewritten with two nested `transform` calls, `x_0` and `x_1`.\r\n    - `unionByName_nested_arrays_of_structs_allowMissingColumns`: each side misses a struct field of the other, so `arr` is rewritten on both sides. Both lambdas are named `x_0`.\r\n\r\n  Without the fix, the new `ResolveUnionSuite` test fails because the second resolution names the variables differently. The `allowMissingColumns` golden file also fails, because the counter names the variables `x_3` and `x_2` instead of `x_0`.\r\n\r\n  With the fix:\r\n  - `build/sbt \"catalyst/testOnly org.apache.spark.sql.catalyst.analysis.ResolveUnionSuite\"`: 2 passed.\r\n  - `build/sbt \"connect-client-jvm/testOnly org.apache.spark.sql.PlanGenerationTestSuite\"`: 760 passed, 2 ignored.\r\n  - `build/sbt \"connect/testOnly org.apache.spark.sql.connect.ProtoToParsedPlanTestSuite\"`: 765 passed.\r\n\r\n  ### Was this patch authored or co-authored using generative AI tooling?\r\n\r\n  Generated-by: Isaac (Claude Opus 5.5)\n\nCloses #60891 from mihailoale-db/union-by-name-deterministic-lambda-name.\n\nAuthored-by: Mihailo Aleksic \u003cmihailo.aleksic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n"
    },
    {
      "commit": "8afe148ec721c567ada43f5031f0179ffe901668",
      "tree": "87128978dc1abd3fbdbcc2c8768b6082f273ba6b",
      "parents": [
        "55f25b44336ff56c930f9d278cb5791c99baa0d6"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 22:03:23 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 22:03:23 2026 +0900"
      },
      "message": "[SPARK-61513][SS] Fix the V4 stream-stream join range scan window that skips matching rows\n\n### What changes were proposed in this pull request?\n\nIn state format version 4, a stream-stream join row reads only the other side\u0027s rows in a time window, which comes from offsets the watermark solver derives from the join condition at a watermark of 0. This PR makes that window cover every row the condition can match. `StreamingJoinHelper.getRangeScanOffsets` builds it only from comparisons whose bound is an exact offset from the probing row\u0027s event time:\n\n- The bound must move with the watermark (it is solved at two watermarks), so a comparison of one event time with a constant, or a sum of the two event times, gives no offset.\n- Each event time in it must be uncast, shifted by intervals, or cast from TIMESTAMP to TIMESTAMP (`StreamingJoinHelper.castsEventTime`). A cast of an event time to any other type, such as `CAST(ts AS BIGINT)` (the epoch-seconds idiom from before Spark 3.0) or DOUBLE, gives no bound; state eviction keeps supporting such conditions, but the range scan does not optimize them.\n- It must not add months, an interval whose value is not known, or whole days in a session time zone whose offset changes (`StreamingJoinHelper.hasCalendarInterval`). Whole days are exact in a fixed-offset zone such as UTC.\n\nEach direction takes the loosest kept bound; a direction without one reads every row for the key, as in versions 1 to 3. The window is widened by 1 ms at each end, because the solver truncates its offsets toward zero to whole milliseconds.\n\nThe join still checks the full condition on every row it reads. State eviction does not change.\n\n### Why are the changes needed?\n\nIn each case below, V4 misses a match that V1 to V3 emit, in both arrival orders:\n\n- **Casts.** The solver reads `CAST(ts AS BIGINT)` as `ts`, but the cast drops the fraction of a second. With `CAST(rightTime AS BIGINT) \u003e\u003d CAST(leftTime AS BIGINT) + 60`, a left row at 100.6 seconds matches a right row at 160.2 seconds (160 \u003e\u003d 100 + 60), but the left row\u0027s window starts near 160.6 seconds.\n- **Days.** The solver counts a day as 24 hours, but Spark adds days and months in the session time zone. With `rightTime BETWEEN leftTime AND leftTime + INTERVAL 1 DAY` in America/Los_Angeles, a right row 24.5 hours after a left row on 2026-10-31 matches, because that day has 25 hours, but the left row\u0027s window ends after 24 hours.\n- **Sub-millisecond offsets.** The solver returns whole milliseconds, truncated toward zero. With `rightTime \u003e leftTime - INTERVAL 500 MICROSECONDS`, the lower offset of -0.5 ms becomes 0, and the left row\u0027s window misses a right row 0.3 ms earlier.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. V4 queries with such conditions now emit the matches they missed before.\n- With a truncating cast or a calendar interval, they read every state row for the key, as V1 to V3 do.\n- Other range scans read up to 1 ms more on each side.\n\n### How was this patch tested?\n\n- New tests in every state format version, each in both arrival orders:\n  - \"stream stream inner join through truncating casts of event times\";\n  - \"stream stream inner join on a range of whole days across a daylight saving change\";\n  - \"stream stream inner join on a sub-millisecond interval bound\".\n- Unit tests for both helpers.\n- Without the change, every V4 variant of these tests failed (no output), and the V3 variants passed.\n- \"left semi join stores every evicted right row under a bound with a truncating cast\", which\n  SPARK-61380 (#60307) skipped in state format V4 because of this bug, now runs in V4 too. Without\n  this change it fails there.\n\nbuild/sbt \u0027catalyst/testOnly *StreamingJoinHelperSuite\u0027  # 4 passed\nbuild/sbt \u0027sql/testOnly *StreamingInnerJoinV4Suite *StreamingInnerJoinWithVCFSuite *StreamingInnerJoinWithoutVCFSuite -- -z \"truncating casts\" -z \"daylight saving\" -z \"sub-millisecond interval bound\"\u0027  # 30 passed\nbuild/sbt \u0027sql/testOnly *StreamingInnerJoinV4Suite *StreamingOuterJoinV4Suite *StreamingFullOuterJoinV4Suite *StreamingLeftSemiJoinV4Suite\u0027  # 197 passed\n\nScalastyle for catalyst and sql, main and test sources: 0 errors.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Anthropic Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\n\n\n\nCloses #60378 from HeartSaVioR/jungtaek-lim_data/v4-range-scan-window.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "55f25b44336ff56c930f9d278cb5791c99baa0d6",
      "tree": "96fea1ddc3650260dcfbc6286f6732e1b6ef77fe",
      "parents": [
        "cb0ec0404242f031bbebf8bced146963c0bb316f"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 22:00:42 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 22:00:42 2026 +0900"
      },
      "message": "[SPARK-61986][SPARK-62046][SS] Keep rows with a NULL watermarked join key out of stream-stream join state\n\n### What changes were proposed in this pull request?\n\nA stream-stream join row whose watermarked equality key is NULL can never match, because SQL\n`\u003d` never matches NULL. This PR handles such a row like one that fails the pre-join filter: an\nouter join outputs it at once, padded with NULLs, and every join drops it before it reaches the\nstate. Each side checks the watermarked key of the generated key row right after the pre-join\nfilter, for every state format.\n\nThis fixes two problems:\n- SPARK-61986: state format V4 fails with `NullPointerException` for a NULL window key.\n- SPARK-62046: a NULL-key row stays in state for good, and an outer join never outputs it.\n\nIt also removes the `TODO(SPARK-61986)` that SPARK-62022 (#60701) left in\n`SymmetricHashJoinStateManagerV4`, as such a row no longer reaches the V4 state lookups.\n\n### Why are the changes needed?\n\n**1. V4 fails the query (SPARK-61986).** With `spark.sql.streaming.join.stateFormatVersion\u003d4`:\n\n```scala\nval left \u003d leftInput.toDF().toDF(\"lk\", \"t\")\n  .select($\"lk\", timestamp_seconds($\"t\").as(\"lt\"))\n  .withWatermark(\"lt\", \"10 seconds\")\n  .select($\"lk\", window($\"lt\", \"10 seconds\").as(\"lw\"))\nval rightTime \u003d when($\"s\" \u003e\u003d 0, timestamp_seconds($\"s\"))\nval right \u003d rightInput.toDF().toDF(\"rk\", \"s\")   // no watermark; rw is NULL for a negative s\n  .select($\"rk\", when($\"s\" \u003e\u003d 0, struct(rightTime.as(\"start\"),\n    (rightTime + expr(\"INTERVAL 10 SECONDS\")).as(\"end\"))).as(\"rw\"))\nleft.join(right, expr(\"lk \u003d rk AND lw \u003d rw\"), \"full_outer\")\n  .select($\"lk\", $\"lw.end\".cast(\"long\"), $\"rk\", $\"rw.end\".cast(\"long\"))\n// one batch: left (1, 5); right (1, -1) and (1, 0)\n```\n\n- Before: the query fails with `NullPointerException` when V4 reads the event time of the NULL\n  window key of the right row `(1, -1)` (`SymmetricHashJoinStateManagerV4.getJoinedRows`).\n- After: `(1, 10, 1, 10)` and `(null, null, 1, null)` in that batch.\n\n**2. The row is never output (SPARK-62046).** On every state format, a row with a NULL\nwatermarked key passes the late-row filter, but eviction never removes it: V2 and V3 never\nevict it, because their eviction predicate is NULL for it, and V4 evicts it only in the first\nmicro-batch. For example:\n\n```scala\nval windowed \u003d leftInput.toDF().toDF(\"lk\", \"t\")\n  .select($\"lk\", timestamp_seconds($\"t\").as(\"lt\"))\n  .withWatermark(\"lt\", \"10 seconds\")\n  .select($\"lk\", window($\"lt\", \"10 seconds\").as(\"lw\"))\nval nulls \u003d nullInput.toDF().toDF(\"lk\")\n  .select($\"lk\", lit(null).cast(windowed.schema(\"lw\").dataType).as(\"lw\"))\nval right \u003d rightInput.toDF().toDF(\"rk\", \"s\")\n  .select($\"rk\", window(timestamp_seconds($\"s\"), \"10 seconds\").as(\"rw\"))\nwindowed.union(nulls)\n  .join(right, expr(\"lk \u003d rk AND lw \u003d rw\"), \"left_outer\")\n  .select($\"lk\", $\"lw.end\".cast(\"long\"), $\"rk\")\n// batch 0: leftInput (1, 5); batch 1: nullInput 7;\n// batch 2: leftInput (2, 100), so the watermark moves to 90 seconds; batch 3: no data\n```\n\n- Before: on V2 and V3, `(1, 10, null)` only. The row `(7, null, null)` is never output and\n  stays in state. V4 fails as in 1; with a timestamp key instead of the window, V4 also never\n  outputs the row.\n- After: `(7, null, null)` in batch 1, then `(1, 10, null)`. No state is kept for the NULL row.\n\nAlso, in a full outer join a NULL watermarked key on each input no longer joins as\n`(7, null, 7, null)`; each row comes out padded with NULLs.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Stream-stream joins output rows whose watermarked equality key is NULL in the micro-batch\nthey arrive in (outer joins, padded with NULLs) and keep no state for them. State format V4 no\nlonger fails for a NULL window key. No state layout change. Such rows already in a checkpoint\u0027s\nstate stay there, as before.\n\n### How was this patch tested?\n\nNew tests in `StreamingJoinSuite`, on state formats V2, V3 and V4:\n- `StreamingFullOuterJoinBase`: a full outer join with a NULL window key and a NULL timestamp key\n  on the input without a watermark, as in example 1.\n- `StreamingOuterJoinBase`: inner, left outer and full outer joins, window and timestamp keys,\n  with the NULL keys in the first or a later micro-batch, with constraint propagation off so that\n  no inferred `IS NOT NULL` filter removes them first. They check the output of each batch, and\n  that no NULL-key row stays in state.\n\nWithout the fix, all of them fail: V4 with the `NullPointerException` for window keys, the others\nwith missing or extra rows, or NULL-key rows left in state.\n\nOut of scope: NULLs in equality keys that carry no watermark (SPARK-61382), and NULL value-side\nevent times in V4 (SPARK-62022, #60701).\n\n### Note for reviewers, including AI review\n\nPlease review only this PR\u0027s own commit(s). For each finding, give a runnable reproducer and\nsay whether master has the same behavior.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\n\nCloses #60704 from HeartSaVioR/jungtaek-lim_data/f-61986-62046-null-watermarked-key.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "cb0ec0404242f031bbebf8bced146963c0bb316f",
      "tree": "551c5c760bae79d3a1073437e1d5cd214a8d2b7b",
      "parents": [
        "75a659041224742ac897e8000d0daba6caa31a6a"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Thu Nov 26 11:53:30 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Thu Nov 26 11:53:30 2026 +0000"
      },
      "message": "[SPARK-62092][SQL] Keep a GlobalLimit over a global Sort when LimitPushDown pushes a LocalLimit into it\n\n### What changes were proposed in this pull request?\n`LimitPushDown` pushes a smaller `LocalLimit` into UNION ALL, outer joins and Python UDF inputs. If the child was a `GlobalLimit`, the rule removed it.\n\nNow the rule keeps a `GlobalLimit` whose child is a global `Sort` (also through `Project`, `Filter`, `Offset` and other order-keeping nodes), and puts the new `LocalLimit` on top of it. Other `GlobalLimit`s are removed as before.\n\nThe right side of a LEFT SEMI/ANTI join with no condition still drops its `GlobalLimit`, because only whether that side is empty matters there.\n\n### Why are the changes needed?\nIt is a wrong-result bug. `ORDER BY a LIMIT 5` keeps the top 5 rows, but a `LocalLimit` keeps the first rows of each partition. So the outer limit could return rows outside the top 5.\n\n```sql\nSELECT l.a FROM (SELECT a FROM sorted_t ORDER BY a LIMIT 5) l\nLEFT JOIN join_r r ON l.a \u003d r.b LIMIT 3\n-- before: 248, 997, 998   after: three values from 0 to 4\n```\n\n### Does this PR introduce _any_ user-facing change?\nYes, a bug fix. The query above now returns rows from the top 5. Plans of this shape sort all rows for the top 5 again, where the old plan read a few rows per partition.\n\n### How was this patch tested?\n- `LimitPushdownSuite`: the `GlobalLimit` stays for UNION ALL, outer joins, Python UDF input, and over `Project`/`Filter`; it is still removed over a local sort (`SORT BY`) and the semi/anti right side. These fail without the fix.\n- `SQLQuerySuite`: the query above, with LEFT and RIGHT JOIN, returns only values below 5. It returns `248, 997, 998` without the fix.\n- Also ran `SQLQueryTestSuite`, the TPC-DS/TPC-H plan stability suites, `PlannerSuite`, `AdaptiveQueryExecSuite`, `DataSourceV2Suite`, `ExtractPythonUDFsSuite` and other limit suites. No plan changed.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60727 from LukaZdravic/limit-pushdown-keep-ordered-limit.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "75a659041224742ac897e8000d0daba6caa31a6a",
      "tree": "522a6ed6775f310a9ba7970333e2678ed981b7c2",
      "parents": [
        "762277f8c784429a75e434615656a9ca03d15520"
      ],
      "author": {
        "name": "Xiduo You",
        "email": "ulyssesyou18@gmail.com",
        "time": "Thu Nov 26 19:43:41 2026 +0800"
      },
      "committer": {
        "name": "Xiduo You",
        "email": "ulyssesyou@apache.org",
        "time": "Thu Nov 26 19:43:41 2026 +0800"
      },
      "message": "[SPARK-62263][SQL] Keep the constant spelling of a foldable alias in projected partitioning and ordering\n\n### What changes were proposed in this pull request?\n\n`AliasAwareOutputExpression` projects an inherited partitioning or ordering through a node\u0027s output aliases. A foldable alias such as `1 AS one` maps `Literal(1)` to the alias attribute, so `a + 1` was projected to `a + one` and the literal spelling was dropped. A requirement on `a + 1` then no longer matched and the planner added a redundant exchange or sort. Symmetrically, an alias-spelled requirement (`a + one`) lost its match where `FoldablePropagation` cannot rewrite it to the constant.\n\nThe projection now advertises both spellings. `projectExpressions` builds two disjoint streams: the alias-projected spellings, and the constant spellings of inputs that keep a matched foldable leaf. `projectExpression` emits the alias spellings first and the constant spellings after, so each input contributes at most one extra candidate instead of forking every literal occurrence. The constant pass is skipped entirely when no alias child is foldable.\n\nAlias spellings are emitted before constant spellings across `PartitioningCollection` members, keyed and non-keyed, and across `SortOrder.children`, so later members and `sameOrderExpressions` are not crowded out under `spark.sql.optimizer.expressionProjectionCandidateLimit`. In `projectKeyedPartitionings` a position with a matched foldable leaf emits its constant spelling before non-foldable alternatives, which keeps each member\u0027s own and cross-member constant spellings; the constant cross-product keeps only combinations that retain a foldable leaf, so the two passes stay disjoint.\n\nBoth spellings are needed because `FoldablePropagation` rewrites an alias-spelled requirement to the constant only through some operators: not across `CollectMetrics`, a cached or checkpointed relation, a union, or a stream-stream join; nothing rewrites a constant-spelled requirement to the alias.\n\nExample (Int key, AQE and broadcast joins off):\n\n```scala\nval base \u003d spark.range(10).selectExpr(\"cast(id as int) as a\")\nval left \u003d base.repartition($\"a\" + 1).selectExpr(\"a\", \"1 as one\")\nval right \u003d base.selectExpr(\"a as k\")\nleft.join(right, left(\"a\") + 1 \u003d\u003d\u003d right(\"k\"))\n```\n\nOn the base branch the left side is shuffled twice with `hashpartitioning(a + 1)` (3 shuffles); with this change the join reuses the user\u0027s `repartition(a + 1)` (2 shuffles). Results are unchanged.\n\n### Why are the changes needed?\n\nA projection that defines a constant alias weakens the partitioning and ordering it inherits, which adds a shuffle or sort to a common `repartition` + join shape; symmetrically, an alias-spelled requirement loses its match where `FoldablePropagation` cannot rewrite it to the constant.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Query results are unchanged; only the optimized plan changes (fewer exchanges and sorts).\n\n### How was this patch tested?\n\nAdded 10 tests to `ProjectedOrderingAndPartitioningSuite` (46 tests):\n\n- both partitioning spellings advertised, and both ordering spellings (alias primary, constant as a same-order expression);\n- a constant-spelled join reusing the projection\u0027s partitioning, and an alias-spelled key right above the projection (2 shuffles each);\n- an alias-spelled key across `CollectMetrics` (2 shuffles) and over a `localCheckpoint` (no exchange on the checkpoint side);\n- both spellings surviving an attribute rename;\n- multi-key `KeyedPartitioning` collections (partial positions, cross-member foldable positions, outer-expression aliases, non-leaf foldables) and a seven-key join not crowded out by the extra candidates;\n- a multi-member `PartitioningCollection` (keyed and non-keyed) and `SortOrder.sameOrderExpressions` not crowded out at the candidate limit.\n\nAdded an end-to-end 5-key SPJ test to `KeyGroupedPartitioningSuite` (250 tests): `1 as one` plus `observe` and a `Window`, over both scan keys and alias-spelled join keys, with one shuffle and AQE off and on.\n\nAlso ran `EnsureRequirementsSuite` (91 tests), `RemoveRedundantSortsSuite` and `PlannerSuite` (86 tests); all passing.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: deepseek-flash\nAssisted-by: Claude Code\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCloses #60804 from ulysses-you/foldable-alias-partitioning.\n\nAuthored-by: Xiduo You \u003culyssesyou18@gmail.com\u003e\nSigned-off-by: Xiduo You \u003culyssesyou@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "762277f8c784429a75e434615656a9ca03d15520",
      "tree": "f5830c8f9c6268aa51ec61def121c3971a040d55",
      "parents": [
        "483621a2dde77e74163373ed3faf2d7427c5d12b"
      ],
      "author": {
        "name": "yyanyy",
        "email": "yyanyyyy@gmail.com",
        "time": "Thu Nov 26 11:41:56 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Thu Nov 26 11:41:56 2026 +0000"
      },
      "message": "[SPARK-61530][SQL] Respect NaN ordering in approximate percentile summaries\n\n### What changes were proposed in this pull request?\n\nUse `SQLOrderingUtil.compareDoubles` when inserting, merging and compressing quantile summaries so NaN values follow Spark SQL ordering. Add summary-level regressions and a SQL regression with explicit input partitions for both `percentile_approx` and `approx_percentile`.\n\n### Why are the changes needed?\n\nFixes [SPARK-61530](https://issues.apache.org/jira/browse/SPARK-61530).\n\nOrdinary floating-point comparisons are false for NaN. They can misorder merged samples and drop a sample during compression while keeping its count, corrupting quantile ranks and endpoints.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Approximate percentiles containing NaN now respect Spark SQL\u0027s NaN-last ordering across partition layouts. For inputs `[1,2,3,4]` and `[NaN]` in separate partitions, percentiles `[0,0.5,1]` previously returned `[1,3,4]`; they now return `[1,3,NaN]`.\n\n### How was this patch tested?\n\nThe new summary and SQL regressions both failed on the original code before the production change. Validation uses a fresh SBT build with JDK 21:\n\n- Full `QuantileSummariesSuite` and `ApproximatePercentileSuite`.\n- Percentile tests in `DataFrameAggregateSuite`, including both aliases, both partition orders and one partition.\n- `approxQuantile` tests in `DataFrameStatSuite`.\n- Catalyst production/test and SQL test Scala style checks.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex (GPT-6)\n\nCloses #60428 from yyanyy/spark-approx-percentile-nan-20261112.\n\nAuthored-by: yyanyy \u003cyyanyyyy@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "483621a2dde77e74163373ed3faf2d7427c5d12b",
      "tree": "f6ef62494e703a98f18b9b0d7682a8080d62f57e",
      "parents": [
        "c4ac8eb580be31a0d4c7205fd3d9bd34debf66f2"
      ],
      "author": {
        "name": "Ganesha S",
        "email": "ganeshashree2@gmail.com",
        "time": "Thu Nov 26 11:36:16 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Thu Nov 26 11:36:16 2026 +0000"
      },
      "message": "[SPARK-60805][SQL] Resolve system- and catalog-qualified calls in CREATE FUNCTION bodies\n\n### What changes were proposed in this pull request?\n\n`CREATE FUNCTION` checks a SQL function body for cycles and for temporary function references. Both checks treated every called name as a persistent function in `spark_catalog`, so `builtin.f` and `session.f` were read as schema names, and three-part names were rejected.\n\nThis PR makes both checks resolve names the way function resolution does:\n\n- `builtin.f` / `session.f` use a persistent schema of that name if it has `f`, else the system namespace. With `spark.sql.legacy.persistentCatalogFirst\u003dfalse`, the system namespace comes first.\n- `system.builtin.f` / `system.session.f` always use the system namespace.\n- `spark_catalog.db.f` is looked up directly. Other catalogs are left to analysis.\n\nThe temporary function check also now covers table function calls and `IDENTIFIER(...)` calls. A call counts only when it really resolves to a temporary function, so for example `range(3)` still works when a temporary function named `range` exists.\n\n### Why are the changes needed?\n\nThe same call works in a query but fails in a function body:\n\n```sql\nSELECT builtin.abs(-1);                                            -- 1\nCREATE FUNCTION f1() RETURNS INT RETURN builtin.abs(-1);           -- SCHEMA_NOT_FOUND\nCREATE FUNCTION f2() RETURNS INT RETURN system.builtin.abs(-1);    -- IDENTIFIER_TOO_MANY_NAME_PARTS\nCREATE FUNCTION g() RETURNS INT RETURN 5;\nCREATE FUNCTION f3() RETURNS INT RETURN spark_catalog.default.g(); -- IDENTIFIER_TOO_MANY_NAME_PARTS\n\nCREATE TEMPORARY FUNCTION temp_fn() RETURNS INT RETURN 1;\nCREATE FUNCTION f4() RETURNS INT RETURN session.temp_fn();         -- SCHEMA_NOT_FOUND (wrong error)\n```\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, it fixes a bug:\n\n- `f1`, `f2` and `f3` are created and work like the query.\n- `f4` fails with `INVALID_TEMP_OBJ_REFERENCE`, as a persistent function cannot use a temporary function.\n- Cycles through qualified names are still detected.\n- A call that resolves to a built-in or persistent function is no longer rejected just because a temporary function shares its name, for example `lower(\u0027A\u0027)` next to a temporary `lower`, or `abs(-1)` next to a temporary table function `abs`.\n- A persistent function now fails with `INVALID_TEMP_OBJ_REFERENCE` when its body or a parameter default uses a temporary function, including through another SQL function it calls. Master missed some of these, for example a temporary table function, a call through `IDENTIFIER(...)`, a temporary generator in `LATERAL VIEW`, or a `session.` call in a CTE. Such functions behaved differently, or failed, in other sessions. Set `spark.sql.legacy.allowTempFunctionInPersistedSQLFunction\u003dtrue` to restore the old behavior; the migration guide notes this.\n\n### How was this patch tested?\n\nNew tests in `SQLFunctionSuite`. `SQLFunctionSuite`, `FunctionQualificationSuite`, the SQL/JSON function suites, and the `sql-udf.sql` and `identifier-clause.sql` golden files pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60214 from ganeshashree/SPARK-60805.\n\nLead-authored-by: Ganesha S \u003cganeshashree2@gmail.com\u003e\nCo-authored-by: Ganesha S \u003cganesha.s@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "c4ac8eb580be31a0d4c7205fd3d9bd34debf66f2",
      "tree": "02a5370ee01f3a1f2f77b8d12d1f8bd4a639b0d4",
      "parents": [
        "ae10aa6c1033e42080374a0c7d11df85eaa196f8"
      ],
      "author": {
        "name": "Dejan Krakovic",
        "email": "dejan.krakovic@databricks.com",
        "time": "Thu Nov 26 10:35:25 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Thu Nov 26 10:35:25 2026 +0000"
      },
      "message": "[SPARK-62112][SQL] Add the physical representation and the FileRef value of the FILE type\n\n### What changes were proposed in this pull request?\n\nSlice 1 of the SPARK-59132 implementation plan: the physical representation and the value of FILE.\n\n**FileType in the Types Framework.** `FileTypeOps` (catalyst) and `FileTypeApiOps` (sql/api) register FileType. Its physical type is `PhysicalStructType(FileType.FIELDS)` (uri, offset, size, content_type, checksum, inline), so with the generic row access of SPARK-56076 its row representation is `FileType.asStruct`, and the row readers and writers, the projections and code generation handle it without per-type changes. The default literal is a reference with an empty uri.\n\n**FileRef.** The user-facing Java value class of FILE, in `org.apache.spark.sql.types`, with the nullable getters `uri`, `offset`, `size`, `contentType` and `checksum` from the SPIP, and `equals`, `hashCode` and `toString`. The SPIP keeps `inline` internal: a FileRef carries it, so that a value converts to a FileRef and back without loss, but its constructor and getter for it are package-private, reached through `private[sql] FileRefInternals`. The I/O methods (`open`, `asLocalFile`, `fromBytes`, `fromLocalFile`) come with slice 5.\n\n**Encoders.** `AgnosticEncoders.FileRefEncoder`, `Encoders.FILE` and an implicit encoder in `SQLImplicits`; `ScalaReflection` and `JavaTypeInference` map `FileRef` to FILE, so case classes and beans can hold one; `Row.getFile`. As for TIME, building the serializer or deserializer requires `spark.sql.fileType.enabled`.\n\n**Modes.** A FILE casts and up-casts to a FILE of unknown mode, as the value does not change. The FileRef encoder needs this to read a FILE EXTERNAL column, for example `df.as[FileRef]`. A write stores a FILE of any mode in a FILE EXTERNAL column, since the file is external to the table that stores it: `DataTypeUtils.canWrite` accepts it under every store assignment policy, and the cast that table insertion adds (tagged `BY_TABLE_INSERTION`) may turn a FILE into a FILE EXTERNAL. So a Dataset of FileRef can be appended or inserted into a table with a FILE EXTERNAL column. An explicit cast to FILE EXTERNAL is not allowed, and a table created from a FILE of unknown mode still fails, as a table column must declare EXTERNAL.\n\n**Cast to STRING.** The SPIP defines a cast of a FILE to STRING as reading its bytes (slice 4a), so `CAST(f AS STRING)`, also of a value with a nested FILE, now fails at analysis instead of rendering the struct.\n\n**Display.** `df.show()` and other uses of `ToPrettyString` render a FILE as its canonical JSON, `{\"uri\":...,\"offset\":...,\"size\":...,\"content_type\":...,\"checksum\":...,\"inline\":...}` without the null fields, in both the interpreted and the code generation paths. `ToStringBase` formats a struct-backed framework type with its catalyst-side ops, whose internal value is an InternalRow.\n\n**Column vectors and the columnar cache.** SPARK-56076 left column vectors to the first type that needs them. `WritableColumnVector` and `ConstantColumnVector` build one child vector per field for a framework type whose row representation is a struct, and `ColumnVectorUtils.populate`, `RowToColumnConverter`, and the cache (`ColumnType`, `ColumnBuilder`, `ColumnAccessor`, `InMemoryRelation`) handle it as that representation. They look it up through a new Java-friendly `TypeOps.rowRepresentationOrSelf`. Array- and map-backed framework types are not handled in column vectors yet.\n\n### Why are the changes needed?\n\nFILE (SPARK-59132) has DDL, a JSON schema and restrictions, but no values. This adds its values, which the next slices build on: field access and casts (2), Parquet storage (3), byte access (4a) and the FileRef I/O API (5).\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, behind `spark.sql.fileType.enabled`, which stays off by default:\n- A FILE value can be created, collected and shown, as a `FileRef` in Datasets, DataFrames, `Row.getFile`, case classes and beans.\n- `CAST(f AS STRING)` of a FILE fails at analysis, where it rendered the struct before. A FILE casts to a FILE of unknown mode, and a FILE of any mode can be written to a FILE EXTERNAL column.\n\nA Dataset of FileRef in the Spark Connect clients, Python, `to_json`, Parquet storage and field access are not supported yet.\n\n### How was this patch tested?\n\n- New `FileTypeOpsSuite` (catalyst): the physical type and row representation, the default literal, conversions between FileRef and InternalRow (all fields, inline, no uri, nulls), `CatalystTypeConverters`, `SpecializedGettersReader`, interpreted and generated unsafe projections of a FILE column, null values and fields, arrays, map values and structs of FILE, the safe projection on a reused UnsafeRow, formatting and JSON escaping, FileRef equality and string form, the encoders of FileRef, of a case class with FileRef fields and of a Row, reading a FILE EXTERNAL column through the FileRef encoder, the encoder flag, and the casts.\n- New `FileTypeDatasetSuite` (sql/core): Datasets of FileRef and of a case class with FileRef fields, a DataFrame with a FILE EXTERNAL column read back as FileRef, `show` with and without whole-stage code generation, a bean with a FileRef property, a cached DataFrame, the rejected cast to STRING, writes of FileRefs to FILE EXTERNAL columns under the ANSI and STRICT store assignment policies, the aggregates that hash a FILE, and the flag.\n- `RowToColumnConverterSuite`: FILE columns, null values, null fields, an array of FILE and a struct with a FILE, in on-heap and off-heap vectors, read through `ColumnarBatchRow`.\n- `ColumnVectorUtilsSuite`: populating a constant FILE vector.\n- Also ran the `CastWithAnsiOn/Off` and `TryCast` suites, `DataTypeSuite`, `ExpressionEncoderSuite`, `EncoderResolutionSuite`, the `types.ops` suites, `ScalaReflectionSuite`, `JavaTypeInferenceSuite`, `ToPrettyStringSuite`, the `execution.vectorized` and `execution.columnar` suites, `CachedTableSuite` and `FileTypeRestrictionsSuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\nCloses #60741 from dejankrak-db/SPARK-62112-file-type-physical-value.\n\nAuthored-by: Dejan Krakovic \u003cdejan.krakovic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "ae10aa6c1033e42080374a0c7d11df85eaa196f8",
      "tree": "7175f1ad0818395c10035ad4c8a7161b454aa1a8",
      "parents": [
        "80efe1a2257334984f23d44f71517bbf63b0e2a2"
      ],
      "author": {
        "name": "Simon Maling",
        "email": "s.maling@celonis.com",
        "time": "Thu Nov 26 15:52:35 2026 +0800"
      },
      "committer": {
        "name": "Cheng Pan",
        "email": "chengpan@apache.org",
        "time": "Thu Nov 26 15:52:35 2026 +0800"
      },
      "message": "[SPARK-59574][SQL] Apply injectHintResolutionRule in the single-pass Analyzer\n\n### What changes were proposed in this pull request?\n\nhttps://issues.apache.org/jira/browse/SPARK-59574\n\nThe single-pass Resolver never applies the hint resolution rules injected through `SparkSessionExtensions.injectHintResolutionRule`. `HybridAnalyzer.fromLegacyAnalyzer` forwards `singlePassResolverExtensions`, `singlePassMetadataResolverExtensions`, `singlePassPostHocResolutionRules` and `singlePassExtendedResolutionChecks`, and there is no hint resolution rule list among them, so those rules are silently dropped.\n\nThis PR adds `Analyzer.singlePassHintResolutionRules`, following the existing `singlePass*` extension points so that an Analyzer can run a different set of rules under the single-pass Resolver. Unlike the other `singlePass*` lists it defaults to `hintResolutionRules` (as a `def`, to stay clear of Scala initialization order) instead of `Nil`: a `Nil` default would recreate the footgun this PR is fixing, where an Analyzer that only overrides `hintResolutionRules` silently drops those rules under single-pass.\n\nThe rules are applied in `Resolver.lookupMetadataAndResolve`, after IDENTIFIER/CTE substitution and before the `MetadataResolver` pre-pass, mirroring the fixed-point ordering:\n\n```\nSubstitution -\u003e Hints -\u003e ... -\u003e Resolution (ResolveSQLOnFile)\n```\n\nOrdering relative to the metadata pre-pass is the important part: the pre-pass resolves relation metadata eagerly, and for path-based relations `FileResolver` lists files there. Anything that has to rewrite an `UnresolvedRelation` must run before it.\n\n`HintResolutionRunner` is a small wrapper on top of `RuleExecutor`, modelled on the existing `PlanRewriter`:\n\n- It runs the rules in a `\"Hints\"` batch with the same `FixedPoint` strategy the fixed-point Analyzer uses for that batch, so injected rules see identical iteration semantics and the same `spark.sql.analyzer.maxIterations` error. `FixedPoint` rather than `Once` is a deliberate compatibility choice: `injectHintResolutionRule` is an existing API whose contract has always been fixed-point execution inside that batch, and running the rules once could silently change the behaviour of extensions that rely on re-application.\n- It is preceded by a `\"Disable Hints\"` batch holding `ResolveHints.DisableHints`, in the same position the fixed-point Analyzer has it, so that `spark.sql.optimizer.disableHints\u003dtrue` keeps hiding hints from the injected rules. Without this, a custom rule matching `UnresolvedHint` would still fire under the forced single-pass resolver while the fixed-point Analyzer had already stripped the hint.\n- It presents the plan to the rules in the shape the fixed-point `\"Hints\"` batch observes. There, `CTESubstitution` has already turned each `WITH` into a `WithCTE` whose `CTERelationDef`s are children of the root, so the batch runs once over the whole CTE tree. `UnresolvedWith` does not expose its definitions as children (the same reason `MetadataResolver` matches it explicitly), so the runner temporarily replaces each `UnresolvedWith`, nested ones included, with the equivalent `WithCTE`, runs the batch once, and converts it back, keeping CTE names, options, `origin` and tags. Rules therefore receive one root per iteration, regardless of the number of CTE definitions.\n- Subquery plans are handled like `ResolveSubquery` re-entering the Analyzer: the batch runs on the containing plan first, then separately on each subquery plan, including subqueries the rules just created. The rewrites run within `AnalysisHelper.allowInvokingTransformsInAnalyzer`, like the rewrite rules in `PlanRewriter`.\n\n`IdentifierAndCteSubstitutor`, which runs immediately before, walks the same three places in one pass, so this is a second traversal over that shape. They are kept separate deliberately: the fixed-point Analyzer completes its `\"Substitution\"` batch before the `\"Hints\"` batch begins, so folding the rules into the substitutor\u0027s traversal would hand them partially substituted trees and trade a traversal for a parity gap. The traversal is pruned on `UNRESOLVED_WITH` / `PLAN_EXPRESSION`, and when no extension registers hint resolution rules, which is the default, the plan is returned untouched and no `RuleExecutor` runs.\n\nScope, stated precisely, because the name of the extension point is broader than what this PR can deliver:\n\n- Rules that rewrite non-hint operators, such as the `UnresolvedRelation` rewrite that motivates this PR, work under every single-pass configuration: forced, tentative and the single-pass half of dual-run.\n- Rules that implement custom hint *syntax*, i.e. that match `UnresolvedHint`, are only reachable when single-pass resolution runs unconditionally. `ResolverGuard` runs before `lookupMetadataAndResolve` and rejects `UnresolvedHint`, so under `enabledTentatively` or dual-run such a plan falls back to the fixed-point Analyzer and never reaches this code. That is why the `CONVERT_TO_EMPTY` test uses the unconditional mode, while the path-rewrite tests cover dual-run.\n- The built-in hint rules (`ResolveHints.ResolveJoinStrategyHints`, `ResolveCoalesceHints`) are not run here, since the single-pass Resolver has no `UnresolvedHint` handling to build on. Supporting hints in the single-pass Resolver is separate work.\n- The rules run after IDENTIFIER/CTE substitution, whereas the fixed-point `\"Hints\"` batch runs after the whole `\"Substitution\"` batch (`OptimizeUpdateFields`, `WindowsSubstitution`, `EliminateUnions`, `EliminateLazyExpression`) and `\"Apply Limit All\"`. A rule keyed on `Union` or on window shapes can therefore see a different tree under the two analyzers. The single-pass Resolver handles those rewrites during resolution, so there is no equivalent point to run after.\n- `UnresolvedCTERelation.plan` is typed as `SubqueryAlias`, so a rule that replaces the `SubqueryAlias` of a CTE definition, or adds or removes CTE definitions, produces a plan that cannot be converted back to an `UnresolvedWith`; that fails with an internal error. Rules that rewrite relations are unaffected.\n- References to CTEs are still `UnresolvedRelation`s when the rules run, since the single-pass Resolver links them during resolution, whereas the fixed-point `\"Hints\"` batch already sees `CTERelationRef`s.\n- An injected rule can introduce an operator the single-pass Resolver cannot resolve. `ResolverGuard` has already vetted the plan by then, so the resolution fails with `UNSUPPORTED_SINGLE_PASS_ANALYZER_FEATURE` instead of falling back. Dual-run reports it as `HYBRID_ANALYZER_EXCEPTION.SINGLE_PASS_FAILED_FIXED_POINT_SUCCEEDED`; `enabledTentatively` falls back to the fixed-point Analyzer. Such a query already failed before this change, with `LOGICAL_PLAN_COMPARISON_MISMATCH`, because only the fixed-point half applied the rule, so this changes which error is reported rather than breaking a working query. Re-running `ResolverGuard` on the post-hint plan would turn it into a graceful fallback; that is left out of this PR, since dual-run exists to surface exactly this kind of divergence.\n\n### Why are the changes needed?\n\n1. Rules registered through a public, documented extension API do not run under the single-pass Analyzer, i.e. with `spark.sql.analyzer.singlePassResolver.enabled\u003dtrue`, with `enabledTentatively\u003dtrue`, or in the single-pass half of `dualRunWithLegacy`.\n\n2. Rules that must run *before* relation metadata lookup cannot work at all. Example: path SQL such as ``SELECT * FROM parquet.`s3://bucket/dir` ``. Under fixed-point a hint rule sees the `UnresolvedRelation` and can rewrite it (for instance to attach storage credentials) before `ResolveSQLOnFile`. Under single-pass, `FileResolver` has already resolved and listed the path in the metadata pre-pass. `injectPostHocResolutionRule` is not a substitute, as it runs after resolution, and `singlePassMetadataResolverExtensions` is not injectable through `SparkSessionExtensions`.\n\n3. Dual-run diverges. Without this change the dual-run of such a query fails with:\n\n```\n[HYBRID_ANALYZER_EXCEPTION.SINGLE_PASS_FAILED_FIXED_POINT_SUCCEEDED] ...\nSingle-pass resolution failed, but fixed-point resolution succeeded.\n```\n\nThis is the same class of gap as SPARK-59081 and SPARK-56453: an analyzer rule list that was not updated when a second analyzer path was introduced.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Rules injected with `injectHintResolutionRule` now also run under the single-pass Resolver and in dual-run, matching the fixed-point Analyzer. Previously they were silently dropped. There is no change for sessions that do not register such rules.\n\nWorth being explicit about one consequence: in dual-run these rules now run once per analyzer half, so a rule with side effects (an RPC, minting a credential) is invoked twice per query, and a rule that is not deterministic can make the two plans differ. This matches the existing behaviour of `singlePassMetadataResolverExtensions`, which also run in both halves.\n\n### How was this patch tested?\n\nNew tests in `SparkSessionExtensionSuite`:\n\n- `SPARK-59574: inject custom hint rule with single-pass resolver` — the existing `CONVERT_TO_EMPTY` -\u003e `LocalRelation` hint rule, with the single-pass resolver enabled.\n- `SPARK-59574: hint rule rewrites path relations` (fixed-point, regression guard), `... with single-pass resolver`, `... in dual-run` and `... with the resolver enabled tentatively` — a hint rule redirects ``parquet`.`\u003cpath\u003e`` to another directory holding a different number of rows, so the rewrite is observable in the query result. Each variant covers a plain relation, a CTE and a scalar subquery.\n- `SPARK-59574: injected hint rules are bound by spark.sql.analyzer.maxIterations` — a rule that never converges has to fail the same way under both analyzers, which pins the `FixedPoint` strategy and the `errorOnExceed` behaviour.\n- `SPARK-59574: injected hint rules honour spark.sql.optimizer.disableHints` — parity check for the `\"Disable Hints\"` batch. Fails without it: the rule still fires under the forced single-pass resolver and turns the plan into a `LocalRelation`.\n- `SPARK-59574: rule introducing an operator unsupported by single-pass fails the resolution` — pins the last scope item above, for both the forced resolver and dual-run.\n- `SPARK-59574: root-sensitive hint rule sees a CTE query as one plan` - a rule that limits an `Aggregate` root must leave an aggregating CTE definition alone, under fixed-point, forced single-pass, dual-run and tentative modes.\n- `SPARK-59574: CTE definitions do not multiply hint rule invocations` - a rule that does not change the plan must be invoked equally often by both analyzers on a query with three CTE definitions (before: 1 vs. 4).\n- `SPARK-59574: containing plan\u0027s hint batch sees an unprocessed subquery` and `... subquery created by a hint rule is rewritten before metadata lookup` - pin the containing-plan-before-subquery order under both analyzers.\n- `SPARK-59574: hint rule rewrites path relations in a view body` — `lookupMetadataAndResolve` runs once per unresolved `View`, so the rules reach view bodies. That matches the fixed-point Analyzer, which resolves a view body through `ViewResolution.resolve` with `resolveChild \u003d executeSameContext` and therefore replays the `\"Hints\"` batch. Measured on a persistent view over `parquet.` + path with the redirecting rule:\n\n| mode | result |\n| --- | --- |\n| fixed-point | view body rewritten |\n| dual-run | view body rewritten (agrees with fixed-point) |\n| single-pass forced | `ExplicitlyUnsupportedResolverFeature`: \"View body is not supported\" |\n\n  The single-pass Resolver cannot resolve a view body holding a relation yet, with or without this change, which is why dual-run agrees with fixed-point: `ExplicitlyUnsupportedResolverFeature` makes it fall back. This test therefore passes on `master` as well; it is a canary that will start failing if the single-pass Resolver gains view-body support without the hint rules being considered.\n\nNew `HintResolutionRunnerSuite` in catalyst covers the runner directly: CTE definitions, nested CTEs, subquery plans, a subquery inside a CTE definition, `origin`, tag, name and option preservation, rules seeing a single `WithCTE` root and being invoked once regardless of the CTE count, root-sensitive rules leaving CTE definitions alone, rejection of a rule that replaces a CTE\u0027s `SubqueryAlias`, and the containing-plan-before-subquery order.\n\n`HybridAnalyzerSuite` runs `HybridAnalyzer.fromLegacyAnalyzer` with distinct `hintResolutionRules` and `singlePassHintResolutionRules`, and checks that each mode runs only its own sequence, so forwarding the legacy sequence to the `Resolver` fails the test.\n\n`HiveSparkSessionExtensionSuite` gains single-pass and dual-run coverage for the existing SPARK-59081 path SQL test, under `enableHiveSupport()`. The dual-run variant uses the redirecting rule rather than the observing one, because an observing rule cannot tell the two dual-run halves apart: the fixed-point half satisfies it on its own.\n\n`AnalyzerExtensionPropagationSuite` guards `Analyzer.withCatalogManager` against a new extension point being added without being propagated. `singlePassHintResolutionRules` is copied there like the other lists, and the suite now overrides it with a rule sequence distinct from `hintResolutionRules`, so the assertion fails if the copy is dropped.\n\nVerified the tests are meaningful: with the test changes kept and the production files reverted to `master`, the single-pass, dual-run and tentative tests fail (single-pass reads the original directory, `1 did not equal 3`; dual-run raises `SINGLE_PASS_FAILED_FIXED_POINT_SUCCEEDED`) while the fixed-point test passes. Likewise, with the previous per-definition CTE handling restored, the new CTE tests fail (`1 did not equal 2`, `invoked the rule 1 and 4 times`), and forwarding `legacyAnalyzer.hintResolutionRules` in `HybridAnalyzer` fails the `HybridAnalyzerSuite` test (`List(legacy) did not equal List(single-pass)`).\n\nLocally, on Java 17:\n\n- `build/sbt \u0027sql/testOnly org.apache.spark.sql.SparkSessionExtensionSuite org.apache.spark.sql.analysis.resolver.*\u0027`\n- `build/sbt \u0027catalyst/testOnly org.apache.spark.sql.catalyst.analysis.AnalyzerExtensionPropagationSuite org.apache.spark.sql.catalyst.analysis.resolver.HintResolutionRunnerSuite\u0027`\n- `build/sbt \u0027hive/testOnly org.apache.spark.sql.hive.HiveSparkSessionExtensionSuite\u0027`\n- `catalyst/scalastyle`, `catalyst/Test/scalastyle`, `sql/Test/scalastyle`, `hive/Test/scalastyle` — no errors.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Cursor Claude Opus 5\n\n\nCloses #58856 from s-maling-celonis/SPARK-59574.\n\nAuthored-by: Simon Maling \u003cs.maling@celonis.com\u003e\nSigned-off-by: Cheng Pan \u003cchengpan@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "80efe1a2257334984f23d44f71517bbf63b0e2a2",
      "tree": "55a205d30f1eaf9b259444e51d89d2515b3ab93d",
      "parents": [
        "ef70642c23269b70858fa2da2926816052215cb9"
      ],
      "author": {
        "name": "Saath",
        "email": "63187492+saths008@users.noreply.github.com",
        "time": "Thu Nov 26 15:23:39 2026 +0800"
      },
      "committer": {
        "name": "Cheng Pan",
        "email": "chengpan@apache.org",
        "time": "Thu Nov 26 15:23:39 2026 +0800"
      },
      "message": "[SPARK-62125][SQL] Avoid intermediate copies of binary values in Parquet writes\n\n[SPARK-62125](https://issues.apache.org/jira/browse/SPARK-62125)\r\n\r\n### What changes were proposed in this pull request?\r\n\r\n\r\nWhilst writing binary values to Parquet:\r\n  - For byte-array-backed unsafe rows and arrays, we pass the existing slice to Parquet without an intermediate copy.\r\n  - For other backing storage, we first copy the bytes into a byte array.\r\n  - For other row and array implementations, we keep the existing getBinary path.\r\n\r\nThis has decent perf improvements (see below)\r\n\r\n\r\n### Why are the changes needed?\r\n\r\n\r\n| Workload | Writer | Baseline allocated MB | Patched allocated MB | Allocation reduction | Baseline latency (ms) | Patched latency (ms) | Time saved (ms) | Latency reduction |\r\n|---|---|---:|---:|---:|---:|---:|---:|---:|\r\n| short | V1 | 360.0 | 325.1 | 9.7% | 717.0 | 695.0 | 21.9 | 3.1% |\r\n| short | V2 | 379.0 | 346.5 | 8.6% | 654.1 | 621.3 | 32.8 | 5.0% |\r\n| wide | V1 | 515.3 | 478.6 | 7.1% | 894.9 | 861.2 | 33.7 | 3.8% |\r\n| wide | V2 | 534.0 | 485.0 | 9.2% | 867.8 | 814.1 | 53.8 | 6.2% |\r\n| long | V1 | 325.2 | 236.5 | 27.3% | 510.9 | 503.6 | 7.3 | 1.4% |\r\n| long | V2 | 384.0 | 295.0 | 23.2% | 509.9 | 512.1 | -2.2 | -0.4% |\r\n| low-cardinality | V1 | 169.0 | 142.6 | 15.6% | 459.8 | 405.0 | 54.9 | 11.9% |\r\n| low-cardinality | V2 | 167.0 | 140.6 | 15.8% | 408.4 | 395.4 | 13.0 | 3.2% |\r\n\r\n\r\n\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nNo\r\n\r\n### How was this patch tested?\r\n\r\n\r\nTests were added, there are existing tests too\r\n\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\nGenerated-by: Codex GPT-6-Astra\r\n\r\n\r\n\r\n\r\n### Benchmark \r\n```java\r\n/*\r\n * Licensed to the Apache Software Foundation (ASF) under one or more\r\n * contributor license agreements.  See the NOTICE file distributed with\r\n * this work for additional information regarding copyright ownership.\r\n * The ASF licenses this file to You under the Apache License, Version 2.0\r\n * (the \"License\"); you may not use this file except in compliance with\r\n * the License.  You may obtain a copy of the License at\r\n *\r\n *    http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\npackage org.apache.spark.sql.execution.benchmark\r\n\r\nimport java.lang.management.ManagementFactory\r\nimport java.util.concurrent.atomic.AtomicLong\r\n\r\nimport com.sun.management.ThreadMXBean\r\nimport org.apache.hadoop.fs.Path\r\nimport org.apache.parquet.column.ParquetProperties\r\n\r\nimport org.apache.spark.benchmark.Benchmark\r\nimport org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd}\r\nimport org.apache.spark.sql.{DataFrame, Row}\r\nimport org.apache.spark.sql.functions.col\r\n\r\n/**\r\n * Measures Parquet binary writes from heap-backed row slices after a shuffle.\r\n * Compare unmodified and patched writers in fresh JVMs with the same settings.\r\n * Allocation counts cover the whole JVM, including driver work; CPU counts cover executor tasks.\r\n *\r\n * To run:\r\n * {{{\r\n * build/sbt \"sql/Test/runMain org.apache.spark.sql.execution.benchmark.ParquetBinaryWriteBenchmark\"\r\n * }}}\r\n * An optional argument selects one workload: short, wide, long, or low-cardinality.\r\n */\r\nobject ParquetBinaryWriteBenchmark extends SqlBasedBenchmark {\r\n\r\n  override def runBenchmarkSuite(mainArgs: Array[String]): Unit \u003d {\r\n    val workloads \u003d Seq(\r\n      Workload(\"short\", 120000, 8, 32),\r\n      Workload(\"wide\", 40000, 32, 32),\r\n      Workload(\"long\", 12000, 8, 1024),\r\n      Workload(\"low-cardinality\", 120000, 8, 32, seed \u003d \"id % 16\"))\r\n    val names \u003d workloads.map(_.name)\r\n    require(mainArgs.forall(names.contains), s\"Unknown workload, expected one of $names\")\r\n    val allocationBean \u003d ManagementFactory.getThreadMXBean.asInstanceOf[ThreadMXBean]\r\n    require(allocationBean.isThreadAllocatedMemorySupported)\r\n    allocationBean.setThreadAllocatedMemoryEnabled(true)\r\n    // Resolve at runtime: this HotSpot method is absent from the Java 21 release API.\r\n    val totalAllocatedBytes \u003d try {\r\n      classOf[ThreadMXBean].getMethod(\"getTotalThreadAllocatedBytes\")\r\n    } catch {\r\n      case e: NoSuchMethodException \u003d\u003e\r\n        throw new IllegalStateException(\"This benchmark requires total JVM allocation counts\", e)\r\n    }\r\n    def allocatedBytes(): Long \u003d totalAllocatedBytes.invoke(allocationBean)\r\n      .asInstanceOf[java.lang.Long].longValue()\r\n    require(allocatedBytes() \u003e\u003d 0, \"Total JVM allocation counts are unavailable\")\r\n\r\n    workloads.filter(w \u003d\u003e mainArgs.isEmpty || mainArgs.contains(w.name)).foreach { workload \u003d\u003e\r\n      withTempPath { root \u003d\u003e\r\n        val columns \u003d (0 until workload.columns).map { index \u003d\u003e\r\n          val value \u003d s\"sha2(concat(cast(${workload.seed} as string), \u0027-$index\u0027), 256)\"\r\n          val repeated \u003d s\"substring(repeat($value, ${(workload.length + 31) / 32}), \" +\r\n            s\"1, ${workload.length * 2})\"\r\n          s\"if(id % 10 \u003d 0, null, unhex($repeated)) as b$index\"\r\n        }\r\n        val source \u003d new Path(root.toURI.toString, \"source\").toString\r\n        spark.range(workload.rows).selectExpr((Seq(\"id\") ++ columns): _*)\r\n          .write.parquet(source)\r\n        // Cache before the shuffle so that the measured region pays for the shuffle and the write\r\n        // but not for the Parquet scan. Caching after the shuffle would instead feed rows from the\r\n        // columnar cache, bypassing the UnsafeRow slices this benchmark exists to measure.\r\n        val cached \u003d spark.read.parquet(source).cache()\r\n        cached.count()\r\n        try {\r\n          val input \u003d cached.repartition(4, col(\"id\"))\r\n          val expected \u003d checksum(input)\r\n          val destination \u003d new Path(root.toURI.toString, \"output\")\r\n          val fs \u003d destination.getFileSystem(spark.sessionState.newHadoopConf())\r\n          ParquetProperties.WriterVersion.values().foreach { version \u003d\u003e\r\n            val name \u003d s\"${workload.name} binary values, $version\"\r\n            runBenchmark(name) {\r\n              val cpu \u003d new AtomicLong()\r\n              val listener \u003d new SparkListener {\r\n                override def onTaskEnd(event: SparkListenerTaskEnd): Unit \u003d {\r\n                  if (event.taskMetrics !\u003d null) {\r\n                    cpu.addAndGet(event.taskMetrics.executorCpuTime)\r\n                  }\r\n                }\r\n              }\r\n              spark.sparkContext.addSparkListener(listener)\r\n              try {\r\n                val benchmark \u003d new Benchmark(name, workload.rows, output \u003d output)\r\n                benchmark.addTimerCase(\"write binary values\", numIters \u003d 5) { timer \u003d\u003e\r\n                  spark.sparkContext.listenerBus.waitUntilEmpty(30000)\r\n                  val beforeCpu \u003d cpu.get()\r\n                  val beforeAllocation \u003d allocatedBytes()\r\n                  timer.startTiming()\r\n                  input.write.mode(\"overwrite\")\r\n                    .option(\"compression\", \"snappy\")\r\n                    .option(\"parquet.writer.version\", version.toString)\r\n                    .option(\"parquet.enable.dictionary\", \"true\")\r\n                    .option(\"parquet.dictionary.page.size\", 1024 * 1024)\r\n                    .parquet(destination.toString)\r\n                  timer.stopTiming()\r\n                  val allocated \u003d allocatedBytes() - beforeAllocation\r\n                  spark.sparkContext.listenerBus.waitUntilEmpty(30000)\r\n                  // Warm-up runs get iteration -1; report only the timed ones.\r\n                  if (timer.iteration \u003e\u003d 0) {\r\n                    val files \u003d fs.listStatus(destination)\r\n                      .filter(_.getPath.getName.endsWith(\".parquet\"))\r\n                    // scalastyle:off println\r\n                    benchmark.out.println(s\"${workload.name},$version,${timer.iteration},\" +\r\n                      s\"allocatedBytes\u003d$allocated,elapsedNs\u003d${timer.totalTime()},\" +\r\n                      s\"executorCpuNs\u003d${cpu.get() - beforeCpu},\" +\r\n                      s\"outputBytes\u003d${files.map(_.getLen).sum},files\u003d${files.length}\")\r\n                    // scalastyle:on println\r\n                  }\r\n                }\r\n                benchmark.run()\r\n                assert(checksum(spark.read.parquet(destination.toString)) \u003d\u003d expected)\r\n              } finally {\r\n                spark.sparkContext.removeSparkListener(listener)\r\n              }\r\n            }\r\n          }\r\n        } finally {\r\n          cached.unpersist()\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n  private def checksum(data: DataFrame): Row \u003d {\r\n    data.selectExpr(\"count(*)\", \"sum(cast(xxhash64(*) as decimal(38, 0)))\").head()\r\n  }\r\n\r\n  private case class Workload(\r\n      name: String,\r\n      rows: Int,\r\n      columns: Int,\r\n      length: Int,\r\n      seed: String \u003d \"id\")\r\n}\r\n```\r\n\nCloses #60755 from saths008/saaths/reduce-binary-allocs.\n\nLead-authored-by: Saath \u003c63187492+saths008@users.noreply.github.com\u003e\nCo-authored-by: Saath Satheeshkumar \u003csaaths@palantir.com\u003e\nSigned-off-by: Cheng Pan \u003cchengpan@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "ef70642c23269b70858fa2da2926816052215cb9",
      "tree": "2707b86005603e79d019ffc8e26a0751be7d6e9c",
      "parents": [
        "e5f6570ecf16cdb7404966a55de09a5a06c895b3"
      ],
      "author": {
        "name": "Sem",
        "email": "ssinchenko@apache.org",
        "time": "Thu Nov 26 11:54:27 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Thu Nov 26 11:54:27 2026 +0800"
      },
      "message": "[SPARK-61793][GRAPH] simple centrality metrics\n\n### What changes were proposed in this pull request?\nTrivial centrality metrics: degrees, typed degrees.\n\n#### Difference compared to GF origin\nExplicit overloading instead of `Option` and scala\u0027 defaults.\n\n### Why are the changes needed?\nPart of SPARK-61746\n\n### Does this PR introduce _any_ user-facing change?\nNew API (Experimental)\n\n### How was this patch tested?\n- checks\n- scalatest\n\n### Was this patch authored or co-authored using generative AI tooling?\nClaude Code (Opus 5.5)\n\nCloses #60885 from SemyonSinchenko/SPARK-61793-trivial-centrality-metrics.\n\nAuthored-by: Sem \u003cssinchenko@apache.org\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n"
    },
    {
      "commit": "e5f6570ecf16cdb7404966a55de09a5a06c895b3",
      "tree": "d3fb39336926952ae96d61e1ead887324bd7638f",
      "parents": [
        "4636e209ad2d799480477f7b7564a847df0d65b8"
      ],
      "author": {
        "name": "Livia Zhu",
        "email": "livia.zhu@databricks.com",
        "time": "Thu Nov 26 10:35:44 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 10:35:44 2026 +0900"
      },
      "message": "[SPARK-59877][SS] Shuffle the stateful side of a Cartesian product so each state partition is computed by one task\n\n### What changes were proposed in this pull request?\n\nAdd a physical plan rule, `InsertShuffleBeforeStatefulCartesianProduct`, that runs in\n`QueryExecution.preparations` right after `EnsureRequirements` (and the `StampUnionDecisions` that\npairs with it). When one side of a `CartesianProductExec` reaches a stateful operator\n(`StateStoreWriter`) without crossing a stage boundary, the rule puts a shuffle between them that\nkeeps the state partition count:\n\n- It reuses the child\u0027s `HashPartitioning` when it already has one partition per state partition\n  and the child still outputs every attribute it references (`GenerateExec`, for example, forwards a\n  partitioning over a column it drops); otherwise it uses `RoundRobinPartitioning`.\n- It does nothing when an exchange already separates the stateful operator from the Cartesian\n  product, or when neither side is stateful.\n- It is not gated on streaming: a `foreachBatch` sink can run a batch plan that embeds an\n  already-planned stateful subtree.\n\nThe behavior is controlled by a new internal conf,\n`spark.sql.streaming.statefulOperator.shuffleBeforeCartesianProduct.enabled` (default true).\n\n### Why are the changes needed?\n\n`CartesianProductExec` runs one task per (left partition, right partition) pair. When the stateful\noperator is in the same stage, every state partition is computed by one task per partition of the\nother side, so N state partitions and M static partitions give N x M tasks, and the M tasks for one\nstate partition load the same state store at the same time. State stores assume one task per state\npartition per stage, so this fails in two ways:\n\n- With RocksDB, the sibling tasks wait on the same instance lock and time out with\n  `CANNOT_LOAD_STATE_STORE.UNRELEASED_THREAD_ERROR`.\n- When siblings run on different executors, the coordinator moves the active provider and unloads\n  the previous executor\u0027s copy, and a task can fail with\n  `STATE_STORE_INVALID_STATE_MACHINE_TRANSITION` (`CLOSED` -\u003e `ACQUIRED`).\n\nEven when neither happens, each sibling task reloads the state. A Cartesian product is the planner\u0027s\nlast-resort join, so this shows up when a stream is joined with a static side on a constant or\nnon-equi condition that is too large to broadcast.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo for queries that work today. A streaming query with a stateful operator under a Cartesian product\nin the same stage gets one extra shuffle per micro-batch, and each state partition is computed by\none task instead of once per partition of the other side. The output is unchanged, and the state\npartitioning and checkpoint are unchanged, since the shuffle sits above the stateful operator.\n\n### How was this patch tested?\n\nNew tests:\n\n- `StreamingStatefulCartesianSuite`:\n  - with the conf off, the stateful stage runs N x M tasks and the query fails with\n    `UNRELEASED_THREAD_ERROR` (checked with `checkError`);\n  - with it on, the stateful side on the left or the right is computed by one task per state\n    partition, and the inserted shuffle keeps the hash partitioning;\n  - round-robin when the stateful output no longer has the dedup\u0027s hash partitioning, or no longer\n    outputs the hash key (`explode`);\n  - no extra shuffle when one already separates the stateful side.\n- `StreamingStatefulCartesianEndToEndSuite`: a memory-sink query over two micro-batches with 8 state\n  partitions and a 4-partition static side, which fails without the fix and runs 8 tasks per\n  stateful stage with it.\n\n```\nbuild/sbt \"sql/testOnly org.apache.spark.sql.streaming.StreamingStatefulCartesianSuite org.apache.spark.sql.streaming.StreamingStatefulCartesianEndToEndSuite\"\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60833 from liviazhu/SPARK-59877.\n\nAuthored-by: Livia Zhu \u003clivia.zhu@databricks.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "4636e209ad2d799480477f7b7564a847df0d65b8",
      "tree": "a27e7fb73d3e5cae38223696fd9a0956a9e099fc",
      "parents": [
        "3003cd04d06ff53cfed3dba2b69260110596f9cd"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 09:31:08 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 09:31:08 2026 +0900"
      },
      "message": "[SPARK-61380][SS] Keep same-batch matches of stream-stream left semi joins between the watermarks\n\n### What changes were proposed in this pull request?\n\nA stream-stream left semi join now stores a right input row that the batch evicts, so that the batch\u0027s left rows can still find it. The eviction at the end of the batch still removes such a row.\n\nThe join skips such a row only when a cutoff at the late-events watermark that is exact today shows that no left row passing late filtering can match it. There are two such cutoffs:\n\n- a key cutoff, when the left input\u0027s late-filtered column is a left join key;\n- a value cutoff on the right event time, from bounds that compare it with that left column shifted by literal intervals without a month part, and with a day part only in a session time zone with a fixed offset, such as UTC, where Spark adds a day as 24 hours.\n\nOther conditions store every evicted right row until the cutoff derivation becomes exact for them (SPARK-61344, SPARK-61381). Inner and outer joins keep skipping evicted right rows, because they process the left input first.\n\n### Why are the changes needed?\n\nSince SPARK-55973, a left semi join processes the right input of a micro-batch before the left input. The join did not store a right row that the batch evicts, because it assumed that the batch\u0027s left rows had already probed it. For a left semi join they have not. With the default `spark.sql.streaming.statefulOperator.allowMultiple\u003dtrue`, late filtering uses the previous batch\u0027s watermark and eviction uses the current one, so a right row between the two passes late filtering but was not stored. A left row of the same batch then found no match and was never emitted.\n\nFor example, take `leftKey \u003d rightKey AND leftTime \u003d rightTime` with 0-second watermarks on both inputs. A batch with late-events watermark 100 s and eviction watermark 105 s receives left (1, 102) and right (1, 102). It should emit (1, 102), but emits nothing.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. A left semi join now emits a left row whose matching right row arrives in the same micro-batch, passes late filtering, and is at or below the batch\u0027s right eviction cutoff. That includes:\n\n- a right row later than the eviction watermark under a time-interval condition such as `rightTime BETWEEN leftTime + INTERVAL 1 MINUTE AND leftTime + INTERVAL 1 HOUR`;\n- a match whose right cutoff comes from a bound on another right column, even when both watermarks are equal, as under `spark.sql.streaming.statefulOperator.allowMultiple\u003dfalse`.\n\nIn Spark 4.2.0 to 4.3.0 such rows were dropped.\n\nTo find these matches, the join writes such right rows to state and removes them in the same batch, unless an exact cutoff shows that no left row of the batch can match them. So for conditions without an exact cutoff, the number of updated state rows of a left semi join can grow.\n\n### How was this patch tested?\n\nAdded fourteen tests to `StreamingLeftSemiJoinBase`, and replaced the whole-day test of the first version by six of them. They run in state format 2 (RocksDB and HDFS), 3 and 4, each with and without changelog checkpointing where it applies.\n\n- **Same-batch matches between the watermarks** (each checks the output, and the state rows after the second and third batches), for four conditions:\n  - equal event times;\n  - a key shifted by 10 seconds while the watermark advances by 50 seconds;\n  - a time interval, `leftTime BETWEEN rightTime - INTERVAL 10 SECONDS AND rightTime + INTERVAL 10 SECONDS`;\n  - a right cutoff that comes from a bound on another right column, `rightExpiry \u003e\u003d leftTime + INTERVAL 30 SECONDS AND leftTime \u003e\u003d rightTime - INTERVAL 1 HOUR`. Each of its right rows is evicted in the same batch whether the cutoff is applied to rightTime or to rightExpiry, so the test also holds once SPARK-61344 applies it to rightExpiry.\n\n  Storing only the right rows above the cutoff at the late-events watermark would drop the last match.\n- **Rows that an exact cutoff rules out** are not stored:\n  - under `spark.sql.streaming.statefulOperator.allowMultiple\u003dfalse`, `rightTime BETWEEN leftTime + INTERVAL 1 MINUTE AND leftTime + INTERVAL 1 HOUR` writes and removes the same right state rows as before this change;\n  - in the default mode, the same condition skips a right row below the exact cutoff and still emits a same-batch match above it;\n  - `leftTime \u003d rightTime` with a watermark only on the left input skips a right row at or below the late-events watermark and still emits its same-batch match.\n- **Bounds with whole days** in the session time zone America/Los_Angeles, where a day can be 23 or 25 hours: the BETWEEN bound `rightTime BETWEEN leftTime + INTERVAL 1 DAY AND leftTime + INTERVAL 2 DAYS`, a negative day shift `rightTime - INTERVAL 1 DAY \u003e\u003d leftTime`, and `CAST(\u00271 day\u0027 AS INTERVAL)`. Each still stores every evicted right row, because its cutoff is not exact. The same three tests in UTC, a zone with a fixed offset, skip the right rows at or below the exact cutoff.\n- **A truncating cast**, `CAST(rightTime AS BIGINT) \u003e\u003d CAST(leftTime + INTERVAL 1 MINUTE AS BIGINT)`, still stores every evicted right row: with a late-events watermark of 100.5 s, the left row at 100.6 s matches the right row at 160.2 s after the cast. The test is skipped in state format 4, where the V4 range scan already misses this match for a separate reason.\n\n```sh\nbuild/sbt \u0027sql/testOnly *StreamingLeftSemiJoinV4Suite *StreamingLeftSemiJoinWithVCFSuite *StreamingLeftSemiJoinWithoutVCFSuite\u0027  # 170, 2 canceled\nbuild/sbt \u0027sql/testOnly *StreamingInnerJoinV4Suite *StreamingOuterJoinV4Suite *StreamingFullOuterJoinV4Suite *StreamingLeftSemiJoinV4Suite *StreamingInnerJoinWithVCFSuite *StreamingOuterJoinWithVCFSuite *StreamingFullOuterJoinWithVCFSuite *StreamingLeftSemiJoinWithVCFSuite *StreamingInnerJoinWithoutVCFSuite *StreamingOuterJoinWithoutVCFSuite *StreamingFullOuterJoinWithoutVCFSuite *StreamingLeftSemiJoinWithoutVCFSuite\u0027  # 625, 2 canceled\n```\n\nScalastyle for sql, main and test sources: 0 errors, 0 warnings.\n\nBefore round 3, the eight original tests failed without the change they cover:\n\n- **Without the fix,** with `StreamingSymmetricHashJoinExec` restored from the base commit and this PR\u0027s tests kept, 42 of the 136 left semi tests fail: seven of the eight new tests, in all 6 runs each.\n  - The four same-batch tests and the exact key-cutoff test emit no row for their same-batch match.\n  - The exact value-cutoff test and the whole-day test write a different number of state rows.\n  - The test under `allowMultiple\u003dfalse` passes there, as it should, because it checks that the state rows are the same as before this change.\n- **Without the exact cutoffs,** with this PR\u0027s previous code that stores every evicted right row, the three skip tests fail in all 18 runs, because one more right row is written to state. The whole-day test and the four same-batch tests pass there.\n\nReview round 3: the truncating-cast test fails in all 4 runs of state formats 2 and 3 when `isExactShiftOf` accepts a cast to BIGINT, because the left row at 100.6 s is not emitted. In the first run of the whole-day tests with wrong expected counts, UTC wrote fewer state rows than America/Los_Angeles in the first two batches, which shows that the zone rule takes effect. I did not run the America/Los_Angeles tests with each day check loosened.\n\nReview round 4 (tests only): a test for a same-batch match bounded by another right column when the late-events and eviction watermarks are equal, a test that skips evicted right rows below an exact cutoff when they are equal, left-first variants of the two minute-to-hour skip tests, and a fourth, left-first bound in the whole-day tests. After the change, the three left semi suites ran 200 tests with 2 canceled and scalastyle for the sql test sources reported 0 errors; the counts above are from round 3. If evicted right rows are not stored whenever the two watermarks are equal, the new test for equal watermarks with a bound on another right column fails. If the left-first orientation is dropped from the exactness filter, the left-first equal-watermark skip test, the left-first value-cutoff test and the UTC whole-day bound 4 fail; the America/Los_Angeles bound 4 passes, as it should, because it stores the row either way.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Anthropic Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\nCloses #60307 from HeartSaVioR/jungtaek-lim_data/left-semi-same-batch-match.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "3003cd04d06ff53cfed3dba2b69260110596f9cd",
      "tree": "c8a793be8492bdfb63d91a53a8af624f91f299b2",
      "parents": [
        "cdd66eff4eefcf097f17df05f941f9b8e3e5d1bc"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 06:24:07 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Thu Nov 26 06:24:07 2026 +0900"
      },
      "message": "[SPARK-62038][SS] Scan the V4 stream-stream join state from the start in the first batch of each run\n\n### What changes were proposed in this pull request?\n\nWith state format version 4, a stream-stream join starts each batch\u0027s eviction scan after the\nprevious batch\u0027s cutoff. This PR makes the first batch of each run scan from the start, as it\nalready did for batch 0. That covers a restart from a checkpoint whose previous run evicted less\nstate than the restarted query\u0027s cutoffs imply. State formats 2 and 3 evaluate every stored row\neach batch, so they are not affected.\n\n### Why are the changes needed?\n\nAn upgrade can raise a cutoff. For example, SPARK-61985 (#60664) removes a constant-only cap\nfrom the range cutoff, so state from an older version has rows below the new cutoff. V4 never\nscans them again. Example, a left outer join with 1 second watermarks:\n\n```sql\nleftKey \u003d rightKey AND lt \u003e rt - INTERVAL 5 SECONDS AND CAST(lt AS LONG) \u003e 10\n```\n\n| Step | Input | Output |\n|---|---|---|\n| Run without SPARK-61985 | left (1, 20 s), right (9, 20 s); left (8, 40 s), right (9, 40 s); right (9, 41 s) | none (the cutoff is capped at 10 s) |\n| Restart with SPARK-61985 | left (8, 60 s), right (9, 60 s) | V2 and V3: `(1, 20, null)`. V4: none, and the row stays in state |\n\nWith this PR, V4 also emits `(1, 20, null)`. Master shows the same skip without an upgrade, when\na restart tightens a range bound, for example from `lt \u003e rt - INTERVAL 10 SECONDS` to\n`lt \u003e rt - INTERVAL 5 SECONDS`.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. With V4, the first batch after a restart evicts the rows that the previous run\u0027s cutoff\nleft, and outer joins emit them, as V2 and V3 do. That batch scans the V4 timestamp index up to\nthe cutoff once.\n\n### How was this patch tested?\n\nNew test in `StreamingOuterJoinBase`, run with state format V2, V3 and V4: a left outer join\nrestarts with a cutoff above the previous run\u0027s. V4 fails without this PR. The outer join V2 and\nV3 suites and the V4 suites pass. The SPARK-61985 example above was also run across builds\n(first run on a build without SPARK-61985, restart on a build with it and this change).\n\n### Note for reviewers, including AI review\n\nPlease review only this PR\u0027s own commit. For each finding, give a runnable reproducer and say\nwhether master has the same behavior.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\nCloses #60700 from HeartSaVioR/jungtaek-lim_data/f-62038-v4-restart-backlog.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "cdd66eff4eefcf097f17df05f941f9b8e3e5d1bc",
      "tree": "5ffce2510f420296570eb51e115e56838be0b21c",
      "parents": [
        "31692e0692700a4a1a731be45391c94942b8404e"
      ],
      "author": {
        "name": "Rajesh Vakkalagadda",
        "email": "vrj@meta.com",
        "time": "Wed Nov 25 13:04:47 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Wed Nov 25 13:04:47 2026 -0800"
      },
      "message": "[SPARK-59387][SQL][TEST] Cover restricted-mode rejection of banned functions in subqueries\n\n### What changes were proposed in this pull request?\n\nAdds a test to the catalyst `RestrictedModeSuite` verifying that the restricted SQL execution mode (SPARK-59319) rejects banned functions (`reflect` / `java_method` / `try_reflect`) when they are nested inside an `EXISTS` predicate, asserting `UNSUPPORTED_FEATURE.SQL_RESTRICTED_MODE` with the function-name parameter, plus a mode-off control proving the gate (and not general analysis) is what fires. No production code is changed.\n\nThis complements the `sql/core` `RestrictedModeCommandSuite`, which already covers a banned call inside a scalar subquery through real SQL (`SELECT (SELECT reflect(...))`) and the linear-traversal guarantee on deeply nested subqueries. What no suite covers — and this test adds — is the `EXISTS` predicate shape, and `java_method` / `try_reflect` nested in a subquery at all.\n\n### Why are the changes needed?\n\nThe restricted mode exists so deployments can block dynamic code and external-script execution in SQL, and its core promise is that banned features \"cannot slip through\" — with subqueries being the most natural place to hide a banned call from a top-level-only check:\n\n```sql\nSELECT * FROM t WHERE EXISTS (SELECT reflect(\u0027java.lang.Runtime\u0027, \u0027getRuntime\u0027));\n```\n\nThe gate reaches subqueries through one traversal branch (`SubqueryExpression \u003d\u003e checkPlan(s.plan)`). A regression that broke handling for the `EXISTS` shape specifically — say, the match narrowed to scalar subqueries only — or for `java_method` / `try_reflect` inside any subquery, would fail silently today, since none of that is exercised by the existing scalar-subquery-only coverage. This test pins those shapes so such a regression fails loudly instead. The test is analysis-only and deterministic, adding negligible CI cost.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nNew test `restricted mode rejects banned functions nested in subqueries` in `RestrictedModeSuite` (analysis-only, no session needed):\n```\nbuild/sbt \u0027catalyst/testOnly org.apache.spark.sql.catalyst.analysis.RestrictedModeSuite\u0027\n```\nResult: Tests: succeeded 5, failed 0, canceled 0, ignored 0, pending 0 (4 existing, including the upstream init-fixture test, + 1 new).\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: MetaCode\n\nCloses #58674 from vrjdev/fill-replace-restricted-tests.\n\nAuthored-by: Rajesh Vakkalagadda \u003cvrj@meta.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "31692e0692700a4a1a731be45391c94942b8404e",
      "tree": "c61ad208e59391cb444d84c3a2439d454c77f36a",
      "parents": [
        "d3853926e3f4c40eb8d9937a3e02f35b52234372"
      ],
      "author": {
        "name": "Matthew B.",
        "email": "mgball@uci.edu",
        "time": "Wed Nov 25 13:02:34 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Wed Nov 25 13:02:34 2026 -0800"
      },
      "message": "[SPARK-61686][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_1082\n\n### What changes were proposed in this pull request?\n\nThis PR assigns the name `PARTITION_LOCATION_URI_NOT_SPECIFIED` to the legacy error condition `_LEGACY_ERROR_TEMP_1082`, as part of the ongoing SPARK-37935 work to give every error condition a stable, descriptive name. The entry in `error-conditions.json` is moved out of the `_LEGACY_ERROR_TEMP_*` block and redefined under the new name, keeping the same message text and gaining the SQLSTATE `42601`. The single throw site, `QueryCompilationErrors.partitionNotSpecifyLocationUriError`, is updated to reference the new condition, and a `checkError`-based test is added in `QueryCompilationErrorsSuite`.\n\n### Why are the changes needed?\n\n`_LEGACY_ERROR_TEMP_*` conditions are placeholder names that carry no meaning and no SQLSTATE. Naming them makes the error surface self-describing for users and tooling and moves the codebase toward retiring the legacy block (SPARK-37935).\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. The error raised when a partition specification does not specify a `locationUri` now reports the condition name `PARTITION_LOCATION_URI_NOT_SPECIFIED` with SQLSTATE `42601` instead of `_LEGACY_ERROR_TEMP_1082`. The message text is unchanged.\n\n### How was this patch tested?\n\nAdded a new test in `QueryCompilationErrorsSuite` that triggers `CatalogTablePartition.location` on a partition with no `locationUri` and asserts the condition and message parameter via `checkError`. Ran `SparkThrowableSuite` (validates `error-conditions.json`: alphabetical order, SQLSTATE, structure) — 38 tests, all pass — and the new `QueryCompilationErrorsSuite` test — passes.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 4.8\n\nCloses #60490 from Ma77Ball/assign-name-legacy-error-1082.\n\nAuthored-by: Matthew B. \u003cmgball@uci.edu\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d3853926e3f4c40eb8d9937a3e02f35b52234372",
      "tree": "e3b706f8201423b9e48b88daae188c65c80a05dd",
      "parents": [
        "65910135378250d698b7c0d82a944ba23d7fd1db"
      ],
      "author": {
        "name": "Amogh Desai",
        "email": "amoghdesai.oss@gmail.com",
        "time": "Wed Nov 25 12:57:39 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Wed Nov 25 12:57:39 2026 -0800"
      },
      "message": "[SPARK-60775][SQL][PYTHON] Add SparkSession. getOrCreateDataFrame for dataframes\n\nGiven a path, load the dataset if it is already there; otherwise compute it, store it as Parquet, and return it. Lets a rerun skip work an earlier run finished.\r\n\r\nClassic only. Completeness is tracked with a marker file instead of reusing `_SUCCESS`, which can be disabled or left by an unrelated writer. \r\n\r\n\r\n\r\n### What changes were proposed in this pull request?\r\n\r\nAdds `SparkSession.getOrCreateDataFrame(path, create)` to Spark Classic, in Scala and\r\nPySpark.\r\n\r\n```python\r\ndf \u003d spark.getOrCreateDataFrame(path, lambda: expensive_transform(src))\r\n```\r\n\r\nFirst call computes and saves. Later calls load and skip the work. A marker file records completeness, so a path left by an interrupted write is recomputed.\r\n\r\nClassic only, `DataFrame` not `Dataset[T]`, Parquet hardcoded, caller supplies the path.\r\n\r\nThe method is declared on the shared `SparkSession` and marked `ClassicOnly`. Connect throws `UNSUPPORTED_CONNECT_FEATURE.SESSION_GET_OR_CREATE_DATAFRAME`. The completeness check and the write live in two JVM helpers (`isDataFrameMaterialized`, `materializeDataFrame`) that PySpark calls, so the marker name is defined in one place.\r\n\r\n### Why are the changes needed?\r\n\r\nA batch job that dies in a late stage reruns from the start. Under an orchestrator, users pay for the same stages twice, usually after a spot reclaim where the same code would have worked.\r\n\r\nPeople hand-roll this today and get it wrong quietly: a path-exists check returns partial data, and a `_SUCCESS` check returns an unrelated job\u0027s data. Both report success.\r\n\r\nDev list: [Thoughts around getOrCreate for Dataset / DataFrame](https://lists.apache.org/thread.html/7mj5rwnylksnrvjocywc6sfxnrhl7c59)\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nYes, a new public method. No change to existing APIs.\r\n\r\n### How was this patch tested?\r\n\r\nNew suites in Scala and PySpark, three tests each: computes on first call, loads instead of recomputing, recomputes when the marker is absent.\r\n\r\n#### Pyspark\r\n\r\nUsing this function for the test - imitates a function run by daily pipeline that passes in the date\r\n\r\n```python\r\nimport time, os, shutil\r\ndef job(date):\r\n    def create():\r\n        print(\"\u003e\u003e\u003e computing\", date)\r\n        time.sleep(5)\r\n        return spark.range(100)\r\n    return spark.getOrCreateDataFrame(f\"/tmp/daily/{date}\", create)\r\n```\r\n\r\nResult:\r\n```shell\r\n\u003e\u003e\u003e job(\"2026-11-01\").count(); job(\"2026-11-02\").count()\r\n\u003e\u003e\u003e computing 2026-11-01\r\n\u003e\u003e\u003e computing 2026-11-02                                 # separate folders, no reuse\r\n100\r\n\r\n\u003e\u003e\u003e job(\"2026-11-01\").count()                            # a retry\r\n100                                                      # instant, no recompute\r\n\r\n\u003e\u003e\u003e [job(d).count() for d in [\"2026-11-03\", ..., \"2026-11-07\"]]\r\n\u003e\u003e\u003e computing 2026-11-03 ... 2026-11-07\r\n\r\n\u003e\u003e\u003e sorted(os.listdir(\"/tmp/daily\"))\r\n[\u00272026-11-01\u0027, \u00272026-11-02\u0027, \u00272026-11-03\u0027, \u00272026-11-04\u0027, \u00272026-11-05\u0027, \u00272026-11-06\u0027, \u00272026-11-07\u0027]\r\n9926 bytes                                               # nothing cleaned up\r\n```\r\n\r\nListing the files:\r\n```shell\r\namoghrajesh.desai  …/spark   SPARK-60775     v26.0.1  🅼    ♥ 16:16  ls -lr /tmp/daily\r\ntotal 0\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:12 2026-11-07\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:12 2026-11-06\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:12 2026-11-05\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:11 2026-11-04\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:11 2026-11-03\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:11 2026-11-02\r\ndrwxr-xr-x 10 amoghrajesh.desai  wheel  320 Nov  1 16:10 2026-11-01\r\n```\r\n\r\n#### Scala\r\n\r\nRunning same / similar case with scala. Run the shell first: `./bin/spark-shell`\r\n\r\n\r\nLets use this block:\r\n```scala\r\nvar calls \u003d 0\r\ndef create() \u003d {\r\n  calls +\u003d 1\r\n  println(\"\u003e\u003e\u003e computing\")\r\n  Thread.sleep(8000)\r\n  spark.range(1000).toDF()\r\n}\r\n```\r\n\r\nRunning this:\r\n\r\n```scala\r\nscala\u003e val t \u003d System.currentTimeMillis; val n \u003d spark.getOrCreateDataFrame(\"/tmp/sgoc1\", () \u003d\u003e create()).count(); println(s\"count $n | calls $calls | secs ${(System.currentTimeMillis-t)/1000.0}\")\r\n     | \r\n\u003e\u003e\u003e computing\r\ncount 1000 | calls 1 | secs 10.4                                                \r\nval t: Long \u003d 1793531061641\r\nval n: Long \u003d 1000\r\n```\r\n\r\nThat notes the time, calls getOrCreateDataFrame on an empty path, counts the rows, then prints how long it took and how many times the work ran.\r\n\r\nThen this:\r\n```scala\r\nscala\u003e val t \u003d System.currentTimeMillis; val n \u003d spark.getOrCreateDataFrame(\"/tmp/sgoc1\", () \u003d\u003e create()).count(); println(s\"count $n | calls $calls | secs ${(System.currentTimeMillis-t)/1000.0}\")\r\n     | \r\n\u003e\u003e\u003e computing\r\ncount 1000 | calls 1 | secs 10.4                                                \r\nval t: Long \u003d 1793531061641\r\nval n: Long \u003d 1000\r\n\r\n```\r\n\r\n##### Daily pipeline similar to pyspark\r\n\r\n```scala\r\ndef job(date: String) \u003d spark.getOrCreateDataFrame(\r\n  s\"/tmp/sdaily/$date\",\r\n  () \u003d\u003e { println(s\"\u003e\u003e\u003e computing $date\"); Thread.sleep(5000); spark.range(100).toDF() })\r\n\r\n```\r\n\r\nResult:\r\n```shell\r\nscala\u003e job(\"2026-11-01\").count(); job(\"2026-11-02\").count()\r\n     | \r\n\u003e\u003e\u003e computing 2026-11-01\r\n\u003e\u003e\u003e computing 2026-11-02                                                        \r\nval res0: Long \u003d 100\r\n```\r\n\r\n\r\n### Open questions\r\n\r\n- Staleness: if an input changes but the saved copy does not, the stale copy is returned. No way to force recomputation yet, is that an acceptable issue?\r\n- Cleanup: nothing deletes saved intermediates. Should that be documented?\r\n- Concurrency: two runs against the same fresh can path both compute and overwrite.\r\n- Spark Connect support, and a format argument, left as follow-ups.\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-By: Claude (Sonnet)\n\nCloses #60000 from amoghrajesh/SPARK-60775.\n\nAuthored-by: Amogh Desai \u003camoghdesai.oss@gmail.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "65910135378250d698b7c0d82a944ba23d7fd1db",
      "tree": "c30b419cc49a6a72ecebd226966597f00a7c86f0",
      "parents": [
        "aa907943afa5d215e69954ce41b943338a46676d"
      ],
      "author": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Wed Nov 25 12:40:07 2026 -0800"
      },
      "committer": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Wed Nov 25 12:40:07 2026 -0800"
      },
      "message": "[SPARK-61829][PYTHON][TEST] Add tests for invalid return types of Arrow and Pandas UDF APIs\n\n### What changes were proposed in this pull request?\n\nAdds `test_invalid_return_type_for_arrow_and_pandas_apis` to `BaseUDFTestsMixin` in `python/pyspark/sql/tests/test_udf.py`. It checks that each of these APIs rejects an invalid return type when the plan is built:\n\n- `udf(..., useArrow\u003dTrue)` with a type Arrow cannot represent (`YearMonthIntervalType`) raises `PySparkNotImplementedError`.\n- `DataFrame.mapInArrow` with a struct containing an unsupported field raises `PySparkNotImplementedError`. `DataFrame.mapInPandas` with a non-struct schema raises `INVALID_RETURN_TYPE_FOR_PANDAS_UDF`.\n- `GroupedData.applyInArrow` raises `PySparkNotImplementedError` for an unsupported field and `INVALID_RETURN_TYPE_FOR_ARROW_UDF` for a non-struct schema.\n- `PandasCogroupedOps.applyInPandas` with a non-struct schema raises `INVALID_RETURN_TYPE_FOR_PANDAS_UDF`.\n- `PandasCogroupedOps.applyInArrow` raises `PySparkNotImplementedError` for an unsupported field and `INVALID_RETURN_TYPE_FOR_ARROW_UDF` for a non-struct schema.\n\nNo Spark job runs. The test is skipped when pandas or pyarrow is missing.\n\n### Why are the changes needed?\n\n12 lines of `UserDefinedFunction._check_return_type` in `python/pyspark/sql/udf.py` were not covered by any test. These are the error branches for Arrow-optimized Python UDFs, map-in-Arrow/Pandas, grouped-map Arrow, and cogrouped-map Pandas/Arrow return types. This adds coverage for all 12.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, test-only change.\n\n### How was this patch tested?\n\nRan in the PySpark CI image:\n\n- `python/run-tests --testnames \u0027pyspark.sql.tests.test_udf UDFTests\u0027` (whole class, 93 tests): passed.\n- `python/run-tests --testnames \u0027pyspark.sql.tests.connect.test_parity_udf UDFParityTests.test_invalid_return_type_for_arrow_and_pandas_apis\u0027`: passed.\n- `ruff check` and `ruff format --check` on the changed file: passed.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60581 from gaogaotiantian/cov/sql-udf--userdefinedfunction-_check_return_type.\n\nAuthored-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\nSigned-off-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "aa907943afa5d215e69954ce41b943338a46676d",
      "tree": "8d6b751f1a09301f821bd3cc9f08905665f30e30",
      "parents": [
        "3b39230a46ffec2ecb950863c4cad8d317556eb3"
      ],
      "author": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Wed Nov 25 12:37:10 2026 -0800"
      },
      "committer": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Wed Nov 25 12:37:10 2026 -0800"
      },
      "message": "[SPARK-61828][PYTHON][TEST] Add observation test for more metric value types\n\n### What changes were proposed in this pull request?\n\nAdds `test_observe_with_various_types` to `DataFrameObservationTestsMixin` in `python/pyspark/sql/tests/test_observation.py`. One `DataFrame.observe` call collects metrics of type null, byte, short, float, and timestamp_ntz, plus a struct that contains a nested struct and a map, and the test asserts the values returned by `Observation.get`. Because the test lives in the mixin, it runs on both classic and Spark Connect.\n\n### Why are the changes needed?\n\n15 lines of `LiteralExpression._to_value` in `python/pyspark/sql/connect/expressions.py` were not covered by any test. This method converts the proto literals that the Connect server returns for observed metrics into Python values. The existing observation tests only use long and double values plus a top-level struct, array, and map, so the null, byte, short, float, and timestamp_ntz branches and the type checks for a struct or map nested inside a struct never ran. This test covers 14 of those 15 lines. The remaining line is the `UNSUPPORTED_LITERAL` error branch, which cannot be reached through public APIs.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, test-only change.\n\n### How was this patch tested?\n\nRan in the PySpark CI image:\n- `python/run-tests --testnames \u0027pyspark.sql.tests.test_observation DataFrameObservationTests\u0027` (13 tests pass)\n- `python/run-tests --testnames \u0027pyspark.sql.tests.connect.test_parity_observation DataFrameObservationParityTests\u0027` (13 tests pass)\n\nThe new test adds about 0.1 s when run in its class.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60578 from gaogaotiantian/cov/sql-connect-expressions--literalexpression-_to_value.\n\nAuthored-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\nSigned-off-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "3b39230a46ffec2ecb950863c4cad8d317556eb3",
      "tree": "e73b92f24b43b46310d0d477fd1dcd58bbd93088",
      "parents": [
        "c7c3397c0d3fb8a063e8734e4f8298291a43f0ae"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Wed Nov 25 17:52:08 2026 +0000"
      },
      "committer": {
        "name": "Yicong-Huang",
        "email": "17627829+Yicong-Huang@users.noreply.github.com",
        "time": "Wed Nov 25 17:52:08 2026 +0000"
      },
      "message": "[SPARK-62246][SQL][DOC][FOLLOWUP] Move the DataFrame as-of join using-columns migration guide entry to 4.4\n\n### What changes were proposed in this pull request?\nThis moves the migration guide entry added in #60796 from \"Upgrading from Spark SQL 4.5 to 5.0\" to \"Upgrading from Spark SQL 4.3 to 4.4\", and changes \"Since Spark 5.0\" to \"Since Spark 4.4\".\n\n### Why are the changes needed?\nSPARK-62246 is being backported to `branch-4.4` and `branch-4.x`, so the change first ships in 4.4.0.\n\n### Does this PR introduce _any_ user-facing change?\nNo, documentation only.\n\n### How was this patch tested?\nDocumentation only.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60888 from LukaZdravic/asof-62246-migration-note.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Yicong-Huang \u003c17627829+Yicong-Huang@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "c7c3397c0d3fb8a063e8734e4f8298291a43f0ae",
      "tree": "7a0aa8864b4382090eb2241c507f49ec88a63ac9",
      "parents": [
        "3cb02b5e7be7a7a6b8b8aedae39d491e73150a54"
      ],
      "author": {
        "name": "Vladan Vasić",
        "email": "vladan.vasic@databricks.com",
        "time": "Wed Nov 25 17:42:30 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Wed Nov 25 17:42:30 2026 +0000"
      },
      "message": "[SPARK-62330][SQL][TEST] Add DESCRIBE target, column and partition goldens\n\n### What changes were proposed in this pull request?\n\nAdd three SQL inputs and their execution and analyzer goldens for DESCRIBE ([SPARK-62330](https://issues.apache.org/jira/browse/SPARK-62330)):\n\n- Table and view target lookup: qualification, current schema, temporary-view shadowing, case sensitivity, stored metadata after dropping a view\u0027s base table, and unsupported V2 JSON output.\n- Column lookup: relation qualifiers, quoted dotted names, nested-field rejection, view comments, missing columns, and shadowing.\n- Partition lookup: key ordering, value casting, invalid specifications, view targets, and qualified access past a shadowing temporary view.\n\nThe inputs also exercise EXECUTE IMMEDIATE and variable-backed IDENTIFIER clauses; table targets include SQL scripts. Fixtures use Parquet and the existing in-memory V2 test catalog. The golden helper follows the analyzed command inside EXECUTE IMMEDIATE so DESCRIBE retains its metadata row order, with regression assertions for table and column describes. The dynamic JSON case runs inside a SQL script because JDBC sessions add owner metadata; direct AS JSON cases retain rendered-metadata coverage. No production code changes are included.\n\n### Why are the changes needed?\n\nThe existing describe.sql covers basic output forms. These cases pin target precedence and error behavior across tables and views, including dynamic execution, so resolver changes can be checked against both results and analyzed plans.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nRan with JDK 21:\n\n```sh\nSPARK_GENERATE_GOLDEN_FILES\u003d1 build/sbt \u0027sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z describe-table-targets.sql -z describe-table-column.sql -z describe-table-partition.sql\u0027\nenv -u SPARK_GENERATE_GOLDEN_FILES build/sbt -Phive-thriftserver \u0027sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z describe-table-targets.sql -z describe-table-column.sql -z describe-table-partition.sql -t \"Test logic for determining whether a query is semantically sorted\"\u0027 \u0027hive-thriftserver/testOnly org.apache.spark.sql.hive.thriftserver.ThriftServerQueryTestSuite -- -z describe-table-targets.sql -z describe-table-column.sql -z describe-table-partition.sql\u0027\n```\n\nGolden generation passed all 6 tests. Comparison passed all 7 SQLQueryTestSuite tests (6 execution/analyzer cases plus the ordering regression) and all 3 ThriftServerQueryTestSuite cases. The inputs contain 191 SQL statements, including setup and cleanup. Reviewed the generated results, plans and intended errors for stability.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex CLI 0.171.0 (GPT-6).\n\nCloses #60846 from vladanvasi-db/vladanvasi-db/describe-target-golden-tests.\n\nAuthored-by: Vladan Vasić \u003cvladan.vasic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n"
    },
    {
      "commit": "3cb02b5e7be7a7a6b8b8aedae39d491e73150a54",
      "tree": "6ef790056ff5c627bac06bbfaa3e4b3e45b24d18",
      "parents": [
        "b17f03c04ef38900bad0eae41d3ef88163d9dede"
      ],
      "author": {
        "name": "Vladan Vasić",
        "email": "vladan.vasic@databricks.com",
        "time": "Wed Nov 25 17:41:34 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Wed Nov 25 17:41:34 2026 +0000"
      },
      "message": "[SPARK-62326][SQL] Extract shared analysis helpers for table-targeted SHOW commands\n\n### What changes were proposed in this pull request?\n\nExtend `ShowCommandHelper` with the existing V1 lowering for `SHOW TABLE EXTENDED ... PARTITION`, `SHOW CREATE TABLE`, `SHOW PARTITIONS`, `SHOW COLUMNS` and `SHOW TBLPROPERTIES`. `ResolveSessionCatalog` delegates to it, passing its configuration lazily. Extract the legacy keyed `SHOW TBLPROPERTIES` output preparation into `KeepLegacyOutputs.keepLegacyShowTablePropertiesOutput`, with `KeepLegacyOutputs` retaining the configuration check.\n\nJira: https://issues.apache.org/jira/browse/SPARK-62326\n\n### Why are the changes needed?\n\nThese operations remain embedded in analyzer rules after SPARK-61004. Exposing per-command helpers lets other analysis paths share the same Hive/V1 branch ordering, namespace checks, raw partition specifications and output attributes. DDL target validation and not-found search paths are covered separately by SPARK-62296 (#60822).\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. The existing rules call the extracted logic with the same configuration, output attributes and error behavior.\n\n### How was this patch tested?\n\nWith JDK 21 and `build/sbt -Phive`:\n\n- `PlanResolutionSuite`: 113 tests passed, including six new tests for Hive/V1 precedence,\n  raw partitions, temporary views, legacy property output, owning-rule configuration and deferred\n  configuration lookup.\n- V1/V2 `ShowColumnsSuite`, `ShowCreateTableSuite`, `ShowPartitionsSuite`,\n  `ShowTblPropertiesSuite` and `ShowTablesSuite`: 213 tests passed across 10 suites, including\n  the DataSourceV2-tagged suites.\n- The same five Hive suites: 175 tests passed.\n- `SQLQueryTestSuite` for `show-*.sql`, `show_columns.sql` and `identifier-clause*.sql`:\n  16 execution/analyzer golden cases passed with no golden changes.\n- Catalyst/core Compile and Test scalastyle, whitespace, changed-source line-length and ASCII\n  checks: passed with zero errors or warnings.\n\nAll 517 tests passed with no failures, canceled, ignored or pending tests.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Codex (GPT-6)\n\nCloses #60842 from vladanvasi-db/vladanvasi-db/show-table-analysis-helpers.\n\nAuthored-by: Vladan Vasić \u003cvladan.vasic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b17f03c04ef38900bad0eae41d3ef88163d9dede",
      "tree": "ab068e6d9835087ed94233f9da4c2faa6c9df45c",
      "parents": [
        "0a12e0ec79af2f208bb2d95998865d29864ef5dc"
      ],
      "author": {
        "name": "Nicholas Chammas",
        "email": "nicholas.chammas@gmail.com",
        "time": "Wed Nov 25 11:57:08 2026 -0500"
      },
      "committer": {
        "name": "Nicholas Chammas",
        "email": "nicholas.chammas@gmail.com",
        "time": "Wed Nov 25 11:57:08 2026 -0500"
      },
      "message": "[SPARK-61645][BUILD] Run the R linter only when its inputs change\n\n### What changes were proposed in this pull request?\n\nAdded a `lint-r` module to `sparktestsupport` with `dev/lint-r` as its shell script test goal, and the lint job now runs it with `./dev/run-tests --modules lint-r`. This is the same approach #60449 took for JavaScript. The module is selected when anything under `R/`, the R lint scripts, or the lint CI image changes.\n\nTwo supporting changes:\n\n- `dev/lint-r` now installs SparkR itself when `R/lib` doesn\u0027t have it, so the separate `./R/install-dev.sh` workflow step is gone. The install runs only when the linter does.\n- I removed `run_sparkr_style_checks()` from `dev/run-tests.py`. The `lint-r` goal replaces it, so a full `./dev/run-tests` has one R lint path.\n\n### Why are the changes needed?\n\nThe `lint` job installs SparkR and runs `dev/lint-r` on every PR, though almost no PRs touch R now that SparkR is deprecated. With this change those PRs skip both steps.\n\nThe R linter (including SparkR install) takes a bit over 2 minutes to run. This is runner time we will now save on every single CI run.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, not for end users.\n\nFor contributors, a full local `./dev/run-tests` now fails if R isn\u0027t on `PATH`. It used to skip the R style check in that case. This is the same trade-off #60449 accepted for npm. `SKIP_R` only skips the SparkR tests, not this linter, so there is no way to skip just `lint-r` short of `--modules`.\n\nSparkR test jobs are unchanged.\n\n### How was this patch tested?\n\nR isn\u0027t installed on my machine, so I didn\u0027t run lintr or `R/install-dev.sh`. This PR changes `dev/lint-r`, so its own CI run is what exercises the new step.\n\n- Added a `sparktestsupport` test that checks a few representative paths select `lint-r` (or don\u0027t), and that `root` still runs `dev/lint-r`. `python3 -m unittest discover -s dev/sparktestsupport/tests -t dev` passes.\n- Checked with a stub `Rscript` that `dev/lint-r` calls `R/install-dev.sh` only when `R/lib/SparkR/DESCRIPTION` is missing.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Cursor (Grok 4.7, Claude Opus 5.5)\n\nCloses #60780 from nchammas/lint-r-test-module.\n\nAuthored-by: Nicholas Chammas \u003cnicholas.chammas@gmail.com\u003e\nSigned-off-by: Nicholas Chammas \u003cnicholas.chammas@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "0a12e0ec79af2f208bb2d95998865d29864ef5dc",
      "tree": "4850268980916dca951782664238311fd785aafb",
      "parents": [
        "f2730038855ae25aca0342b88c78e62728a02985"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Wed Nov 25 22:45:10 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Wed Nov 25 22:45:10 2026 +0900"
      },
      "message": "[SPARK-62057][SS] Keep empty children of a streaming Union in PropagateEmptyRelation\n\n### What changes were proposed in this pull request?\n\nIn a streaming query, a source without new data in a micro-batch is planned as an empty\n`LocalRelation`. `PropagateEmptyRelation` removes such empty children from a `Union`, so the plan\nof a query can change from one micro-batch to the next. When another rule then pushes a stateful\noperator below the `Union`, the number of stateful operators changes too, and a new operator\nlooks for state that no earlier batch wrote.\n\nThis PR keeps the empty children of a streaming `Union`, so the plan has the same shape in every\nmicro-batch. `PropagateEmptyRelation` already keeps empty streaming relations for joins,\naggregations and limits for the same kind of reason. Batch queries are not affected: the change\napplies only when the `Union` is streaming.\n\nA new internal conf, `spark.sql.optimizer.propagateEmptyRelationCanPruneStreamingUnionChildren`\n(default `false`), restores the old behavior. It is pinned in the offset log, and checkpoints\nwritten before this change read it as `true`, so their plans and stateful operators stay as\nthey were. This follows SPARK-49699 (`spark.sql.optimizer.pruneFiltersCanPruneStreamingSubplan`).\n\n### Why are the changes needed?\n\nA stream-stream left semi join over a union fails when a union input gets its first data after\nthe first micro-batch. `PushDownLeftSemiAntiJoin` pushes the join below the union, one join per\nunion input, but in the first batch the empty input had been removed. For example, with\n`spark.sql.streaming.noDataMicroBatches.enabled\u003dfalse`:\n\n```scala\ndef withTime(input: MemoryStream[(Int, Int)]) \u003d input.toDF().toDF(\"lk\", \"t\")\n  .select($\"lk\", timestamp_seconds($\"t\").as(\"lt\"))\nval left \u003d withTime(input1).withWatermark(\"lt\", \"10 seconds\")\n  .union(withTime(input2))          // no watermark on this input\nval right \u003d rightInput.toDF().toDF(\"rk\", \"s\")\n  .select($\"rk\", timestamp_seconds($\"s\").as(\"rt\"))\nleft.join(right, expr(\"lk \u003d rk AND lt \u003d rt\"), \"left_semi\")\n  .select($\"lk\", $\"lt\".cast(\"long\"))\n// batch 0: input1 (1, 5) and rightInput (1, 5)\n// batch 1: input2 (2, 6) and rightInput (2, 6)\n```\n\n- Before: batch 0 outputs `(1, 5)` with one stream-stream join. In batch 1 the plan has a second\n  join, and the query fails with `CANNOT_LOAD_STATE_STORE` (`state/1/\u003cpartition\u003e/1.changelog does\n  not exist`). This happens on every state format. The query also fails later whenever input2\n  stops getting data for a batch and then gets data again.\n- After: `(1, 5)`, then `(2, 6)`. The plan has two joins in every micro-batch.\n\nOnly an input whose path to the union is stateless and has no watermark is removed: an\n`EventTimeWatermark` or a streaming stateful operator stops the empty relation from spreading up.\nSo stateful operators inside a union input, and aggregations or deduplications above the union,\nare not affected. A left anti join with a streaming right side is not supported, so left anti\njoins are not affected either.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. New streaming queries keep empty union inputs in their plans, so a stateful operator that\nthe optimizer pushes below a union is planned the same way in every micro-batch, and such queries\nno longer fail as above. Existing checkpoints keep the old behavior through the offset log.\nBatch queries do not change.\n\n### How was this patch tested?\n\n- `PropagateEmptyRelationSuite`: a streaming union keeps its empty child, and drops it with the\n  conf set to `true`.\n- `OffsetSeqLogSuite`: an old offset log reads the conf as `true`, a new one records `false`.\n- `StreamingJoinSuite` (`StreamingLeftSemiJoinBase`, state formats V2, V3 and V4): the example\n  above, with the second input starting late, then pausing and coming back; and a restart from\n  a checkpoint without the conf, which keeps the single-join plan and finds its state.\n\nWithout the change to `PropagateEmptyRelation`, the `PropagateEmptyRelationSuite` test and the\nlate-input tests fail. Without the value for old checkpoints, the restart test fails, because\nthe query then plans two joins where the checkpoint has one.\n\n`StreamingStatefulOperatorNullabilityDriftSuite` now writes the checkpoints of its Union\nscenarios with the new conf set to true, as earlier versions did, so it still covers the branch\ndrop of existing checkpoints.\n\nPossible follow-up, not checked here: `PushDownJoinThroughUnion` (inner and left outer joins, off\nby default through `spark.sql.optimizer.pushDownJoinThroughUnion.enabled`) has no streaming guard\neither. It pushes a join below a union only when the right side is broadcast, which could depend\non a streaming input being empty in a micro-batch.\n\n### Note for reviewers, including AI review\n\nPlease review only this PR\u0027s own commit(s). For each finding, give a runnable reproducer and\nsay whether master has the same behavior.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\n\nCloses #60707 from HeartSaVioR/jungtaek-lim_data/f-62057-semi-union-state.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "f2730038855ae25aca0342b88c78e62728a02985",
      "tree": "2908be4809ad502391f948298a4cdf9a9ece7b59",
      "parents": [
        "9c61e02033db7165467c2a3fbeca602f20cc667d"
      ],
      "author": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Wed Nov 25 14:10:37 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Wed Nov 25 14:10:37 2026 +0100"
      },
      "message": "[SPARK-60329][SQL] Add a config to evaluate the IS NOT NULL checks of a filter in the order of the condition\n\n### What changes were proposed in this pull request?\r\n\r\nWith whole-stage codegen on, `FilterExec` and the `FILTER` clause of an aggregate function (`GeneratePredicateHelper.generatePredicateCode`) generate an `IsNotNull` check lazily: just before the first conjunct that references its column, or after all conjuncts. With codegen off, `And.eval` evaluates the condition in its order. So a FALSE check cannot drop a row before a later conjunct that raises on it under codegen.\r\n\r\nThis PR adds an internal config, `spark.sql.optimizer.evaluateNotNullChecksInOrder` (default `false`, version 4.5.0), that evaluates the checks in the order of the condition. With it off, the optimizer and the code generation are unchanged. With it on:\r\n\r\n- **Codegen.** `precedingNotNullChecks` (SPARK-60315) gets a second rule in `generatePredicateCode`, which generates `FilterExec`\u0027s condition with and without subexpression elimination (SPARK-61556) and the aggregate `FILTER` clause: before a conjunct whose evaluation is observable, the pending checks that precede it in the condition and can be evaluated early are generated at their position. A check that cannot keeps the lazy placement, so on a row on which it raises, a check after it can drop the row first, where codegen off raises: codegen raises less, never more, as it already does when a later conjunct drops such a row. A conjunct is observable when it can raise, is nondeterministic or calls a UDF (`mayRaise`, that is `ExprUtils.canEvaluateUnconditionally`), or when it evaluates a column that the stage computes on demand by an expression that can raise. A check can be evaluated early when it cannot raise itself and does not evaluate such a computation. `notNullCheckPlacement` decides both once per operator from the input variables. An input variable that is already evaluated is safe. A deferred one is resolved through projections (with `AliasHelper`), filters, samples and limits, to an aggregate result expression or to the input of the stage. Any other operator counts as raising, so its columns keep the previous placement. A check generated at its position makes the synthetic check on its column before the same conjunct unnecessary, so it is not generated.\r\n- **Optimizer.** `InferFiltersFromConstraints` places a predicate it infers from a filter condition just before the first conjunct at which the conjuncts so far, with the constraints of the child, imply it, instead of at the front. Only with the config, it finds the first implying prefix of each inferred predicate by a search that doubles the prefix and then halves the last range, computing the constraints of each prefix once, and rebuilds the condition as a balanced tree, as the parser builds a long chain of `AND`. So `y + 1 \u003e 0 AND x \u003e 0` becomes `isnotnull(y) AND y + 1 \u003e 0 AND isnotnull(x) AND x \u003e 0`. Its inferred check does not load `x` any earlier, and both evaluation paths follow the condition as written. For `coalesce(x, 1) + y \u003e 0 AND x \u003e 0`, where the first conjunct references `x` but does not imply `isnotnull(x)`, the placement is best effort: the plan has `isnotnull(x)` just before `x \u003e 0`, and codegen off follows it, but whole-stage codegen still generates the check on `x` before the first conjunct that references `x`, which is bound with `x` non-nullable. So on a row where `x` is NULL and the first conjunct raises, codegen off raises and codegen on drops the row; the config doc says so, and a test pins both results. No tag tells inferred checks from written ones: the position is in the plan and `EXPLAIN` shows it. The predicates inferred for a side of a join still go to a filter of their own, and the codegen generates them by position like any other check. With codegen off, an inferred check is now evaluated after the nondeterministic or UDF conjuncts before the conjunct it is inferred from, as with codegen on.\r\n\r\nThe NULL-conjunct decisions (the flag and the `afterNullable` branch, SPARK-60315) keep their previous classification, so the config does not change them. A predicate pushed down to a data source keeps its own placement: for a DSv2 source, `PushDownUtils.pushFilters` puts the translated filters back in front of the untranslatable ones after the scan, and for a DSv1 source, `DataSourceStrategy.selectFilters` puts a translated filter that the source does not handle after them.\r\n\r\nTesting only the null bit of a columnar scan column at the check\u0027s position, instead of decoding the value, is tracked in SPARK-60872. With it, the config could default to `true`.\r\n\r\n### Why are the changes needed?\r\n\r\nA query should not fail only with whole-stage codegen on (SPARK-60329). ANSI mode, Parquet filter pushdown off:\r\n\r\n```sql\r\nCREATE TABLE t USING parquet AS\r\n  SELECT * FROM VALUES (NULL, 1, 2147483647, NULL), (0, 1, 0, 1) AS v(a, b, y, x);\r\nSELECT a FROM t WHERE x IS NOT NULL AND y + 1 \u003e 0 AND x \u003e 0;\r\n-- codegen on:                                   [ARITHMETIC_OVERFLOW] overflow. SQLSTATE: 22003\r\n-- codegen on, evaluateNotNullChecksInOrder:     0\r\n-- codegen off:                                  0\r\n```\r\n\r\nThe fix decodes the checked column on every row that reaches the check, before the conjunct that can raise. A filter over 20M Parquet rows with `d DECIMAL(38, 10)`, `d IS NOT NULL AND y * 3 \u003e 1000000 AND d \u003e 5`, went from 0.88 to 2.54 relative to a control in ANSI mode. That is why the config is opt-in until SPARK-60872.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nNo, the config is off by default. With it on, an `IS NOT NULL` check that cannot raise is evaluated before a later conjunct that can raise, is nondeterministic or calls a UDF, as with codegen off. So a row that the check rejects no longer raises that conjunct\u0027s error, a `rand(seed)` conjunct runs only on the rows the check keeps, and a UDF is not called on the rows it rejects. An inferred check is evaluated just before the first conjunct on its columns, with codegen on and off, so `SELECT a FROM t WHERE y + 1 \u003e 0 AND x \u003e 0` raises with codegen off too.\r\n\r\n### How was this patch tested?\r\n\r\n`InferFiltersFromConstraintsSuite` checks the placement of the inferred predicates with the config on and off, and, with the config, that an inferred predicate goes just before the first conjunct at which the conjuncts so far imply it: after a conjunct that references its column but does not imply it, through a constraint of the child, and transitively, and that a 32-conjunct condition gets the exact placement and stays balanced. `WholeStageCodegenSuite` has three tests:\r\n\r\n- With the config, codegen on and off and `spark.sql.legacy.filterShortCircuitOnNullConjunct` on and off, with and without subexpression elimination in `FilterExec`:\r\n  - a written check with and without a later conjunct on its column;\r\n  - a check on a struct field;\r\n  - a check written after the raising conjunct, which still raises;\r\n  - the inferred check, which now raises with codegen on and off;\r\n  - the aggregate `FILTER` clause.\r\n\r\n  Without the config, the previous behavior. With the config, a check that can raise, `cast(s AS INT) IS NOT NULL`, keeps the lazy placement, while a check that cannot, `x IS NOT NULL`, written after it still moves: codegen then drops the row on which codegen off raises the cast error, so it raises less, never more. A check that `mayRaise` only because it is not declared total, `upper(s) IS NOT NULL`, does not keep a later `x IS NOT NULL` lazy.\r\n- Columns the stage computes on demand:\r\n  - an aggregate result that can raise, `sum(a) / sum(b)`, whose check keeps the lazy placement;\r\n  - one that cannot, `max(x) * 2.0D`, whose check moves;\r\n  - a raising cast alias through a sample, whose check keeps its placement;\r\n  - a scan column through a sample, through a limit and through a filter below in the same stage, whose checks move;\r\n  - a conjunct over the deferred cast, which moves the check before it;\r\n  - a shared computation over the deferred cast, with subexpression elimination in `FilterExec` on and off;\r\n  - an aggregate `FILTER` clause over a projection alias the aggregate evaluates first, whose check moves;\r\n  - the SPARK-60315 case of a check on a deferred aggregate result after a NULL conjunct, which keeps the previous result with the config on and off.\r\n- A check before a seeded `rand` conjunct, with the same rows with codegen on and off, and before a counting UDF, which is called only on the rows the check keeps.\r\n\r\nEach walk case, the evaluated-input rule, the conjunct trigger and the optimizer placement was checked by removing it and seeing a test fail. The SPARK-60315 and SPARK-51356 tests pass unchanged.\r\n\r\n```\r\nbuild/sbt \u0027catalyst/testOnly *InferFiltersFromConstraintsSuite\u0027\r\nbuild/sbt \u0027sql/testOnly *WholeStageCodegenSuite\u0027\r\n```\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-by: Claude Code (Claude Fable 5.1, Claude Opus 5.5)\r\n\r\n\r\n\r\n\r\n\nCloses #59985 from MaxGekk/SPARK-60329-isnotnull-position.\n\nAuthored-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "9c61e02033db7165467c2a3fbeca602f20cc667d",
      "tree": "f95b6eabedd9efb55fed06013a1d7749541a90c7",
      "parents": [
        "a156d5a4b12eee8c3d7979c41df62a7005735c79"
      ],
      "author": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Wed Nov 25 21:53:24 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Wed Nov 25 21:53:24 2026 +0900"
      },
      "message": "[SPARK-62022][SS] Fix NPE for a NULL window watermark column in V4 stream-stream join state\n\n### What changes were proposed in this pull request?\n\nState format V4 indexes each stored row of a stream-stream join by its event time. When the\nwatermark is on a window struct column that is not a join key, V4 reads that time from the\nstruct\u0027s `end` field, and throws `NullPointerException` when the struct is NULL. This PR keeps\nsuch a row in state without evicting it, as V2 and V3 do. A NULL timestamp event time keeps\nits existing handling.\n\n### Why are the changes needed?\n\nThe query fails on V4, while V2 and V3 return the right rows. For example, with\n`spark.sql.streaming.join.stateFormatVersion\u003d4`:\n\n```scala\nval lt \u003d timestamp_seconds($\"t\")\nval left \u003d leftInput.toDF().toDF(\"lk\", \"t\")\n  .select($\"lk\", $\"t\", when($\"t\" \u003e\u003d 0,\n    struct(lt.as(\"start\"), (lt + expr(\"INTERVAL 10 SECONDS\")).as(\"end\"))).as(\"lw\"))\n  .withWatermark(\"lw\", \"10 seconds\")\nval right \u003d rightInput.toDF().toDF(\"rk\", \"s\")\nleft.join(right, expr(\"lk \u003d rk\")).select($\"lk\", $\"t\", $\"lw\".isNull, $\"s\")\n// left rows (1, -1) and (1, 5), then right row (1, 7)\n```\n\n- Before: the query fails with `NullPointerException` in\n  `SymmetricHashJoinStateManagerV4.extractEventTimeFn` when it stores the left row `(1, -1)`.\n- After: `(1, -1, true, 7)` and `(1, 5, false, 7)`, as on V2 and V3.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, for state format V4 only (internal, off by default): the query no longer fails. No state\nlayout change.\n\n### How was this patch tested?\n\nNew test in `StreamingInnerJoinBase`, so it runs on V2, V3 and V4.\nWithout the fix, it fails on V4 with the `NullPointerException` and passes on V2 and V3.\n\nOut of scope: a side whose watermark is on a window outside the join keys can get a cutoff only\nfrom a range on another column, and V2 to V4 then evict non-NULL rows that can still match.\nSPARK-61988 (#60667) evicts by the bounded column.\n\n### Note for reviewers, including AI review\n\nPlease review only this PR\u0027s own commit(s). For each finding, give a runnable reproducer and\nsay whether master has the same behavior.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\n\n\n\nCloses #60701 from HeartSaVioR/jungtaek-lim_data/f-62022-v4-value-null.\n\nAuthored-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "a156d5a4b12eee8c3d7979c41df62a7005735c79",
      "tree": "e5726ad87148d3e8a5097f8b325bc8eaf6d2f550",
      "parents": [
        "47d2f3575a2bc128d8fd0a54ca18854dc7215a3e"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Wed Nov 25 12:47:08 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 12:47:08 2026 +0000"
      },
      "message": "[SPARK-62246][SQL] Make a DataFrame as-of join with using columns return one key column\n\n### What changes were proposed in this pull request?\n`Dataset.joinAsOf` with `usingColumns` now builds an `AsOfJoin` with `usingColumns` set, the same node that SQL `ASOF JOIN ... USING` builds. Both analyzers already expand it, so the output has one column per name, placed first, as in SQL.\nIt used to turn each name into `left(name) \u003d\u003d\u003d right(name)`, which kept the key of both sides.\nSpark Connect and PySpark `_joinAsOf` call `Dataset.joinAsOf`, so they change too. A migration guide line is added.\n\n```\njoinAsOf(quotes, ts, ts, usingColumns \u003d Seq(\"sym\"))\nbefore: ts, sym, qty, ts, sym, bid   (select(\"sym\") fails with AMBIGUOUS_REFERENCE)\nafter:  sym, ts, qty, ts, bid        (same as SQL ASOF JOIN quotes ... USING (sym))\n```\n\n### Why are the changes needed?\nThe DataFrame API and SQL gave different columns for the same join, and the key could not be selected by name.\n\n### Does this PR introduce _any_ user-facing change?\nYes, for the private DataFrame as-of join (`DataFrame._joinAsOf` in PySpark, and Spark Connect) when `on` is a column name or a list of names. The output has one key column per name instead of two. There is no switch for the old output. The key keeps the type of the left side, and names are matched against top-level columns as in a regular USING join (a nested, quoted or metadata name now fails). A name missing on either side now fails with `UNRESOLVED_USING_COLUMN_FOR_JOIN`, not `UNRESOLVED_COLUMN`. The inputs\u0027 metadata columns (such as `_metadata`) can no longer be selected after the join, as after a regular USING join. A join with a Column for `on`, and `pandas.merge_asof`, are not changed.\n\n### How was this patch tested?\n- `DataFrameAsOfJoinSuite`: columns, schema and rows equal SQL `ASOF JOIN ... USING` for INNER and LEFT, one and two keys. Also select/filter/group by the key, an unmatched LEFT row and a NULL key, a self join, a missing name (`UNRESOLVED_USING_COLUMN_FOR_JOIN`), tolerance and direction against the rows of the Column-condition join. Each test runs with the fixed-point and single-pass analyzers, the sort-merge flag off and on, and ANSI on and off.\n- Also: qualified access to the right key, INT vs BIGINT and STRING keys against SQL USING, case sensitivity, a nested field name.\n- `SparkConnectProtoSuite`: a Connect as-of join with `using_columns` returns one key column, resolves plan-id keys with rows, with both analyzers.\n- `StreamingAsOfJoinSuite`: a stream-static DataFrame join with using columns.\n- Existing ASOF, join and codegen suites, with expected rows updated for the new column order.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60796 from LukaZdravic/asof-df-using-columns.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "47d2f3575a2bc128d8fd0a54ca18854dc7215a3e",
      "tree": "d383f9c23fd85438aa32991be1562dc72241aca5",
      "parents": [
        "57abf2151aff45cbbdf219b57aa728ace8afbc84"
      ],
      "author": {
        "name": "Holden Karau",
        "email": "holden@pigscanfly.ca",
        "time": "Wed Nov 25 09:21:54 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 09:21:54 2026 +0000"
      },
      "message": "[SPARK-59546][SQL][FOLLOWUP] Preserve TimeType parsing and inference semantics after SPARK-59546\n\n### What changes were proposed in this pull request?\n\nSPARK-59546 added a non-throwing `TimeFormatter.parseOptional` and switched JSON, CSV and XML schema inference to it. That changed behavior in two ways, which this PR fixes:\n\n1. `Iso8601TimeFormatter.parseOptional` built the time from the *unresolved* result of `DateTimeFormatter.parseUnresolved`, skipping the resolver. Clock-hour and AM/PM fields (`hh`, `KK`, `kk`, `a`) were therefore not resolved or validated like `parse` does, so for example `timeFormat \u003d \"hh:mm:ss\"` inferred `17:30:01` as TIME although `parse` rejects it. `parseOptional` now parses once with `formatter.toFormat.parseObject(s, ParsePosition)` (which resolves fields and reports failure without throwing), still requiring the whole input to be consumed, and converts the resolved result.\n2. The inference probe used to be `allCatch opt timeFormatter.parse(field)`, which also caught an exception from the lazy construction of the formatter for an unusable `timeFormat` (e.g. `\"EEE HH:mm\"`). With `timeFormatter.parseOptional(field)` that exception escaped and broke inference (a failed query or a corrupt record). The formatter is now built as `allCatch opt TimeFormatter(...)`, and TIME is skipped when it cannot be built.\n\n### Why are the changes needed?\n\nTo keep `parseOptional` equivalent to `parse` and keep schema inference results the same as before SPARK-59546, as that PR intended.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, compared to the last release. It fixes an unreleased behavior change from SPARK-59546.\n\n### How was this patch tested?\n\nNew tests in `TimeFormatterSuite`, `CSVInferSchemaSuite`, `JsonInferSchemaSuite`, `XmlInferSchemaTypeCastingSuite`, `CSVSuite`, `JsonSuite` and `XmlSuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Opus 5.5)\n\nCloses #60687 from holdenk/SPARK-59546-master-followup.\n\nLead-authored-by: Holden Karau \u003cholden@pigscanfly.ca\u003e\nCo-authored-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "57abf2151aff45cbbdf219b57aa728ace8afbc84",
      "tree": "9c4ec7f32eee6dff0b5beea18a3ad549ed83a1d2",
      "parents": [
        "856cc77d6fe94d229b84fa72c5c526142b949c39"
      ],
      "author": {
        "name": "Varun Gandhi",
        "email": "varun.gandhi@databricks.com",
        "time": "Wed Nov 25 09:17:44 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 09:17:44 2026 +0000"
      },
      "message": "[MINOR][INFRA] Discourage agents from committing large binaries\n\n### What changes were proposed in this pull request?\n\nAdd one rule to the Code Standards section of the root `AGENTS.md`: avoid committing large binaries\nsuch as test archives, check their combined size, and ask the user before adding an exception.\n\n### Why are the changes needed?\n\nAgents that run benchmarks or generate test data tend to commit the outputs along with the code.\nEach archive can look small, but together they can add hundreds of MiB, and once pushed they stay in\nthe history of the fork and every clone of it. We saw this on an internal fork, where an agent\ncommitted about 100 generated `.tar.xz` archives totalling over 280 MiB.\n\nThe rule asks for a size check and user confirmation rather than banning binaries, since some test\nfixtures are intentionally binary.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Documentation for contributors and agent tooling only.\n\n### How was this patch tested?\n\n`dev/agent_docs_lint.py --strict` passes with no errors or warnings. The root `AGENTS.md` goes from\n6951 to 7078 bytes.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Cursor (Claude Opus 5.5)\n\nCloses #60878 from varungandhi-databricks/agents-avoid-large-binaries.\n\nAuthored-by: Varun Gandhi \u003cvarun.gandhi@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "856cc77d6fe94d229b84fa72c5c526142b949c39",
      "tree": "0bef1e3ad65a09a720437e5dba7d66eb15473024",
      "parents": [
        "b26408b3de1ec34204aa963ac38b966aa77b52ca"
      ],
      "author": {
        "name": "Ganesha S",
        "email": "ganeshashree2@gmail.com",
        "time": "Wed Nov 25 08:26:58 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 08:26:58 2026 +0000"
      },
      "message": "[SPARK-62261][SQL] Remove stale query column names when syncing a SCHEMA EVOLUTION view\n\n### What changes were proposed in this pull request?\n\nWhen a read finds that the table under a `SCHEMA EVOLUTION` view changed, `ViewSyncSchemaToMetaStore` rewrites the view schema. This PR also removes the view\u0027s stored query column names (`view.query.out.*`) in that same write. EVOLUTION views don\u0027t use them, and names written by Spark 4.0 no longer match the new schema.\n\n### Why are the changes needed?\n\nSince SPARK-52417, the sync keeps these old names. A later `ALTER VIEW ... WITH SCHEMA \u003cmode\u003e` copies them into the new mode, and the view then returns swapped columns or fails:\n\n```sql\nCREATE TABLE sales (gross DOUBLE, net DOUBLE) USING parquet;\nCREATE VIEW sales_v WITH SCHEMA EVOLUTION AS SELECT * FROM sales;\n-- Stand-in for the names Spark 4.0 stores:\nALTER VIEW sales_v SET TBLPROPERTIES (\n  \u0027view.query.out.numCols\u0027 \u003d \u00272\u0027, \u0027view.query.out.col.0\u0027 \u003d \u0027gross\u0027, \u0027view.query.out.col.1\u0027 \u003d \u0027net\u0027);\nDROP TABLE sales;\nCREATE TABLE sales (net DOUBLE, gross DOUBLE) USING parquet;\nINSERT INTO sales VALUES (80.0, 100.0);\nSELECT gross, net FROM sales_v;          -- 100.0, 80.0\nALTER VIEW sales_v WITH SCHEMA BINDING;\nSELECT gross, net FROM sales_v;          -- before: 80.0, 100.0 (swapped); after: 100.0, 80.0\n```\n\nSPARK-62259 (#60800) handles stale names whose count differs from the schema at ALTER time. This PR stops the sync from keeping stale names.\n\nNotes for reviewers:\n- The sync still writes only when the schema changed, so there is no new write on read. That write now also removes these names when the view has them, which SPARK-52417 avoided so that readers need fewer permissions. An alternative is to resolve the names at ALTER time by analyzing the view query.\n- Views already synced by an affected version keep their stale names, since their reads need no sync. A view that `ALTER VIEW ... WITH SCHEMA` has already switched with those names returns swapped columns or fails until it is recreated, redefined with `ALTER VIEW ... AS`, or switched back to `WITH SCHEMA EVOLUTION`.\n- Since the sync no longer keeps these names, this PR removes a #60800 test that relied on it; the new tests here cover a sync followed by an ALTER. It also removes the `TODO(SPARK-62261)` that #60800 added for this case, as suggested in its review.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. In the example above, the view returns correct values after the ALTER instead of swapped ones. Other views behave as before, including all SCHEMA EVOLUTION views created by Spark 4.1 or later, which don\u0027t store these names.\n\n### How was this patch tested?\n\nNew tests in `SQLViewSuite`, run with both the in-memory and Hive catalogs: after a column reorder or a new column, the sync removes stale names (these fail without the fix) and a later ALTER returns correct values; a read with no schema change keeps the names; a TYPE EVOLUTION view keeps its names.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60803 from ganeshashree/SPARK-62261.\n\nLead-authored-by: Ganesha S \u003cganeshashree2@gmail.com\u003e\nCo-authored-by: Ganesha S \u003cganesha.s@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b26408b3de1ec34204aa963ac38b966aa77b52ca",
      "tree": "98ab0be1ed9accab9eee91a61b093fe81799efaa",
      "parents": [
        "77faec6fef44d7bb698763b9318bbc01ca8141f0"
      ],
      "author": {
        "name": "Xinyao Zhang",
        "email": "43081360+zhangxinyao88@users.noreply.github.com",
        "time": "Wed Nov 25 14:01:18 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Wed Nov 25 14:01:18 2026 +0800"
      },
      "message": "[SPARK-60538][PYTHON][TEST] Guard optional dependencies in Python tests\n\n### What changes were proposed in this pull request?\n\nAdd dependency guards to the Arrow and pandas cases in `PythonWorkerEnvMixin`, preserving the regular Python worker tests. Move pandas and pandas-dependent helper imports in `test_tws_tester.py` behind the existing pandas availability check.\n\n### Why are the changes needed?\n\nThe Python 3.15 CI image omits pandas and PyArrow. In [this run](https://github.com/apache/spark/actions/runs/40032262075), the worker-environment suite reports 10 errors and the streaming tester fails during import, before its class-level skip can apply. Two Arrow-specific worker tests also silently fall back to regular Python execution when their dependencies are missing.\n\nThese failures affect two test shards in the README-linked Python 3.15 workflow. This patch addresses the missing-dependency failures; it does not address the separate pandas 3 workflow failure.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Test-only changes.\n\n### How was this patch tested?\n\n- Reproduced the upstream streaming tester\u0027s missing-pandas import failure on Python 3.15.0rc1.\n- On Python 3.15.0rc1 without pandas or PyArrow, verified that all 12 dependent worker cases and all 60 streaming tester cases skip cleanly. Verified that the remaining 17 worker cases stay enabled; their Spark execution was not run.\n- On Python 3.12, checked imports and skip selection with both dependencies present, either one missing, and both missing. All worker cases remain enabled when both dependencies are present.\n- Passed Ruff 0.14.8 lint and formatting checks, and `git diff --check`.\n\nFull Spark suites and the Linux Python 3.15 workflow were not run locally.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex (GPT-6)\n\nJIRA: [SPARK-60538](https://issues.apache.org/jira/browse/SPARK-60538)\n\nCloses #59773 from zhangxinyao88/codex/python315-test-dependency-guards.\n\nAuthored-by: Xinyao Zhang \u003c43081360+zhangxinyao88@users.noreply.github.com\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n"
    },
    {
      "commit": "77faec6fef44d7bb698763b9318bbc01ca8141f0",
      "tree": "af957c14aac4490bf40e47176554311c7dae6851",
      "parents": [
        "a06dd8d667f08bf879256efb99f4dfa71c6524fc"
      ],
      "author": {
        "name": "Sem",
        "email": "ssinchenko@apache.org",
        "time": "Wed Nov 25 13:48:34 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Wed Nov 25 13:48:34 2026 +0800"
      },
      "message": "[SPARK-62131][GRAPH] GraphCheckpointer and implementations\n\n### What changes were proposed in this pull request?\nAn internal abstraction `GraphCheckpointer` and two implementations:\n\n1. `persist` based\n2. `parquet` based\n\nThis is a core part of the future \"pregel-loop\" and the main way to make it really fast (much faster than what GraphFrames can provide today).\n\n#### Context\n\nPregel loop looks like:\n\n- create triplets by joining vertex state to edges\n- from each triplet generate message(-s)\n- group messages by target\n- aggregate\n- join aggregated messages to vertex state and update it\n\nSo, as one may see, `edges` are joined on each iteration by the same key. At the same time, for most of the cases edges is like x5-20 times bigger than vertex state.\n\nAs an example, let\u0027s take `graph500-30` from the LDBC Graphalytics dataset. It has 447M vertices and 17B edges. Let\u0027s imagine we want to compute LabelPropagation, so the vertex state is just one `currentLabel` of the same type as vertexId (assume `LONG`). So, edges will have (raw) size 17B x 8 x 2 (17B of edges, each has `srcId: Long` and `dstId: Long`) ~\u003d 253 GB. Vertex state in this case is (raw) 447M * 8 * 2 (447M vertices, `vertexId: Long` and `currentLabel: Long`) ~\u003d 6.7 GB.\n\nOne may already see, that the sort+exchange on edges side is the biggest cost of iteration. The proposed `GraphCheckpointer` solves this. Both of its implementations allow to persist/write edges in a way so on each join both `Sort` and `Exchange` are skipped (see `private def checkPartitionedLayout` in tests and how does it check the plan).\n\n### Why are the changes needed?\nIt is a part of the SPARK-61746\n\n### Does this PR introduce _any_ user-facing change?\nThe proposed API is internal.\n\n### How was this patch tested?\n- scalatest\n- manual analysis of resulted plans for different options (not part of the PR)\n- minimal spike + micro-bench (not part of the PR)\n\n### Was this patch authored or co-authored using generative AI tooling?\nClaude Code (Opus 5.5)\n\nCloses #60818 from SemyonSinchenko/SPARK-62131-gf-iterative-checkpointer.\n\nAuthored-by: Sem \u003cssinchenko@apache.org\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "a06dd8d667f08bf879256efb99f4dfa71c6524fc",
      "tree": "bb134b513f74b5f6e4c6dc35b8a36718044b100e",
      "parents": [
        "5b215eb6713791ec5420f0b2d0f2778a22b14de0"
      ],
      "author": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 05:20:40 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 05:20:40 2026 +0000"
      },
      "message": "[MINOR][INFRA] Add agent rules for tests, license headers and API compatibility, and move procedures out of the root AGENTS.md\n\n### What changes were proposed in this pull request?\n\nThis PR adds rules to the agent docs for four failures that show up only after an agent\u0027s work is done, and moves two procedures out of the root `AGENTS.md`. Both follow the placement rule the agent docs state: keep a rule in `AGENTS.md` if most tasks need it, or if an agent could break it without noticing it is in that situation; otherwise put it in `.agents/` behind a pointer that starts with its trigger.\n\n**New rules in the root `AGENTS.md`** (most changes write a test or add a file, and nothing in the code tells an agent about these):\n- **Pin the configs a test\u0027s assertions depend on**: runtime SQL configs with `withSQLConf` (`self.sql_conf` in Python), static SQL and core configs in the suite\u0027s conf (`sparkConf` in `SharedSparkSession` suites, `conf` in `SharedSparkContext` suites, `conf()` in Python). Scheduled jobs rerun the suites with other defaults set through env vars: Non-ANSI (`SPARK_ANSI_SQL_MODE\u003dfalse`), UDS (`PYSPARK_UDS_MODE\u003dtrue`), JDK codegen (`SPARK_CODEGEN_COMPILER\u003djdk`) and RocksDB UI (`LIVE_UI_LOCAL_STORE_DIR\u003d\u003cdir\u003e`). The RocksDB UI job keeps the live UI store on disk with no config to switch it back, so a UI or listener test must pass with either store. When a result differs by ANSI mode and both matter, the test asserts both modes instead of pinning one. To check, rerun the suite with the job\u0027s env var set.\n- **Never remove, skip or weaken a failing test, or mock the code under test, unless asked.** Weakening includes `ignore`, `assume(false)`, `unittest.skip`, and an expected value or golden file updated just to match. Each new mock is explained in a code comment.\n- **Every new text file that `dev/.rat-excludes` does not already match needs the Apache License header**, after the `#!` line of an executable script. The file\u0027s patterns already cover Markdown, SQL, JSON, text, CSV and similar types, and RAT skips binary files. A text file that cannot carry a header, such as test data, gets a `dev/.rat-excludes` entry that matches no other file or directory name, since RAT matches each entry against bare names anywhere in the tree and skips a matching directory with everything under it.\n\n**Binary compatibility, in `.agents/code-conventions.md`** (read when changing Scala, Java or Python code): keep binary compatibility, including Scala `private[spark]` and other `private[...]` members of public classes, which compile to public bytecode. `dev/mima` keeps its exclusions in `project/MimaExcludes.scala`. `dev/connect-jvm-client-mima-check` compares the Connect Scala client with the `sql` module and keeps its exclusions in `CheckConnectJvmClientCompatibility.scala`. Which `MimaExcludes` section an entry goes in stays with `.agents/versioning.md`, which the root already routes version questions to. That file now says a MiMa exclusion alone does not make a change master-only: most are for changes a minor release may ship.\n\nThe root pointer to `.agents/code-conventions.md` now fires when changing Scala, Java or Python code, not only before committing, since the file holds rules an agent needs while writing code.\n\n**Moved out of the root `AGENTS.md`**, each behind a pointer:\n- How to write agent docs and run `dev/agent_docs_lint.py` -\u003e `.agents/agent-docs.md`. The root keeps that agent instructions go in `AGENTS.md` or `.agents/`, so an agent asked to add instructions does not write a tool-specific file instead, and points to the file before adding or editing them.\n- PR title and `[FOLLOWUP]` rules -\u003e the top of `.agents/pr-workflow.md`, which the root already sends agents to before creating a PR or writing its description, and now also its title. The JIRA ticket step there now applies only when creating a PR whose title needs a JIRA ID, so asking for a title alone does not create a ticket, and a `[FOLLOWUP]` takes the earlier PR\u0027s ID instead of a new ticket.\n\nThe pre-flight checks stay in the root, since most tasks need them. The docstring of `dev/agent_docs_lint.py` now names `.agents/agent-docs.md`, which holds the pairing rule.\n\nThe rules say what to write. They do not ask agents to run the license check or MiMa locally, which are slow; CI runs them.\n\n### Why are the changes needed?\n\nEach new rule prevents a failure that shows up only after the agent\u0027s work is done:\n- A test that relies on a default passes in PR CI and fails later in a scheduled job that changes that default, after the PR has merged.\n- Removing, skipping or weakening a failing test, or mocking the code under test, makes CI green without fixing anything, and reviewers have to catch it.\n- A new text file without the license header, of a type `dev/.rat-excludes` does not match, fails the license check in the Linters job.\n- An intended API change without an exclusion in the right file and section fails MiMa or the Connect JVM client check, on master or after the backport.\n\nThe moves keep the root to what most tasks need. Every agent reads it in full on every task, and Codex loads it into the 32 KiB budget of every root-to-directory chain.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Only agent documentation changes.\n\n### How was this patch tested?\n\n- `dev/agent_docs_lint.py --strict` passes with no errors or warnings. The root `AGENTS.md` goes from 6637 bytes on master to 6951 bytes, under its 8 KiB target.\n- Checked the facts the rules rely on: `build_non_ansi.yml`, `build_uds.yml`, `build_codegen_jdk.yml` and `build_rockdb_as_ui_backend.yml` set `SPARK_ANSI_SQL_MODE\u003dfalse`, `PYSPARK_UDS_MODE\u003dtrue`, `SPARK_CODEGEN_COMPILER\u003djdk` and `LIVE_UI_LOCAL_STORE_DIR`. `SQLConf` and `pyspark.testing.utils` read `SPARK_ANSI_SQL_MODE`. `spark.ui.store.path` is optional with no in-memory value, and `AppStatusStore.createLiveStore` falls back to the `LIVE_UI_LOCAL_STORE_DIR` env var when it is unset. `sparkConf` is defined in `SparkSessionBinder`, which `SharedSparkSession` suites use, and `SharedSparkContext` has `conf`. RAT 0.16.1 skipped a binary file and, for an entry `stat`, a directory named `stat` anywhere in a test tree. `dev/.rat-excludes` has the patterns `.*md`, `.*\\.sql`, `.*\\.json`, `.*\\.txt`, `.*\\.csv`, `.*\\.tsv`, `.*\\.data` and `.*out`. The `v44excludes` entries for new APIs are `ReversedMissingMethodProblem` filters for abstract members of `Dataset` and `TableValuedFunction`. The Linters job runs `dev/check-license`, `dev/mima` and `dev/connect-jvm-client-mima-check`. `CheckConnectJvmClientCompatibility.scala` has `checkMiMaCompatibilityWithSqlModule` and `checkMiMaCompatibilityWithReversedSqlModule`. `MimaExcludes.excludes` maps master\u0027s 5.0 and `branch-4.x`\u0027s 4.5 to separate sections.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\n\n\nCloses #60670 from cloud-fan/agents-md-more-rules.\n\nAuthored-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "5b215eb6713791ec5420f0b2d0f2778a22b14de0",
      "tree": "c0a2a6b8ec973766f72d6d6225609a11ec14e912",
      "parents": [
        "32ac15d5c6f618a550a0050ab474226905a0f729"
      ],
      "author": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 04:48:54 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 04:48:54 2026 +0000"
      },
      "message": "Revert \"[SPARK-55014][SQL] Split projection for expensive filters\"\n\n### What changes were proposed in this pull request?\n\nThis reverts #58403 (SPARK-55014) and its follow-up #60441, as proposed in https://github.com/apache/spark/pull/58403#issuecomment-7031246335. They are on master, branch-4.x and branch-4.4 and in no release, so this should go to all three.\n\nA plain `git revert` no longer applies because later changes build on this code, so the revert is done by hand:\n\n- `PushPredicateThroughNonJoin` no longer splits a projection around the filters on its expensive aliases. For a filter over such a projection, it does what it did with `spark.sql.optimizer.splitProjectionForExpensiveFilters\u003dfalse`: it pushes the cheap conditions below the projection and keeps the others above it, in the order they were written. `splitProjectForExpensiveConditions` and the config are removed.\n- The later changes to that path stay: `splitPushable` (SPARK-60602, SPARK-60633) and `isExpensive` (SPARK-60632, SPARK-60905).\n- The tests of the split are removed, including the SPARK-60602 and SPARK-60632 cases that only tested the split. The tests that ran with the config on and off now run once. `AnalysisConfOverrideSuite` used this config as its example of a `NOT_APPLICABLE` config and now uses `spark.sql.optimizer.insertMapSortInDistinctAggregates.enabled`.\n\n### Why are the changes needed?\n\nIt was merged without an approving review, and it can return wrong results. On master:\n\n```scala\nval f \u003d udf((i: Long) \u003d\u003e i)\nval g \u003d udf((i: Long) \u003d\u003e i)\nspark.range(0, 10, 1, 1)\n  .select($\"id\", f($\"id\") as \"f\", g($\"id\") as \"g\")\n  .where($\"f\" \u003e 2 \u0026\u0026 $\"g\" \u003e 5 \u0026\u0026 (monotonically_increasing_id() \u003c 3 || $\"f\" \u003e 100))\n```\n\nreturns no rows instead of 6, 7 and 8. The split keeps the non-deterministic condition above the top projection. But the alias it reads is then computed in a lower layer, so the next run of `PushPredicateThroughNonJoin` pushes it below the top projection, ahead of `g \u003e 5`, which is written before it. The linked comment has the plan.\n\nThe open PRs #60772 and #60351 change the split, so they would not be needed after this. #60766 and #59940 change the conditions pushed below the projection, which this keeps.\n\nThis does not change the SPARK-47672 path, so a cheap non-deterministic condition is still pushed ahead of an expensive one written before it: `.select($\"id\", g($\"id\") as \"g\").where($\"g\" \u003e 5 \u0026\u0026 monotonically_increasing_id() \u003c 3)` still returns no rows. That needs a separate fix.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, compared with the released versions: SPARK-55014 is in no release. Compared with master, branch-4.x and branch-4.4, `spark.sql.optimizer.splitProjectionForExpensiveFilters` is removed, and a filter over expensive projected expressions is no longer split into layers of projections and filters.\n\n### How was this patch tested?\n\nExisting tests that cover this rule or used the config, all passing locally:\n\n- `catalyst/testOnly org.apache.spark.sql.catalyst.optimizer.*`: 1713 passed.\n- `sql/testOnly` of `DataFrameSuite`, `WholeStageCodegenSuite`, `AnalysisConfOverrideSuite`, `BloomFilterAggregateQuerySuite`, `PerPartitionRuntimeFilterSuite`, `StreamingQueryManagerSuite`, `StreamingV2ScanPushDownSuite`, `OffsetSeqLogSuite`, `PythonUDFSuite` and the TPC-DS and TPC-H `*PlanStabilitySuite`s: 818 passed. 20 Python tests of `PythonUDFSuite` were canceled, because the local environment has no PySpark test setup. No golden file changes.\n\nWith this change, the query above returns 6, 7 and 8, with whole-stage codegen on and off.\n\nThe commit also applies cleanly to branch-4.x and branch-4.4.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60801 from cloud-fan/revert-SPARK-55014.\n\nAuthored-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "32ac15d5c6f618a550a0050ab474226905a0f729",
      "tree": "bccd1012420225106c581a3a8879aa8bd0405bf9",
      "parents": [
        "c53348f71777c07857dedc8b01ad8526218901d1"
      ],
      "author": {
        "name": "Cheng Pan",
        "email": "pan3793@gmail.com",
        "time": "Wed Nov 25 10:17:13 2026 +0800"
      },
      "committer": {
        "name": "Cheng Pan",
        "email": "chengpan@apache.org",
        "time": "Wed Nov 25 10:17:13 2026 +0800"
      },
      "message": "[SPARK-62327][SQL][TEST] Map TPC-DS Identifier columns to BIGINT in TPCDSSchema\n\n### What changes were proposed in this pull request?\n\n1. Map all 127 TPC-DS `Identifier` columns (`*_sk`, `*_ticket_number`, `*_order_number`, and `c_last_review_date`) from `INT` to `BIGINT` in `TPCDSSchema`, and update its scaladoc datatype mapping table.\n2. Update `avgLen` and `maxLen` in `TPCDSTableStats` from 4 bytes to 8 bytes for the corresponding SF100 `Identifier` column stats.\n3. Regenerate affected golden files:\n   - TPC-DS plan stability golden files (`sql/core/src/test/resources/tpcds-plan-stability/`) under both ANSI and non-ANSI modes. Aside from type updates, the wider 8-byte `BIGINT` keys and stats cause the following expected plan-shape changes:\n     - 6 SF100 plans switch a broadcast hash join to a sort-merge join due to larger estimated relation sizes: v1.4 `q36`, `q86`; v2.7 `q18a`, `q36a`, `q86a`; modified `q68`.\n     - 2 SF100 plans reorder joins under CBO: v1.4 `q76`, `q85`.\n     - 15 plans no longer pack two `INT` join keys into a single `BIGINT` via `HashJoin.rewriteKeyExpr`: v1.4 `q5`, `q17`, `q25`, `q29`, `q39a`, `q39b`, `q49`, `q64`, `q72`, `q85`; v2.7 `q5a`, `q24.sf100`, `q49`, `q64`, `q72`.\n   - TPC-DS query result golden files (`sql/core/src/test/resources/tpcds-query-results/`).\n   - `sql/core/src/test/resources/sql-tests/results/pipe-operators.sql.out`.\n\n### Why are the changes needed?\n\n1. **TPC-DS specification requirement**: Section 2.2.2.1 a) of the [TPC-DS v4.0.0 Specification](https://www.tpc.org/tpc_documents_current_versions/pdf/tpc-ds_v4.0.0.pdf) defines `Identifier` as a column able to hold any key value generated for that column, and Section 2.2.2.2 explicitly states that the abstract types do not correspond to fixed SQL keywords and that benchmark implementers should pick a concrete SQL type meeting those requirements for the target scale factor. While the official toolkit\u0027s reference `tpcds.sql` template uses `integer` (including through TPC-DS v4.0.0), it is only a baseline template and does not satisfy Section 2.2.2.1 a) at large scales.\n2. **Historical context in Spark**: SPARK-34944 unified `store_returns` and `web_returns` from `BIGINT` to `INT` to stay consistent with `tpcds.sql` when `TPCDSBase` was only used for SF1/SF100 unit and plan stability tests. SPARK-35192 later extracted `TPCDSSchema` and reused it in `GenTPCDSData`.\n3. **Overflow at SF10000+**: Starting at SF10000, generated order and ticket numbers exceed `Int.MaxValue` (`2,147,483,647`):\n   - `store_sales.ss_ticket_number` / `store_returns.sr_ticket_number`: up to 2.4B at SF10000 (24B at SF100000).\n   - `catalog_sales.cs_order_number` / `catalog_returns.cr_order_number`: up to 4.8B at SF30000 (16B at SF100000).\n   - `web_sales.ws_order_number` / `web_returns.wr_order_number`: up to 6B at SF100000.\n\n   With `Identifier` mapped to `INT`, generating SF10000+ datasets via `GenTPCDSData` fails with `CAST_INVALID_INPUT` under ANSI mode (the default in Spark 4+) or silently writes `NULL` under non-ANSI mode.\n4. **Large-scale reference for Spark users**: Spark is designed for large-scale workloads. Although Spark\u0027s own unit tests only exercise up to SF100, `TPCDSSchema` and `GenTPCDSData` are commonly used as a reference by users generating and running large-scale TPC-DS benchmarks (SF10000+) on Spark clusters. Keeping `Identifier` as `INT` is a misleading reference that breaks at those scales; mapping `Identifier` uniformly to `BIGINT` works cleanly across all TPC-DS scale factors up to SF100000.\n\nNote: GitHub Actions (`build_and_test.yml` and `benchmark.yml`) already hash `TPCDSSchema.scala` into the `tpcds-sf-1` cache key, so CI will automatically regenerate cached SF1 Parquet data.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, test-only changes.\n\n### How was this patch tested?\n\n1. Regenerated and verified all TPC-DS plan stability suites in both ANSI and non-ANSI modes:\n```shell\nbuild/sbt \"sql/testOnly *TPCDSQuerySuite *TPCDSQueryWithStatsSuite *TPCDSQueryANSISuite *TPCDS*PlanStability*Suite\"\nSPARK_ANSI_SQL_MODE\u003dfalse build/sbt \"sql/testOnly *TPCDS*PlanStability*Suite\"\n```\n2. Regenerated and verified `pipe-operators.sql`:\n```shell\nbuild/sbt \"sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z pipe-operators.sql\"\n```\n3. Generated SF1 TPC-DS data with `GenTPCDSData` and `databricks/tpcds-kit` `dsdgen`, regenerated `tpcds-query-results` via `TPCDSQueryTestSuite` (135/135 queries), and verified `TPCDSQueryTestSuite` (`q34`, `q64`) across all 3 join configs and `TPCDSCollationQueryTestSuite` (`q30`).\n4. Ran `build/sbt sql/Test/scalastyle`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Gemini 4 Neon\n\nCloses #60845 from pan3793/tpcds-identifier-bigint.\n\nAuthored-by: Cheng Pan \u003cpan3793@gmail.com\u003e\nSigned-off-by: Cheng Pan \u003cchengpan@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "c53348f71777c07857dedc8b01ad8526218901d1",
      "tree": "a33ce6c3b1e0cd6b8e7f5c8057ac5e261b25b625",
      "parents": [
        "b656c32c097d73e41b5ead26732d66fc3d857024"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Wed Nov 25 02:00:49 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Wed Nov 25 02:00:49 2026 +0000"
      },
      "message": "[SPARK-62247][SQL] Use the cursor scan for ASOF joins with a tolerance\n\n### What changes were proposed in this pull request?\n`SortMergeAsOfJoinExec` took its one-pass cursor scan only when the as-of condition was one comparison and there was no residual condition. A tolerance comes in one of two forms, and both took the buffered scan:\n- A DataFrame `joinAsOf` with `tolerance` builds the as-of condition `l \u003e\u003d r AND r \u003e\u003d l - tolerance` (forward: `l \u003c\u003d r AND r \u003c\u003d l + tolerance`).\n- A SQL ASOF JOIN writes the bound in ON, `MATCH_CONDITION (t.ts \u003e\u003d q.ts) ON t.k \u003d q.k AND q.ts \u003e\u003d t.ts - 1000`. The bound becomes the residual condition.\n\nNow backward and forward joins take the bound from either place, in both the interpreted and the generated scan. The cursor moves on the comparison of the keys alone, the same as a join without a tolerance. The bound is checked only on the closest right row: every other row that passes the comparison is at least as far from the left key, so it fails the bound whenever the closest row does.\n\n`supportsCursorScan` takes the bound only when its right key is a column and comes first, and its limit is the left key, or the left key plus or minus a constant (`+`, `-`, or a DATE or TIMESTAMP add). In the as-of condition the bound must follow the comparison. In ON it must be the whole residual condition. Strict and inclusive forms are accepted. These keep the buffered scan: nearest joins, a residual with another condition, a bound in both places, a bound that keeps rows far enough away (`q.ts \u003c\u003d t.ts - 1000`, where the closest row can fail while a farther row passes), a bound written limit first or as a distance, and a bound that casts or computes the right key. There is no new config: the internal `spark.sql.join.sortMergeAsOfJoin.cursorScan.enabled` (default `true`) still turns the cursor scan off.\n\n### Why are the changes needed?\nThe buffered scan reads the right key group again from its start for every left row, so its cost grows with the square of the group size.\n```sql\nSELECT count(*) FROM l LEFT ASOF JOIN r\n  MATCH_CONDITION (l.lt \u003e\u003d r.rt) ON l.lk \u003d r.rk AND r.rt \u003e\u003d l.lt - 1000\n```\nOne key group, 80,000 rows per side, `local[4]`, median of 3 runs, before (cursor scan off) and after: SQL backward 15.0 s and 0.08 s, forward 10.5 s and 0.07 s. DataFrame `tolerance \u003d lit(1000L)`: backward 11.6 s and 0.09 s, forward 10.6 s and 0.09 s. With 20,000 rows, SQL backward takes 0.96 s before and 0.06 s after.\n\n### Does this PR introduce _any_ user-facing change?\nNo. The rows, NULL handling and errors stay the same. Only the speed and two metrics change: `number of cursor scan tasks` now counts these joins, and their `spill size` is 0, since the cursor scan keeps no right rows.\n\n### How was this patch tested?\n- `SortMergeAsOfJoinScannerSuite`: which bounds `supportsCursorScan` takes and rejects, in the as-of condition and as the residual condition, and that the cursor evaluates the limit once per left row in both forms.\n- `AsOfJoinSortMergeSQLSuite`: SQL joins with an ON bound against exact rows, with the cursor scan off and on and the codegen off and on: backward and forward, INNER and LEFT, strict and inclusive, inside, at and past the bound, NULL keys on each side, a key with no right rows, ANSI on and off, and BIGINT, DATE and TIMESTAMP keys with no ON keys. Each ON shape that keeps the buffered scan still returns the right row, for example the farther row for a far-enough bound or a bound on a column the join does not sort on. DOUBLE bounds with an infinite or NaN limit return the same rows in both scans. A limit that overflows fails both scans with `ARITHMETIC_OVERFLOW` under ANSI, and matches nothing without ANSI.\n- `SortMergeAsOfJoinSuite`: the DataFrame tolerance joins against exact rows and random rows, in both scans, a bound given only in `joinExprs` takes the cursor, a tolerance of +Infinity on DOUBLE keys returns the same rows in both scans, and a bound in both places keeps the buffered scan. Its codegen grid test and the ASOF test in `WholeStageCodegenSuite` assumed that a tolerance keeps the buffered scan; they now check both scans.\n- Ran `SortMergeAsOfJoinScannerSuite`, `SortMergeAsOfJoinSuite`, `AsOfJoinSortMergeSQLSuite`, `AsOfJoinSQLSuite`, `DataFrameAsOfJoinSuite`, `StreamingAsOfJoinSuite`, `TimestampNanosJoinAnsiOnSuite`, `TimestampNanosJoinAnsiOffSuite`, `WholeStageCodegenSuite`, `SQLMetricsSuite` and `UnionCodegenSuite`, once as is and once with `SPARK_ANSI_SQL_MODE\u003dfalse`. With ANSI off, one `WholeStageCodegenSuite` test fails (`SPARK-60403: MergeRows compiles with its function spilled to a nested class`); it checks the generated code size of MergeRows, runs no ASOF join, and fails the same way without this change.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60795 from LukaZdravic/asof-tolerance-cursor-scan.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b656c32c097d73e41b5ead26732d66fc3d857024",
      "tree": "287f88fa838655e5334f4c2603c7dc7ecd858d66",
      "parents": [
        "4821c796eaf509f013e5b290b7455734e81bcfca"
      ],
      "author": {
        "name": "Linhong Liu",
        "email": "linhong.liu@databricks.com",
        "time": "Wed Nov 25 01:04:48 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Wed Nov 25 01:04:48 2026 +0000"
      },
      "message": "[SPARK-60754][SQL][FOLLOWUP] Move JDBC write migration guide entry to Spark 4.5\n\n### What changes were proposed in this pull request?\n\nThis is a follow-up to #59962. It moves the JDBC write failure classification entry in the SQL migration guide from \"Upgrading from Spark SQL 4.3 to 4.4\" to \"Upgrading from Spark SQL 4.4 to 4.5\", and changes \"Since Spark 4.4\" to \"Since Spark 4.5\". The rest of the entry is unchanged.\n\n### Why are the changes needed?\n\n#59962 was merged to master for Spark 4.5.0 and will not be backported to `branch-4.4`, as discussed in https://github.com/apache/spark/pull/59962#issuecomment-7147200449. The entry should list the release that contains the change.\n\n### Does this PR introduce _any_ user-facing change?\n\nDocumentation only. The migration guide lists the change under Spark 4.5.\n\n### How was this patch tested?\n\nDocumentation only. I checked that the entry is the last bullet of the 4.4 to 4.5 section and no longer appears in the 4.3 to 4.4 section.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac\n\nThis pull request and its description were written by Isaac.\n\nCloses #60857 from linhongliu-db/linhongliu-db/sqlstate-jdbc-write-4.5-doc.\n\nAuthored-by: Linhong Liu \u003clinhong.liu@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "4821c796eaf509f013e5b290b7455734e81bcfca",
      "tree": "9ed10def6b6f0657f2fd0165894b4bdde6f75b6f",
      "parents": [
        "d237fdb0b444c694e10ee1ac1f5a0c228cf5228b"
      ],
      "author": {
        "name": "Jacek Laskowski",
        "email": "jacek@japila.pl",
        "time": "Tue Nov 24 17:02:33 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 17:02:33 2026 -0800"
      },
      "message": "[SPARK-61750][SDP] Make Language.Python/Sql case objects\n\n### What changes were proposed in this pull request?\n\n`Language.Python` and `Language.Sql `carry no state, so model them as case objects rather than empty case classes.\nUse `Some(Python)` / `Some(Sql)` rather than `Option(Python())` and `Option(Sql())`.\n\n### Why are the changes needed?\n\nMake the Scala code more idiomatic (and slightly more JVM optimized)\n\n### Does this PR introduce _any_ user-facing change?\n\nNo\n\n### How was this patch tested?\n\nLocal build\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nNo, but the commit\u0027s description was supported by Claude Code for better English writing\n\nCloses #60532 from jaceklaskowski/sdp-some-option-fixes.\n\nAuthored-by: Jacek Laskowski \u003cjacek@japila.pl\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d237fdb0b444c694e10ee1ac1f5a0c228cf5228b",
      "tree": "0fe8cb409310ef43e722e72172336513cf0cad66",
      "parents": [
        "581c83b7d89d97ad33e0060ad8252d7bbc8ef749"
      ],
      "author": {
        "name": "Akshay Thorat",
        "email": "ak007t@gmail.com",
        "time": "Tue Nov 24 17:00:20 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 17:00:20 2026 -0800"
      },
      "message": "[SPARK-59514][PYTHON] Handle nonfinite values in assertDataFrameEqual\n\n### What changes were proposed in this pull request?\n\nJira: [SPARK-59514](https://issues.apache.org/jira/browse/SPARK-59514)\n\nCompare NaN and infinity explicitly before applying finite-value tolerances. Preserve matching NaNs and same-sign infinities, and add tests for both argument directions, zero/default tolerances, and nested values.\n\n### Why are the changes needed?\n\nThe tolerance inequality does not reject NaN arithmetic, and an infinite expected value can make both sides infinity. As a result, NaN versus a finite value and opposite-sign infinities can pass equality assertions.\n\n```python\nfrom pyspark.sql import Row\nfrom pyspark.testing import assertDataFrameEqual\nassertDataFrameEqual([Row(x\u003dfloat(\"nan\"))], [Row(x\u003d1.0)])\nassertDataFrameEqual([Row(x\u003d1.0)], [Row(x\u003dfloat(\"inf\"))])\nassertDataFrameEqual([Row(x\u003dfloat(\"inf\"))], [Row(x\u003dfloat(\"-inf\"))])\n# All three return without raising\n```\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Unequal special values now raise DIFFERENT_ROWS. Matching NaNs and same-sign infinities continue to compare equal, and finite-value tolerance behavior is unchanged.\n\n### How was this patch tested?\n\nThe new regression tests failed before the fix and passed afterward on Python 3.10.11 with NumPy 2.2.6. The focused run passed 3 tests, including parameterized subtests:\n\n```bash\nPYTHONPATH\u003dpython TERM\u003ddumb python -m unittest pyspark.sql.tests.test_utils.NonFiniteComparisonTests -q\nPYTHON_EXECUTABLE\u003dpython ./dev/lint-python --compile --custom-pyspark-error --ruff\n```\n\nRun the commands with the Python virtual environment activated; the local run shared an environment from a sibling checkout. The tests call public Python APIs directly and require no SparkSession. Python compilation, custom-error checks, Ruff lint, and Ruff formatting passed. JVM-backed suites were not run because these fixes are confined to Python-side logic.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex (GPT-6).\n\nCloses #58790 from laserninja/fix/nonfinite-comparison.\n\nAuthored-by: Akshay Thorat \u003cak007t@gmail.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "581c83b7d89d97ad33e0060ad8252d7bbc8ef749",
      "tree": "5df0910efeba8080314366dda8e4feff14e1e236",
      "parents": [
        "619a4491eb45732000bb7f82b46fd5422db5b05b"
      ],
      "author": {
        "name": "Elia Liu",
        "email": "Elialiu760317@outlook.com",
        "time": "Tue Nov 24 16:57:37 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 16:57:37 2026 -0800"
      },
      "message": "[SPARK-59119][CONNECT][PYTHON] Do not crash on cyclic or out-of-range cause_idx in error details\n\n### What changes were proposed in this pull request?\n\n`_extract_jvm_stacktrace` in `pyspark/errors/exceptions/connect.py` follows the `cause_idx` chain from `FetchErrorDetailsResponse` recursively, without validating the index. This PR walks the chain iteratively instead and stops when the next index is out of range or has already been visited, so each error is formatted at most once.\n\nThe Scala client has a similar unguarded recursion in `GrpcExceptionConverter.errorsToThrowable`; this PR only covers the Python client.\n\n### Why are the changes needed?\n\nIf the error details returned by `FetchErrorDetails` contain a malformed cause chain, the client crashes inside error conversion and the original server error is lost:\n\n- a cyclic `cause_idx` (two errors pointing at each other, or an error listed as its own cause) raises `RecursionError: maximum recursion depth exceeded`\n- an out-of-range `cause_idx` raises `IndexError: list index out of range`\n\nReproducible by calling `convert_exception` with a `FetchErrorDetailsResponse` where `errors[0].cause_idx \u003d 1` and `errors[1].cause_idx \u003d 0`.\n\n### Does this PR introduce _any_ user-facing change?\n\nOnly for malformed error details: the client now raises the converted server exception instead of `RecursionError`/`IndexError`. Well-formed cause chains are formatted exactly as before.\n\n### How was this patch tested?\n\nAdded `test_convert_exception_with_malformed_cause_chain` to `pyspark.errors.tests.test_connect_errors_conversion` covering the mutual cycle, the self-cycle, and the out-of-range case. All tests in the module pass:\n\n```\npython -m pytest python/pyspark/errors/tests/test_connect_errors_conversion.py\n13 passed\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code\n\nCloses #58515 from Eliaaazzz/SPARK-59119.\n\nAuthored-by: Elia Liu \u003cElialiu760317@outlook.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "619a4491eb45732000bb7f82b46fd5422db5b05b",
      "tree": "1564a08bb293c6487615f3f14b47d0e93ee03b26",
      "parents": [
        "e6b1bed5f700553b3e9e94e46d63fbf4d3e6caaa"
      ],
      "author": {
        "name": "rdtr",
        "email": "norio@apache.org",
        "time": "Tue Nov 24 16:49:54 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 16:49:54 2026 -0800"
      },
      "message": "[SPARK-58213][SQL][FOLLOWUP] Add a migration guide entry for corr with a zero-variance column\n\n### What changes were proposed in this pull request?\r\n\r\nThis PR adds an entry to the \"Upgrading from Spark SQL 4.2 to 4.3\" section of the SQL migration guide for https://github.com/apache/spark/pull/58030. Since that change, `corr` returns NULL instead of failing with `DIVIDE_BY_ZERO` in ANSI mode when either input column has zero variance over two or more rows.\r\n\r\n### Why are the changes needed?\r\n\r\nhttps://github.com/apache/spark/pull/58030 is a user-facing change in ANSI mode, but the migration guide doesn\u0027t mention it. It was released in Spark 4.3.0, so it would be good to have the entry in branch-4.3 as well.\r\n\r\nWe noticed it in Apache Gluten, whose native engine (Velox) already returns NULL in this case: in ANSI mode, the results match Spark 4.3 but differ from Spark 4.2 and earlier.\r\n\r\nIf you think the migration guide doesn\u0027t need this entry, please feel free to close this PR.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nNo. Documentation only.\r\n\r\n### How was this patch tested?\r\n\r\nNot tested. This PR only adds one line to the migration guide.\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-by: Claude Code (Claude Opus 5.5)\r\n\nCloses #59407 from rdtr/spark-58213-migration-guide.\n\nAuthored-by: rdtr \u003cnorio@apache.org\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n"
    },
    {
      "commit": "e6b1bed5f700553b3e9e94e46d63fbf4d3e6caaa",
      "tree": "bf87fc6fc7f5d8beecdea28006cfadf75857d0d5",
      "parents": [
        "b1583bd510ff1a65fa88866031f6bb1adf52ed93"
      ],
      "author": {
        "name": "Yongbin Miao",
        "email": "24323269+DaemonforY@users.noreply.github.com",
        "time": "Tue Nov 24 16:39:18 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 16:39:18 2026 -0800"
      },
      "message": "[SPARK-62338][CORE][DOC] Fix the ACL config name in the spark.history.ui.acls.enable description\n\n### What changes were proposed in this pull request?\n\nThis PR fixes the description of `spark.history.ui.acls.enable` in `docs/security.md` and in its config doc in `History.scala`. They say ACL checks are performed regardless of what applications had set for `spark.ui.acls.enable`; the setting that actually controls application ACLs is `spark.acls.enable`.\n\n### Why are the changes needed?\n\n`spark.ui.acls.enable` is no longer read anywhere:\n\n- `SecurityManager` only reads `spark.acls.enable`: `private var aclsOn \u003d sparkConf.get(ACLS_ENABLE)`, where `ACLS_ENABLE` is defined in `UI.scala`.\n- The legacy key used to be honored as a fallback (\"keep spark.ui.acls.enable for backwards compatibility with 1.0\"): `sparkConf.getBoolean(\"spark.acls.enable\", sparkConf.getBoolean(\"spark.ui.acls.enable\", false))`. That fallback was removed in SPARK-26482 (commit d9e4cf67c06, first released in 3.0.0), and the key is not registered as a deprecated or alternative config in `SparkConf`.\n\nSo a user following the current description may set `spark.ui.acls.enable`, which has no effect.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo behavior change. Documentation only: the description of `spark.history.ui.acls.enable` now refers to `spark.acls.enable`.\n\n### How was this patch tested?\n\nDocumentation-only change; no tests are needed. Both modified lines are within the 100-character limit.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #59436 from DaemonforY/minor-fix-history-acls-doc.\n\nAuthored-by: Yongbin Miao \u003c24323269+DaemonforY@users.noreply.github.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b1583bd510ff1a65fa88866031f6bb1adf52ed93",
      "tree": "c074ac7f550d13231628efd4b2a8bdf9eca2a58e",
      "parents": [
        "d1c23f147cf56d5a63b2058c4af4207b4136d279"
      ],
      "author": {
        "name": "Constantin-Tiberiu Craiu",
        "email": "57532657+craiuconstantintiberiu@users.noreply.github.com",
        "time": "Tue Nov 24 16:36:44 2026 -0800"
      },
      "committer": {
        "name": "Holden Karau",
        "email": "holden.karau@snowflake.com",
        "time": "Tue Nov 24 16:36:44 2026 -0800"
      },
      "message": "[SPARK-60507][SQL][FOLLOWUP] Read JDBC database metadata from the scan\u0027s connection\n\n### What changes were proposed in this pull request?\r\n\r\nJDBCTable.newScanBuilder reuses the database metadata prefetched by the catalog only when the per-read options open the same connection (same URL, driver, connection provider and connection properties). Otherwise the scan reads the metadata from its own connection.\r\n\r\n### Why are the changes needed?\r\n\r\nSPARK-52730 exposes the database and driver versions of the scanned database through JDBCRDD.getDatabaseMetadata. SPARK-60507 passes the catalog\u0027s metadata to every scan, so a read that overrides the connection, e.g. spark.read.option(\"url\", otherUrl).table(\"cat.t\"), reports the versions of the catalog\u0027s database instead of the one it reads.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nNo.\r\n\r\n### How was this patch tested?\r\n\r\nNew unit test in JDBCV2Suite.\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60723 from craiuconstantintiberiu/jdbc-metadata-option-override.\n\nAuthored-by: Constantin-Tiberiu Craiu \u003c57532657+craiuconstantintiberiu@users.noreply.github.com\u003e\nSigned-off-by: Holden Karau \u003cholden.karau@snowflake.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d1c23f147cf56d5a63b2058c4af4207b4136d279",
      "tree": "aa8bfe1d1b6fbf697219916fbcc6b75068558707",
      "parents": [
        "b8ca6c98365f80adc17b31ea0fcc24ded60fc5e2"
      ],
      "author": {
        "name": "Linhong Liu",
        "email": "linhong.liu@databricks.com",
        "time": "Tue Nov 24 23:12:45 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 23:12:45 2026 +0000"
      },
      "message": "[SPARK-60754][SQL] Classify JDBC write failures with SQLSTATE\n\n### What changes were proposed in this pull request?\n\nClassify destination `SQLException`s in executor JDBC partition writes through the active dialect. Condition based dialects use `FAILED_JDBC.WRITE` (SQLSTATE `HV000`) unless a more specific dialect mapping applies. The generic legacy classifier leaves the original `SQLException` in place. Source iterator failures and task cancellation keep their existing behavior. Connection cleanup cannot replace the original write failure.\n\nSpark Connect projects `FAILED_JDBC.WRITE` to `FAILED_JDBC.UNCLASSIFIED` for all clients because it does not negotiate error catalog capabilities. The projected message and structured fields agree.\n\nThe JDBC vendor message and vendor SQLSTATE remain on the original `SQLException` instead of becoming WRITE parameters: driver messages can contain sensitive data, and no general redaction rule exists for them. This means PySpark and Connect public error fields expose the generic condition and `HV000`. The change ships without a rollback setting, following Spark\u0027s error condition migrations; callers that catch `SparkException` or `Py4JJavaError` must update their handlers.\n\n### Why are the changes needed?\n\nJDBC write failures currently lack a Spark error condition and SQLSTATE. Classifying destination failures makes them identifiable while preserving the original JDBC exception as the cause of the default wrapper.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. For condition based dialects, classic JVM JDBC write failures can now surface as `SparkRuntimeException` with `FAILED_JDBC.WRITE` and SQLSTATE `HV000`, or as a more specific mapped exception, instead of a job-aborted `SparkException`. The original JDBC message and vendor SQLSTATE remain on the cause. Classic PySpark exposes the condition, `HV000`, and generated message on its captured exception, without a public JDBC cause. Spark Connect reports `FAILED_JDBC.UNCLASSIFIED` and `HV000`; the original JDBC message is available in the `FetchErrorDetails` cause entry, but its vendor SQLSTATE is not a structured field. The generic legacy classifier retains the previous exception shape. The migration guide describes these surfaces.\n\n### How was this patch tested?\n\nAdded `JdbcWriteExceptionSuite` regressions for connection acquisition, setup, batch execution, cleanup, legacy classification, dialect mappings, and source iterator propagation. Updated the ignored JDBC query timeout assertion and Connect condition/message checks.\n\n```bash\nbuild/sbt -Phive \\\n  \u0027sql/testOnly *JdbcWriteExceptionSuite *JdbcTaskInterruptSuite *JDBCWriteSuite\u0027 \\\n  \u0027connect/testOnly *ErrorUtilsSuite\u0027 \\\n  \u0027core/testOnly *SparkThrowableSuite\u0027 \\\n  \u0027sql/scalastyle\u0027 \u0027sql/Test/scalastyle\u0027 \\\n  \u0027connect/scalastyle\u0027 \u0027connect/Test/scalastyle\u0027\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex (GPT-6).\n\nCloses #59962 from linhongliu-db/linhongliu-db/sqlstate-jdbc-write.\n\nAuthored-by: Linhong Liu \u003clinhong.liu@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b8ca6c98365f80adc17b31ea0fcc24ded60fc5e2",
      "tree": "08476d3683225199b56d80e87d86b55b60ba9719",
      "parents": [
        "20ed64a02dfe9df5232a1215baa0c8bb4e60a09c"
      ],
      "author": {
        "name": "Vladan Vasić",
        "email": "vladan.vasic@databricks.com",
        "time": "Tue Nov 24 23:10:21 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 23:10:21 2026 +0000"
      },
      "message": "[SPARK-62296][SQL] Extract reusable DESCRIBE analysis helpers\n\n### What changes were proposed in this pull request?\n\nhttps://issues.apache.org/jira/browse/SPARK-62296\n\nExtract reusable analysis helpers for DESCRIBE commands and make the existing analyzer rules delegate to them:\n\n- `DescribeCommandHelper` lowers resolved table, partition, column, namespace and function descriptions to V1 commands, preserving V2 fall-through.\n- `CatalogIdentifierResolution.resolveNamespace` resolves namespace metadata while `ResolveCatalogs` retains catalog/name selection.\n- `FunctionResolution.resolveFunctionName` looks up builtin, temporary and catalog function metadata using the caller\u0027s catalog extractor.\n- `DdlTargetValidation` checks resolved table and table-or-view targets.\n- `NotFoundErrorSearchPath` formats the existing DDL and query search paths using the analyzer\u0027s error formatter.\n- `KeepLegacyOutputs.keepLegacyDescribeNamespaceOutput` applies the namespace output rename; the existing rule retains the configuration gate.\n\nEvery extracted helper has a current analyzer-rule caller. The namespace V1 guard is passed lazily from its owning rule. Function lookup retains the caller\u0027s overridden catalog and initialized extractor; search-path formatting retains overridden error formatters. Procedure resolution is already shared by `FunctionResolution.resolveProcedure`.\n\n### Why are the changes needed?\n\nThese operations currently live inside rule match arms or private rule methods. Other analysis code cannot reuse them without repeating the logic or invoking an entire tree-rewriting rule. The helpers provide the same operations for a single command or target while the existing rules retain traversal and ordering.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Catalog selection, lookup order, error timing and formatting, command schemas and expression IDs are preserved.\n\n### How was this patch tested?\n\nTested with JDK 21 and SBT, with Hive enabled: **602 tests passed across 14 suites**, with no failures or skips.\n\n- Catalyst: `AnalysisSuite`, `CatalogSuite`, `LookupFunctionsSuite` (117 tests).\n- SQL: `PlanResolutionSuite`, v1/v2 `DescribeTableSuite` and `DescribeNamespaceSuite`, `DataSourceV2MetadataViewSuite`, `DataSourceV2FunctionSuite`, `org.apache.spark.sql.internal.CatalogSuite`, `SimpleSQLViewSuite` (411 tests).\n- Hive: `DescribeTableSuite`, `DescribeNamespaceSuite` (74 tests).\n- `catalyst/Compile/scalastyle`, `catalyst/Test/scalastyle`, `sql/Compile/scalastyle`, `sql/Test/scalastyle`: zero errors or warnings.\n- `git diff --check` and changed-line length/ASCII checks.\n\nFocused tests cover namespace selection and metadata loading, scalar/table-function lookup precedence and catalog failures, overridden error formatters, temporary-view search-path laziness, command output preservation, and V2 fall-through.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: OpenAI Codex (GPT-6)\n\nCloses #60822 from vladanvasi-db/vladanvasi-db/describe-analysis-helpers.\n\nAuthored-by: Vladan Vasić \u003cvladan.vasic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "20ed64a02dfe9df5232a1215baa0c8bb4e60a09c",
      "tree": "38ce9be8f05e7749836d0e8ee510fd89d000a342",
      "parents": [
        "0bcfe02d3cad22a9fd4c22a48cf0ae346498dffe"
      ],
      "author": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Tue Nov 24 14:46:20 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Tue Nov 24 14:46:20 2026 -0800"
      },
      "message": "[SPARK-62319][SQL] Fix a misleading SPJ fallback log before a cogroup key type mismatch error\n\n### What changes were proposed in this pull request?\n\nThis PR fixes `KeyedShuffleSpec.createPartitioning` so that it no longer logs an INFO line claiming that a storage-partitioned join does not evaluate a partition transform, right before it fails planning with `STORAGE_PARTITION_JOIN_KEY_TYPE_MISMATCH`.\n\n`TransformExpression` gets `isEvaluableQuietly`, which tells whether `evaluableFunction` is defined without logging why not, and returns what resolving the call threw, if anything. `createPartitioning` asks it, instead of `canEvaluate`, of the transform rebuilt over the other side\u0027s key, and makes what was thrown the cause of `STORAGE_PARTITION_JOIN_KEY_TYPE_MISMATCH`. `evaluableFunction` logs as before.\n\n### Why are the changes needed?\n\nWith `spark.sql.sources.v2.bucketing.shuffle.enabled\u003dtrue`, a cogroup that does not coerce its keys (e.g. a Pandas or Arrow cogroup) can have a key that `TransformExpression.keysStoredAlike` accepts but that the layout\u0027s function cannot take. An example is an `ARRAY\u003cDECIMAL(12,2)\u003e` key shuffled onto an `ARRAY\u003cDECIMAL(10,2)\u003e` column whose function declares the column\u0027s type. `createPartitioning` then logged the following line and immediately threw `STORAGE_PARTITION_JOIN_KEY_TYPE_MISMATCH`.\n\n```\nThe partition transform bucket (...) declares the input types (int, array\u003cdecimal(10,2)\u003e), which do not take arguments of types (int, array\u003cdecimal(12,2)\u003e), so a storage-partitioned join does not evaluate it\n```\n\nThe line implies a fallback to a hash shuffle, which never happens: planning fails instead. Keys that the storage check refuses already failed without any log.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. Only the misleading INFO line is gone; the planning error keeps its message. When resolving the call over the other key throws, what was thrown is now the error\u0027s cause instead of a WARN line before it. The line was introduced by SPARK-60027, which is not released yet.\n\n### How was this patch tested?\n\n- `EnsureRequirementsSuite`: the `ARRAY\u003cDECIMAL\u003e` row of \"SPARK-60027: a cogroup shuffled from a key Spark cannot place fails while planning\", added by #60431, now asserts that nothing is logged, like the other rows. Previously it skipped that assertion because of this log.\n- `TransformExpressionSuite`: a new test, \"SPARK-62319: isEvaluableQuietly tells whether a transform is evaluable without logging\". It covers an evaluable transform, arguments that do not suit, a method that cannot be invoked, a function that is not a `ScalarFunction`, and a call that fails to resolve, and checks that nothing is logged at DEBUG level.\n- `ShuffleSpecSuite`: a new test, \"SPARK-62319: what resolving the call over the other key throws is the error\u0027s cause\". It checks that `createPartitioning` fails with `STORAGE_PARTITION_JOIN_KEY_TYPE_MISMATCH` whose cause is what the connector threw.\n\n```\n$ build/sbt \u0027catalyst/testOnly *TransformExpressionSuite *ShuffleSpecSuite\u0027 \u0027sql/testOnly *EnsureRequirementsSuite\u0027\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #60836 from dongjoon-hyun/SPARK-62319.\n\nAuthored-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "0bcfe02d3cad22a9fd4c22a48cf0ae346498dffe",
      "tree": "62d776ed0c379726e903b4bf3156d75b3e311465",
      "parents": [
        "3cb909a39d0e6816703b3f5ce3671dbfe04a2942"
      ],
      "author": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Tue Nov 24 12:18:34 2026 -0800"
      },
      "committer": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Tue Nov 24 12:18:34 2026 -0800"
      },
      "message": "[SPARK-61827][PYTHON][TEST] Add tests for DataFrameWriterV2 write modes, options and properties\n\n### What changes were proposed in this pull request?\n\nAdds `test_write_modes_with_options_and_properties` to `ReadwriterV2TestsMixin` in `python/pyspark/sql/tests/test_readwriter.py`. The test runs in both the classic and the Spark Connect suites and covers:\n\n- `DataFrame.writeTo(...).using(\"parquet\").option(...).tableProperty(...).create()`: checks the written row count and that the table property shows up in `SHOW TBLPROPERTIES`.\n- `replace()` and `createOrReplace()` on a session-catalog (v1) table: `AnalysisException` with `UNSUPPORTED_FEATURE.TABLE_OPERATION`.\n- `append()` and `overwritePartitions()` on a session-catalog (v1) table: `AnalysisException` with `Cannot write into v1 table`.\n\n### Why are the changes needed?\n\n12 lines of `WriteOperationV2.command` in `python/pyspark/sql/connect/plan.py` were not covered by any test. This method builds the Spark Connect proto for `DataFrameWriterV2`. The existing tests only call `create()` and `overwrite()` and never pass options or table properties, so the serialization of `option`/`tableProperty` and of the `replace`, `createOrReplace`, `append` and `overwritePartitions` modes never ran. With this test 12 of the 15 previously uncovered lines in the method are covered. The rest are the `None` value branches, which the public `option()`/`tableProperty()` methods never produce, and the fallback for an unknown mode, which no public method can reach.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, test-only change.\n\n### How was this patch tested?\n\nRan the new test and both full test classes, and all passed:\n\n```\npython/run-tests --testnames \u0027pyspark.sql.tests.connect.test_parity_readwriter ReadwriterV2ParityTests\u0027\npython/run-tests --testnames \u0027pyspark.sql.tests.test_readwriter ReadwriterV2Tests\u0027\n```\n\nThe new test adds about 0.4 s to the class. `dev/lint-python` formatting checks pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (claude-opus-5-5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60576 from gaogaotiantian/cov/sql-connect-plan--writeoperationv2-command.\n\nAuthored-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\nSigned-off-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "3cb909a39d0e6816703b3f5ce3671dbfe04a2942",
      "tree": "373057e3f4440a20e3b87ea083da0feb3f065c70",
      "parents": [
        "53b160be4db0bc9850150c1885f9edee8f6748be"
      ],
      "author": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Tue Nov 24 12:11:08 2026 -0800"
      },
      "committer": {
        "name": "Tian Gao",
        "email": "gaogaotiantian@hotmail.com",
        "time": "Tue Nov 24 12:11:08 2026 -0800"
      },
      "message": "[SPARK-60951][PYTHON] Support configurable aggregation level for the Python UDF sampling profiler\n\n### What changes were proposed in this pull request?\n\nThis PR adds `spark.sql.pyspark.udf.profiler.samplingAggregation` to choose the level at which the sampling profiler (added in SPARK-60604) aggregates sampled call stacks. It accepts `query`, `stage` or `task`, and defaults to `stage`.\n\n- `PythonUDFRunner` and `ArrowPythonRunner` pass the conf to the Python worker, the same way as `spark.sql.pyspark.udf.profiler.samplingInterval`.\n- On the worker, `WorkerSamplingProfiler._get_task_key()` chooses the result key for the task at that level:\n  - `query`: `sampling_query_\u003cid\u003e`. The id is the `sql.streaming.queryId` local property if set, otherwise `spark.sql.execution.root.id`. Each micro-batch of a streaming query is its own SQL execution with its own root id, so the streaming query id is what groups all micro-batches of a streaming query together. If neither is set, i.e. the UDF does not run in a SQL execution (e.g. under `df.rdd`), the key is `sampling_query_unknown`.\n  - `stage`: `sampling_stage_\u003cstageId\u003e`.\n  - `task`: `sampling_task_\u003cstageId\u003e_\u003cpartitionId\u003e`. Stage ids are unique in the application, so this identifies a task; all attempts of a task, e.g. retries, share the key.\n- `WorkerSamplingProfiler` gets the key when it is created, so an aggregation level other than `query`, `stage` or `task` raises `PySparkValueError` (`VALUE_NOT_ALLOWED`) before the UDF runs. `SQLConf` already rejects such values.\n- Each task still sends its own call tree. Results with the same key are merged by the existing `ProfileResultsParamV2` where the profile results are collected: in the driver\u0027s accumulator server in classic PySpark, and in the client in Spark Connect. So one call tree is kept per key there, instead of one per task attempt. In Spark Connect, the server still keeps every task\u0027s update until it sends them to the client, whatever the level.\n- Each sample keeps at most its outermost 256 frames (`WorkerSamplingProfiler._MAX_STACK_DEPTH`), and the samples of deeper stacks are counted under a `\u003ctruncated\u003e` child of the 256th frame. The worker pickles each call tree recursively when it sends it, and on Python 3.11 that counts against the recursion limit, so a UDF stack about 500 frames deep failed the task with \"Python worker exited unexpectedly\", also before this PR. Keeping the outermost frames keeps each sample\u0027s real root, so the trees still merge. A UDF body starts about 16 frames deep in the worker, so in practice only deep recursion reaches the cap. The cap also bounds the recursive copy described below.\n- `SamplingResultParam.addInPlace` now merges call trees with an explicit stack instead of recursion. Results with a shared key are now merged all the time, and this way the merge does not depend on the recursion limit, even though the cap bounds the depth of the call trees that workers send.\n- `ProfilerCollector._sampling_profile_results` returns copies made under the lock, as #60259 did for `_perf_profile_results`. With shared keys, later merges change the stored call trees in place while callers read them outside the lock. The copy recurses, but the cap bounds the depth of a call tree.\n- The `sampling_` prefix keeps these keys apart from the other profilers\u0027 keys, which are UDF result ids (int) or, for `spark.sql.pyspark.dataSource.profiler`, Python worker module names such as `plan_data_source_read`.\n- Within a result, call trees are keyed by thread name instead of `threading.get_ident()`. Thread ids are only meaningful within one process at one time, so merging trees from different tasks by thread id would combine unrelated threads. Keyed by name, for example, the `MainThread` trees of all tasks are merged. At every level, threads with the same name are merged into one call tree, even threads of one task that run at the same time; the conf doc says so.\n  - The sampler takes the frames first and then the names, so that every thread in the frames that `threading.enumerate()` lists by then is named. The names are kept across samples, so a thread whose last frames are still running after `threading.enumerate()` has dropped it keeps its name.\n  - A thread is named once `threading.enumerate()` lists it with its id. Before that, e.g. for the few bytecodes before its id is set, or always if it is never listed, e.g. when started with `_thread.start_new_thread()`, its samples go under the name last seen for its id, which a reused id keeps from an exited thread, or else under one `\u003cunknown thread\u003e` call tree for all such threads, since thread ids mean nothing across tasks.\n  - Names that CPython generates from process-wide counters, e.g. `ThreadPoolExecutor-0_0` or `Thread-1 (run)`, change with every new thread in a worker, so such threads mostly keep separate call trees. For example, with `spark.sql.execution.pythonUDF.arrow.concurrency.level` set, each batch runs the UDF in a new thread pool. Grouping them is left for later, as a TODO in the code says.\n\n### Why are the changes needed?\n\nBefore this PR, the sampling profiler kept one result per task attempt, so for a job with many tasks the driver held one call tree per task attempt, even though users usually want a view of a whole stage or query. Letting users choose the aggregation level up front keeps the memory where results are merged (the driver in classic PySpark, the client in Spark Connect) proportional to the number of stages or queries instead of the number of tasks. Threads with names that CPython generates, described above, are the exception for now: they still keep separate call trees.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, in unreleased code only. There is a new SQL conf, `spark.sql.pyspark.udf.profiler.samplingAggregation`. The sampling profiler is not released yet; with this PR its results are aggregated per stage by default, instead of kept per task attempt, and each sample keeps at most its outermost 256 frames.\n\n### How was this patch tested?\n\nAdded and updated tests in `pyspark.sql.tests.test_udf_profiler`:\n- `test_sampling_profiler_aggregation` (classic and Connect): runs a query with a UDF on both sides of a shuffle (two stages of two tasks each) and checks the number of results and the exact key shape for each level: 4 `sampling_task_\u003cstage\u003e_\u003cpartition\u003e` keys, 2 `sampling_stage_\u003cstage\u003e` keys, and 1 `sampling_query_\u003croot id\u003e` key, plus 2 stage keys when the conf is unset. It runs with both Arrow-optimized and non-Arrow Python UDFs, covering both runners. Each subtest builds a new DataFrame, because running the same classic DataFrame again skips the map stage while its shuffle files are kept; under `run-tests` they are removed after each query, since `spark.sql.classic.shuffleDependency.fileCleanup.enabled` defaults to true in tests.\n- `test_sampling_profiler_merge_threads_by_name` (classic and Connect): two tasks each start a thread named `helper`; checks that the stage-level result has exactly one call tree per thread name, `MainThread` and `helper`. This test fails if call trees are keyed by thread id.\n- `test_sampling_profiler_aggregation_streaming_query` (classic): a streaming query that runs in three micro-batches yields a single `sampling_query_\u003cstreaming query id\u003e` result; the wait is bounded and the query is stopped in a `finally`.\n- `test_sampling_profiler_aggregation_query_unknown` (classic only, since Connect has no `df.rdd`): a UDF under `df.rdd` is grouped under `sampling_query_unknown`.\n- `test_sampling_profiler_aggregation_not_allowed` (classic): creating a `WorkerSamplingProfiler` with an unknown level raises `VALUE_NOT_ALLOWED`.\n- `test_sampling_profiler_truncate_deep_stack` (classic): a sample of a stack deeper than 256 frames keeps exactly the outermost 256 frames, followed by `\u003ctruncated\u003e`.\n- `test_sampling_profiler_unknown_thread` (classic): a thread started with `_thread.start_new_thread()` is sampled under `\u003cunknown thread\u003e`, not under its thread id.\n- `test_sampling_profile_results_are_copies` (classic): results read before a merge into the same key are not changed by it. This test fails without the copy.\n- `test_sampling_result_param_merge` (classic): merging call trees under the same key sums their counts node by node.\n- `test_sampling_result_param_merge_deep_tree` (classic): call trees deeper than the recursion limit are merged. This test fails with the previous recursive merge.\n- `test_sampling_profiler_udf` now sets the `task` level, since it checks one result per task.\n\nRan locally, on Python 3.12:\n```\npython/run-tests --testnames \"pyspark.sql.tests.test_udf_profiler,pyspark.sql.tests.connect.test_parity_udf_profiler\"\n```\nand `pyspark.sql.tests.test_udf_profiler UDFProfiler2Tests` on Python 3.11.\n\nAlso checked by hand on Python 3.11 with the sampling profiler on: a UDF that recurses 600 frames deep crashed the worker before this change, on master as well, and now succeeds with a call tree of 257 levels.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac\n\nThis pull request and its description were written by Isaac.\n\nCloses #60150 from gaogaotiantian/sampling-profiler-aggregation.\n\nAuthored-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\nSigned-off-by: Tian Gao \u003cgaogaotiantian@hotmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "53b160be4db0bc9850150c1885f9edee8f6748be",
      "tree": "a2f4719959e7c36b2110e30292c2103a82bdd608",
      "parents": [
        "13532ee78a8e3bb3514de572aed91c24a4dacd0a"
      ],
      "author": {
        "name": "Eric Marnadi",
        "email": "eric.marnadi@databricks.com",
        "time": "Tue Nov 24 11:47:33 2026 -0800"
      },
      "committer": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Tue Nov 24 11:47:33 2026 -0800"
      },
      "message": "[SPARK-58021][CONNECT] Recover abandoned local pool launches\n\n### What changes were proposed in this pull request?\n\nThis is layer 6 of the ten-PR local Connect pool stack:\n\n#57684 -\u003e #57685 -\u003e #57907 -\u003e #57686 -\u003e #58247 -\u003e #58367 -\u003e\n#57687 -\u003e #58248 -\u003e #57102 -\u003e #57688\n\nThis layer adds recovery before a pool member has finished publishing:\n\n- validated pending-launch records;\n- cleanup of dead, timed-out, malformed, and partially published launches;\n- attendant command and UID checks before acting on a reused PID;\n- complete cleanup of an attendant\u0027s launch process group;\n- recovery of server PIDs from malformed records and daemon PID files; and\n- stale conf-file and unreferenced member-directory garbage collection.\n\nAcquisition, forceful purge, SparkSession integration, and warmup remain in later PRs.\n\n### Why are the changes needed?\n\nAn attendant or its spawning client can die at any point between writing the launch seed, starting\nthe JVM, and publishing the ready server. Those partial states must stop counting toward refills,\nbut cleanup must not signal an unrelated process after PID reuse.\n\nThis layer builds on #58247\u0027s server-retirement machinery while keeping the separate attendant and\nprocess-group ownership contract independently reviewable.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. The pool is not wired into SparkSession in this layer.\n\n### How was this patch tested?\n\nAll 59 focused pool tests at this stack layer passed:\n\n```bash\nPYTHONPATH\u003dpython:python/lib/pyspark.zip:python/lib/py4j-0.10.9.9-src.zip \\\n  SPARK_TESTING\u003d1 \\\n  .venv/bin/python -m unittest -v \\\n  pyspark.sql.tests.connect.test_connect_local_server_pool\n```\n\nThe changed files also passed Python AST parsing, Ruff checking and formatting,\n`git diff --check`, and changed-file ASCII and 100-column checks.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Fable 5) and OpenAI Codex (GPT-5)\n\nCloses #58367 from ericm-db/local-connect-pool-launch-recovery.\n\nAuthored-by: Eric Marnadi \u003ceric.marnadi@databricks.com\u003e\nSigned-off-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "13532ee78a8e3bb3514de572aed91c24a4dacd0a",
      "tree": "93be7cc492e075b63ebaf19aef8efcf4dd57d079",
      "parents": [
        "7076fed8ad00dec07ec77e141511639d42509cbb"
      ],
      "author": {
        "name": "Laura Luo",
        "email": "luoyuqin1113@gmail.com",
        "time": "Tue Nov 24 11:44:25 2026 -0600"
      },
      "committer": {
        "name": "Mridul Muralidharan",
        "email": "mridulatgmail.com",
        "time": "Tue Nov 24 11:44:25 2026 -0600"
      },
      "message": "[SPARK-60759][SQL] Avoid O(N^2) driver accumulator merge in SQLAppStatusListener.aggregateMetrics\n\n### What changes were proposed in this pull request?\nIn `SQLAppStatusListener.aggregateMetrics`, group the driver accumulator updates by accumulator id and append each group to the metric array once, instead of copying the whole array for every update. The SPARK-30300 check that drops the task max when a driver value is larger is now evaluated per id, independently of whether task values exist.\n\n\n### Why are the changes needed?\n`aggregateMetrics` appended driver updates one at a time with `Arrays.copyOf(prev, prev.length + 1)`, which is O(N^2) in the number of updates for the same accumulator id. A single `SparkListenerDriverAccumUpdates` event can carry a very large number of entries for one id, and replaying such an event log in the History Server spends most of its time in `Arrays.copyOf`.\n\nReplaying an event log with this shape through `FsHistoryProvider.rebuildAppStore`, where one execution has N driver updates for one accumulator id:\n\n| N | master | this PR |\n|---|---|---|\n| 250K | 10.4 s | 0.5 s |\n| 500K | 38.2 s | 0.8 s |\n| 1M | 147.9 s | 1.1 s |\n\nmaster grows quadratically with N, this PR grows roughly linearly.\n### Does this PR introduce _any_ user-facing change?\nNo.\n\n### How was this patch tested?\nAdded a listener-level test in `SQLAppStatusListenerSuite` that posts task metric updates followed by a `SparkListenerDriverAccumUpdates` event for the same accumulator id. It checks that `(driver)` is shown when a driver value exceeds the task max, and the stage/task label otherwise. Also ran the existing `SQLAppStatusListener*Suite`s.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: GitHub Copilot\n\n\nCloses #59966 from luoyuqinlaura/SPARK-60759-aggregate-driver-accum-updates.\n\nAuthored-by: Laura Luo \u003cluoyuqin1113@gmail.com\u003e\nSigned-off-by: Mridul Muralidharan \u003cmridul\u003cat\u003egmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "7076fed8ad00dec07ec77e141511639d42509cbb",
      "tree": "b896ec2c66a4d94851be58d73ba9c7698d14bb6d",
      "parents": [
        "dc7c000d0b1f70f996ee6858ce9cd3c8f9efd819"
      ],
      "author": {
        "name": "Maxim Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Tue Nov 24 09:16:26 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Tue Nov 24 09:16:26 2026 -0800"
      },
      "message": "[SPARK-62149][SQL] Add try_abs and try_negative that return NULL on overflow\n\n### What changes were proposed in this pull request?\n\nThis PR adds two SQL functions, `try_abs(expr)` and `try_negative(expr)`, with the semantics of `abs` and `negative`, except that they return NULL instead of raising an overflow error, as `try_add`, `try_subtract` and `try_multiply` do. The result is NULL for:\n\n- the minimum value of `TINYINT`, `SMALLINT`, `INT` and `BIGINT`;\n- the minimum value of a `YEAR TO MONTH` or `DAY TO SECOND` interval;\n- for `try_negative`, a legacy `CALENDAR INTERVAL` with a field at its minimum value (`abs` does not accept that type).\n\nLike the other `try_` arithmetic functions, they return NULL there whatever `spark.sql.ansi.enabled` is. For every other input they are `abs` and `negative`: floating-point and decimal values cannot overflow (`Decimal.abs` and negation keep the precision), a NULL argument is coerced to `DOUBLE` as for `abs`, and a string argument is cast to `DOUBLE` with `try_cast` semantics, so a string that is not a number gives NULL in both modes, as for `try_add`.\n\nImplementation:\n\n- `TryAbs` and `TryNegative` in `TryEval.scala` are `RuntimeReplaceable` with `InheritAnalysisRules`, like `TryAdd`. Over a type that can overflow, the replacement is `AbsOrNull` / `NegateOrNull`; over a string, `Abs` / `UnaryMinus` of `Cast(expr, DoubleType, evalMode \u003d EvalMode.TRY)`; otherwise `Abs` / `UnaryMinus`.\n- `AbsOrNull` and `NegateOrNull` (in `arithmetic.scala`, next to `Abs`) extend `UnaryArithmeticOrNull`. They compare the value with the minimum of its type, and return NULL there, in both the interpreted path and generated code. They are `nullable`, check their input types, and are `NoThrow`, since they cannot raise themselves. Over a calendar interval, `NegateOrNull` calls the new `IntervalUtils.negateOrNull` in both paths.\n- They do not use `TryEval`, so an error raised by the argument itself still surfaces: under ANSI mode, `try_abs(2147483647 + 1)` raises `ARITHMETIC_OVERFLOW` from the addition. `try_add` over intervals wraps the expression in `TryEval`, which also hides such errors. A string argument is cast by `try_cast`, which only turns a string that is not a number into NULL: `try_negative(\u0027abc\u0027)` returns NULL in both modes, as `try_add(1, \u0027abc\u0027)` does.\n- `functions.try_abs` / `functions.try_negative` in Scala, and the PySpark (classic and Connect) functions, with docs. The SQL function reference and `sql-ref-ansi-compliance.md` list both.\n\n### Why are the changes needed?\n\nSpark has `try_` counterparts for the arithmetic operators that raise an overflow error under ANSI mode (`try_add`, `try_subtract`, `try_multiply`, `try_divide`, `try_mod`, `try_sum`, `try_avg`), but not for the unary ones. Under ANSI mode, `abs(x)` and `-x` raise `ARITHMETIC_OVERFLOW` for the minimum value of an integral type, for example `abs(-2147483648)`, and the only ways to get NULL instead were to turn ANSI mode off or to write `CASE WHEN x \u003d \u003cminimum\u003e THEN NULL ELSE abs(x) END` per type.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, two new SQL functions and the matching Scala and Python APIs:\n\n```sql\nSELECT try_abs(-1), try_abs(-2147483648), try_negative(-9223372036854775808L);\n-- 1    NULL    NULL\nSELECT try_negative(INTERVAL \u0027-178956970-8\u0027 YEAR TO MONTH);\n-- NULL\n```\n\n### How was this patch tested?\n\n- `TryEvalSuite`: `AbsOrNull` and `NegateOrNull` over the minimum, minimum + 1, maximum, -1, 0, 1 and NULL of each integral type and of both ANSI interval types, in the interpreted, mutable-projection and unsafe-projection modes. Also `try_negative` over calendar intervals with each field at its minimum, the types that cannot overflow, the replacement with ANSI mode on and off, the input type checks, string arguments in both modes, and an argument whose own error is not caught.\n- `ExprUtilsSuite`: both classes are listed as `NoThrow`, and they do not raise over the extreme values of each integral type, of both ANSI interval types and, for `NegateOrNull`, of calendar intervals.\n- `try_arithmetic.sql` (ANSI and non-ANSI golden files): literals and column-read inputs of every integral type, intervals, decimals at `DECIMAL(38, 0)` extremes, doubles, string literals and a string column, NULL, an argument that raises, and invalid input types.\n- `streaming/try-abs-negative.sql`: both functions in a streaming flow.\n- `MathFunctionsSuite`: the SQL and DataFrame API forms with ANSI mode on and off.\n- `PlanGenerationTestSuite` / `ProtoToParsedPlanTestSuite`: new Connect golden files.\n- `ExpressionsSchemaSuite` (regenerated `sql-expression-schema.md`), `ExpressionInfoSuite` (the examples), and the function parity test in `DataFrameFunctionsSuite`.\n- The PySpark doctests of both functions, in classic mode with ANSI mode on and off.\n\n```\nbuild/sbt \u0027catalyst/testOnly *TryEvalSuite *ExprUtilsSuite\u0027 \\\n  \u0027sql/testOnly *MathFunctionsSuite *DataFrameFunctionsSuite *ExpressionInfoSuite *ExpressionsSchemaSuite\u0027 \\\n  \u0027sql/testOnly *SQLQueryTestSuite -- -z try_arithmetic.sql\u0027 \\\n  \u0027sql/testOnly *StreamingSQLQueryTestSuite -- -z try-abs-negative\u0027 \\\n  \u0027connect-client-jvm/testOnly *PlanGenerationTestSuite -- -z try_abs -z try_negative\u0027 \\\n  \u0027connect/testOnly *ProtoToParsedPlanTestSuite -- -z try_abs -z try_negative\u0027\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60769 from MaxGekk/SPARK-62149-try-abs-negative.\n\nAuthored-by: Maxim Gekk \u003cmax.gekk@gmail.com\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n"
    },
    {
      "commit": "dc7c000d0b1f70f996ee6858ce9cd3c8f9efd819",
      "tree": "ecdf6da126024f0a1d6e829dc7996414d785cdc5",
      "parents": [
        "26c4d283a1a6b14d7da9f1a8c30a93e5faecee8f"
      ],
      "author": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Tue Nov 24 09:06:04 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Tue Nov 24 09:06:04 2026 -0800"
      },
      "message": "[SPARK-62248][SQL][SS] Fix DataFrame as-of joins with a streaming left side failing at the first micro-batch\n\n### What changes were proposed in this pull request?\n\nThis PR makes the analyzer pick the sort-merge as-of join for a DataFrame as-of join whose left side is streaming, regardless of the internal `spark.sql.join.sortMergeAsOfJoin.enabled` (default `false`).\n\n- `AsOfJoinMatchConditionResolution.materializeDataFrame` now selects sort-merge when `SQLConf.get.sortMergeAsOfJoinEnabled || join.left.isStreaming`.\n- The doc of `spark.sql.join.sortMergeAsOfJoin.enabled` says so.\n- A new internal legacy conf, `spark.sql.legacy.asOfJoin.rewriteStreamingLeftToSubquery` (default `false`), restores the previous correlated subquery rewrite for a streaming left side, so that an existing query can restart from its checkpoint.\n- The Structured Streaming migration guide describes the change for existing queries and the legacy conf.\n\nBatch DataFrame as-of joins and SQL `ASOF JOIN` are unchanged.\n\n### Why are the changes needed?\n\nSPARK-59698 allows stream-static as-of joins: each streaming row is matched against the static snapshot. SQL `ASOF JOIN` works because it always uses the stateless sort-merge operator. A DataFrame as-of join (`Dataset.joinAsOf`, PySpark `DataFrame._joinAsOf` and Spark Connect `AsOfJoin`) uses `RewriteAsOfJoin` by default instead. That rule turns the join into a correlated scalar subquery. Decorrelation then aggregates the distinct left values and joins the result back to the left side. On a streaming left side these become a streaming aggregation and a stream-stream left outer join.\n\nWithout a watermark, every such query fails at its first micro-batch.\n\n```scala\n// `stream` is a MemoryStream (t, k), `static` is a static DataFrame (bt, bk, v).\nstream.joinAsOf(static, stream(\"t\"), static(\"bt\"), stream(\"k\") \u003d\u003d\u003d static(\"bk\"),\n  \"inner\", null, true, \"backward\")\n```\n\n- Append output mode: `[UNSUPPORTED_STREAMING_OPERATOR_WITHOUT_WATERMARK] Append output mode not supported for aggregations on streaming DataFrames/DataSets without watermark.`\n- Update output mode, even for an inner as-of join: `requirement failed: Update output mode is not supported for stream-stream LeftOuter join`\n\nIt fails the same way for inner and left joins, for all three directions, with a tolerance and with `usingColumns`.\n\nWith a watermark on the as-of column of the streaming side, a query in Append output mode starts, but it runs with stateful operators (stream-stream joins and state store aggregations) and does not emit some of its rows. In four micro-batches of trades against static quotes, with a 10-second watermark:\n\n- An inner as-of join ran with 9 stateful operators and emitted no rows.\n- A left as-of join ran with 3 stateful operators, emitted each matched row one micro-batch late, and never emitted the unmatched trade.\n\nWith `spark.sql.join.sortMergeAsOfJoin.enabled\u003dtrue`, each of these queries returns the same rows as the batch join over all of its input rows, from the first micro-batch and without stateful operators.\n\nApache Spark 4.3.0 ([v4.3.0](https://github.com/apache/spark/releases/tag/v4.3.0), 2026-10-27) behaves the same way with the default configuration.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. A DataFrame as-of join with a streaming left side now runs with the stateless sort-merge as-of join.\n\n- Without a watermark, such a query now runs instead of failing at its first micro-batch.\n- With a watermark, such a query now emits each row in the micro-batch that reads it, including rows that are late for the watermark, which were dropped before. Its plan no longer has stateful operators, so it cannot restart from a checkpoint written before this PR. It fails with `STREAMING_STATEFUL_OPERATOR_NOT_MATCH_IN_STATE_METADATA` and needs a new checkpoint location, unless `spark.sql.legacy.asOfJoin.rewriteStreamingLeftToSubquery` is set to `true` before the query is built.\n\nIts keys now go through the checks of the sort-merge path during analysis, for example `AS_OF_JOIN.KEY_REFERENCE` for a key that does not reference its own side.\n\nThe migration guide item is added to `Upgrading from Structured Streaming 4.3 to 4.4`.\n\n### How was this patch tested?\n\nPass the CIs with the newly added test cases in `StreamingAsOfJoinSuite`. Without this fix, the inner and left join cases fail with `UNSUPPORTED_STREAMING_OPERATOR_WITHOUT_WATERMARK`. Another case checks that the legacy conf keeps the correlated subquery rewrite.\n\n```\n$ build/sbt \"sql/testOnly org.apache.spark.sql.streaming.StreamingAsOfJoinSuite org.apache.spark.sql.DataFrameAsOfJoinSuite org.apache.spark.sql.SortMergeAsOfJoinSuite\"\n$ build/sbt \"catalyst/testOnly org.apache.spark.sql.catalyst.optimizer.RewriteAsOfJoinSuite org.apache.spark.sql.catalyst.analysis.UnsupportedOperationsSuite\"\n```\n\nThe watermarked case and the checkpoint restart were checked manually: a checkpoint written by Apache Spark 4.3.0 restarts on `master` without this PR, and fails with the error above with this PR unless the legacy conf is `true`. A row that is late for the watermark is dropped on Apache Spark 4.3.0 and emitted with this PR.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #60794 from dongjoon-hyun/SPARK-62248.\n\nAuthored-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "26c4d283a1a6b14d7da9f1a8c30a93e5faecee8f",
      "tree": "ab5029524f56523fb621ea8419698d603e829dcb",
      "parents": [
        "afae23690cb25c1daa61716dede84274a8c6e62b"
      ],
      "author": {
        "name": "dustin",
        "email": "dustin.william.smith@gmail.com",
        "time": "Tue Nov 24 14:42:34 2026 +0100"
      },
      "committer": {
        "name": "Max Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Tue Nov 24 14:42:34 2026 +0100"
      },
      "message": "[SPARK-60843][SQL] Truncate decimals exactly when casting to INT, SMALLINT and TINYINT\n\n### What changes were proposed in this pull request?\n\n`Decimal.roundToInt`, `roundToShort` and `roundToByte` converted a BigDecimal-backed value to a `Double`, range-checked the double and returned its integer part. This PR makes them truncate exactly through `BigInteger`, as `roundToLong` already does, and range-check the truncated integer. Long-backed values keep the existing exact path.\n\nThe interpreted ANSI casts to `SMALLINT` and `TINYINT` now call `roundToShort` and `roundToByte` directly, as codegen does, instead of going through `roundToInt` and narrowing by hand.\n\n**Merge order:** this PR should be merged before #59159 (SPARK-59805), which builds on it and currently includes this branch.\n\nDropping the `Double`-based branch removes the lambdas Scala emitted for it, which changes `Decimal`\u0027s computed `serialVersionUID`. Its serialized fields are unchanged, so the audited transition for `Decimal` in `UdfSerialization` is updated to the new value.\n\n### Why are the changes needed?\n\nThese methods back the ANSI and `try_cast` casts from `DECIMAL` to `INT`, `SMALLINT` and `TINYINT`. When the fraction of a value is close enough to 1 to round up as a double, the cast silently returned a value one too high. With ANSI mode on:\n\n```sql\nSELECT CAST(CAST(\u00270.999999999999999999\u0027 AS DECIMAL(20,18)) AS INT);\n-- before: 1\n-- after:  0 (same as the non-ANSI cast)\n\nSELECT CAST(CAST(\u00271000000000.9999999999\u0027 AS DECIMAL(20,10)) AS INT);\n-- before: 1000000001\n-- after:  1000000000\n```\n\nAt the maximum or minimum of the target type, the same rounding pushes the value past the bound, so the cast fails even though the truncated result fits:\n\n```sql\nSELECT CAST(CAST(\u00272147483647.99999999\u0027 AS DECIMAL(20,8)) AS INT);\n-- before: [CAST_OVERFLOW] The value 2147483647.99999999BD of the type \"DECIMAL(20,8)\" cannot be cast to \"INT\" due to an overflow.\n-- after:  2147483647\n```\n\n`try_cast` returned the same wrong values, and `NULL` instead of the bound. A `Decimal` that holds the same number as an unscaled long (for example, read from a `DECIMAL(18, s)` column) was already truncated exactly, so the result depended on how the value happened to be represented internally.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, a bug fix. Under ANSI mode and with `try_cast`, casting a `DECIMAL` to `INT`, `SMALLINT` or `TINYINT` now truncates toward zero, as the non-ANSI cast already did. Values whose fraction used to round up as a double no longer come back one too high, and values that truncate to exactly the target type\u0027s maximum or minimum no longer fail with `CAST_OVERFLOW` (or return `NULL` from `try_cast`). Values that are out of range still overflow. Non-ANSI casts are unchanged. The SQL migration guide has a line for it under 4.3 to 4.4.\n\n### How was this patch tested?\n\nNew tests, which fail without the change:\n- `DecimalSuite`: `roundToInt`/`roundToShort`/`roundToByte` on BigDecimal-backed values whose fraction rounds up as a double, both far from the bounds (such as `0.999999999999999999` and `12345.9999999999999`) and just inside each bound, return the truncated value, matching the long-backed representation of the same value. Values just outside each bound, and a 37-digit value, still throw `CAST_OVERFLOW`.\n- `CastWithAnsiOnSuite` (also run by `TryCastSuite`): the same kinds of `decimal(20, s)` literals cast to `INT`/`SMALLINT`/`TINYINT` return the truncated value, and one unit in the last place beyond each bound fails with `CAST_OVERFLOW` (`NULL` under `try_cast`), interpreted and codegen.\n\n`DecimalSuite`, `CastWithAnsiOnSuite`, `CastWithAnsiOffSuite`, `TryCastSuite`, `DecimalExpressionSuite` and `UdfSerializationSuite` pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\nNo\n\n\nCloses #60056 from dwsmith1983/fix/decimal-round-to-int-exact.\n\nAuthored-by: dustin  \u003cdustin.william.smith@gmail.com\u003e\nSigned-off-by: Max Gekk \u003cmax.gekk@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "afae23690cb25c1daa61716dede84274a8c6e62b",
      "tree": "fab83356607c04bd54bb41cd66912a0a080d8dc6",
      "parents": [
        "117926b8b2ea7c4cc416c1b03971784a226df44e"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Tue Nov 24 13:15:22 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Tue Nov 24 13:15:22 2026 +0000"
      },
      "message": "[SPARK-62245][SQL][DOC][FOLLOWUP] Move the merge_asof tolerance migration guide entry to 4.4\n\n### What changes were proposed in this pull request?\nThis moves the migration guide entry added in #60798 from \"Upgrading from Spark SQL 4.5 to 5.0\" to \"Upgrading from Spark SQL 4.3 to 4.4\", and changes \"Since Spark 5.0\" to \"Since Spark 4.4\".\n\n### Why are the changes needed?\nSPARK-62245 is being backported to `branch-4.4` and `branch-4.x`, so the change first ships in 4.4.0.\n\n### Does this PR introduce _any_ user-facing change?\nNo, documentation only.\n\n### How was this patch tested?\nDocumentation only.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60819 from LukaZdravic/asof-62245-migration-note.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "117926b8b2ea7c4cc416c1b03971784a226df44e",
      "tree": "abf85293b1a0b2c5e55b19a7bab36263ad87b193",
      "parents": [
        "2eccc39264ba92d131676e6810081d8b3bc39aaa"
      ],
      "author": {
        "name": "Ganesha S",
        "email": "ganeshashree2@gmail.com",
        "time": "Tue Nov 24 12:20:12 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Tue Nov 24 12:20:12 2026 +0000"
      },
      "message": "[SPARK-62259][SQL] Rebuild stale query column names when ALTER VIEW leaves SCHEMA EVOLUTION\n\n### What changes were proposed in this pull request?\r\n\r\n`ALTER VIEW ... WITH SCHEMA \u003cmode\u003e` copies the view\u0027s stored query column names into the new mode. When the view is in `SCHEMA EVOLUTION` mode and those names don\u0027t match the view schema\u0027s column count, this PR rebuilds them from the schema instead. Otherwise nothing changes.\r\n\r\nStale names with the same count as the schema (for example after a column reorder) are still kept, because they can\u0027t be told apart from a column list without analyzing the view. That case is tracked in SPARK-62261 as a follow-up.\r\n\r\n### Why are the changes needed?\r\n\r\nSince SPARK-52417, EVOLUTION views no longer update their stored query column names, so names written by Spark 4.0 go stale once the schema evolves. Switching such a view to another mode made every later read fail:\r\n\r\n```sql\r\nCREATE TABLE t (c1 INT, c2 INT) USING parquet;\r\nCREATE VIEW v WITH SCHEMA EVOLUTION AS SELECT * FROM t;\r\n-- Stand-in for the names Spark 4.0 stores:\r\nALTER VIEW v SET TBLPROPERTIES (\r\n  \u0027view.query.out.numCols\u0027 \u003d \u00272\u0027, \u0027view.query.out.col.0\u0027 \u003d \u0027c1\u0027, \u0027view.query.out.col.1\u0027 \u003d \u0027c2\u0027);\r\nALTER TABLE t ADD COLUMNS (c3 INT);\r\nSELECT * FROM v;                        -- works; the view schema now has 3 columns\r\nALTER VIEW v WITH SCHEMA COMPENSATION;\r\nSELECT * FROM v;                        -- [INTERNAL_ERROR] ... Corrupted view metadata detected\r\n```\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\nYes. A view like the one above stays readable after the ALTER instead of failing with `INTERNAL_ERROR`. Views that are readable today behave as before.\r\n\r\n### How was this patch tested?\r\n\r\nNew tests in `v1.AlterViewSchemaBindingSuite`. They cover leaving EVOLUTION with stale names (these fail without this fix), and views whose stored names must stay unchanged: a view with a column list, a Hive-created view, and a non-EVOLUTION view.\r\n\r\n### Was this patch authored or co-authored using generative AI tooling?\r\n\r\nGenerated-by: Claude Code (Claude Opus 5.5)\r\n\nCloses #60800 from ganeshashree/SPARK-62259.\n\nLead-authored-by: Ganesha S \u003cganeshashree2@gmail.com\u003e\nCo-authored-by: Ganesha S \u003cganesha.s@databricks.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "2eccc39264ba92d131676e6810081d8b3bc39aaa",
      "tree": "84dc3d9963e55f5ccc343973c3659d9214fff9e7",
      "parents": [
        "662f09cfca2922d6b22dcf99e37627200cda5925"
      ],
      "author": {
        "name": "Xiduo You",
        "email": "ulyssesyou18@gmail.com",
        "time": "Tue Nov 24 19:24:10 2026 +0800"
      },
      "committer": {
        "name": "Xiduo You",
        "email": "ulyssesyou@apache.org",
        "time": "Tue Nov 24 19:24:10 2026 +0800"
      },
      "message": "[SPARK-61785][SQL] Support keyed layouts in the union shuffle push-down\n\n### What changes were proposed in this pull request?\n\n`PushDownShuffleExchangeThroughUnion` may now pick a V2 keyed layout (`KeyedPartitioning`) as the union\u0027s output, not only a hash layout. Both the exchange it replaces and the target can be keyed.\n\n- A keyed target keeps the union children that already report the picked domain, and an unmarked child reporting a subset of its keys keeps its layout too. A child carrying the unknown-keys marker has to declare the domain\u0027s key list in the same order and still route by hash; one that lost its routing is laid out instead, which routes its undeclared keys again.\n- A leg laid out on the domain records `HASH_ROUTING`. When the concatenation is not grouped, a `GroupPartitionsExec` groups it, and the grouped layout keeps the full-key claim only (`ROUTING_LOST`).\n- Candidate admission is `canEvaluatePartitioning \u0026\u0026 KeyedShuffleSpec(keyed, required).canCreatePartitioning`: the rebuilt union\u0027s layout is a result and cannot answer for the shuffle template, so the question, including the V2 co-partition key requirement, is settled on the candidate.\n- After the rebuild the child has to satisfy the requirement as rebuilt and pair with the siblings; the rule\u0027s own `allowPartitionKeysSubsetOfClusterKeys` is applied there, against the rebuilt layout.\n- `KeyLayout` gains `describesSameLayoutState`, which `reportsDomain` reads beside the key-list comparison; the target\u0027s key set is taken once per target and only when the comparison is between two keyed layouts.\n- A failed joint attempt is retried with keyed targets off, which is the base branch\u0027s policy, before the inputs are fixed one by one.\n- When the whole-plan check rejects the proposal, the rule plans the same query with keyed targets off and keeps that plan when the whole plan holds. The pass is skipped when the plan reports no keyed layout, since it would then repeat the first pass. With `spark.sql.adaptive.pushDownShuffleThroughUnion.partialReplay.enabled` (off by default), the rule also replays keyed choices on top of that plan one site at a time, and, when that pass changes nothing or fails, replays the proposal over the input plan, where a rejected site takes the layout of the exchange it removes; a replayed site is kept only while the whole plan still holds.\n- `rebuildChild` declines a target that loses a recorded repartition origin before the whole-plan check sees it, so the site falls back to its next target instead of rejecting the proposal, and the other sites keep their keyed targets.\n\nKeyed cases the rule supports, each covered end to end:\n\n1. A bucketed table beside a leg without a layout: the scan keeps its partitions, only the other leg is laid out on the domain, and a key the domain does not declare is hash-routed and stays whole (1 shuffle). Shape: a union over a `VALUES` leg.\n2. An unmarked leg holding a subset of the target\u0027s keys keeps its layout, whatever order its keys are in, since the grouping above the union regroups them; the bigger domain is the target (1 shuffle). Shape: domains `{1,2}` and `{1,2,3}`, and `{2,1}` beside `{1,2,3}`.\n3. Legs declaring different domains: one domain is picked and the other legs are laid out on it (2 shuffles). Shape: domains `{1,2}` and `{1,3}`.\n4. Two of three legs report one keyed domain and the third is a `REPARTITION(2, id)` leg: the keyed domain keeps more rows, so it wins the ranking (kept bytes, then kept children), and the repartition leg is laid out on it on top of its own exchange, since a repartition is not retargeted to a keyed layout (2 shuffles).\n5. A keyed union side in a merge join keeps its own domain and pairs with a keyed table as it stands (1 shuffle).\n6. A leg whose layout the planner marked as hash-routed is kept beside an unmarked scan on the same domain (2 shuffles: the join\u0027s alignment and the values leg). Shape: a `RIGHT OUTER` join between a table bucketed by `identity(id)` and one bucketed by `bucket(2, id)`: the planner lays the `bucket(2, id)` right side out on the left side\u0027s `identity(id)` domain, which marks that side, and the right outer join reports the right side\u0027s marked layout. Needs `keepJoinBranches` on, or a join branch is never kept.\n7. A grouped but unsorted domain supplies the target as it stands (1 shuffle). Shape: an inner union in child order under an aggregate; the rebuild accepts the unsorted order because its final check compares key sets, and the grouping above sorts the legs into it.\n\nNew config `spark.sql.adaptive.pushDownShuffleThroughUnion.allowV2Bucketing.enabled` (off by default) gates the keyed targets, and `spark.sql.adaptive.pushDownShuffleThroughUnion.partialReplay.enabled` (off by default) keeps a keyed replay on top of the hash-only pass. The doc of `spark.sql.adaptive.pushDownShuffleThroughUnion.enabled` now says the shuffle and the target are hash or keyed, and that a V2 keyed target additionally requires the keyed permission.\n\nWith every leg reporting the same domain, `EnsureRequirements` groups the union in place and adds no exchange, so the rule has no site there.\n\n### Why are the changes needed?\n\nV2 connectors report `KeyedPartitioning`, and the rule only accepted hash layouts. A union over bucketed tables therefore had to shuffle every row even when a leg already sat on a keyed domain. Keeping the domain leaves only the legs without one to be laid out.\n\nA keyed target that breaks an ancestor requirement or a recorded layout rejects the whole proposal. Falling back to the base branch\u0027s policy keeps the push-down that policy gives every other site, including sites that have to take one layout together.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, two new configs:\n\n- `spark.sql.adaptive.pushDownShuffleThroughUnion.allowV2Bucketing.enabled` (off by default) gates the keyed targets. A keyed target is reachable only when all of the following hold:\n  - `spark.sql.adaptive.pushDownShuffleThroughUnion.enabled` turned on (off by default), otherwise the rule does not run;\n  - `spark.sql.unionOutputPartitioning` left on (on by default), since the rebuilt union has to report the keyed layout;\n  - `spark.sql.sources.v2.bucketing.enabled` left on (on by default);\n  - `spark.sql.sources.v2.bucketing.shuffle.enabled` turned on (off by default), since a child has to be shuffleable onto the domain;\n  - `spark.sql.sources.v2.bucketing.partiallyClusteredDistribution.enabled` left off (off by default).\n- `spark.sql.adaptive.pushDownShuffleThroughUnion.partialReplay.enabled` (off by default) replays keyed choices on top of the hash-only plan the rule settles a rejected proposal on, and replays the proposal over the input plan when that pass changes nothing or fails. It only takes effect when the rule runs and a whole-plan check rejects the proposal.\n\nA target naming only part of the consumer\u0027s cluster keys also needs `spark.sql.sources.v2.bucketing.requireAllClusterKeysForCoPartition.enabled` turned off (on by default) and `spark.sql.adaptive.pushDownShuffleThroughUnion.allowPartitionKeysSubsetOfClusterKeys.enabled` turned on (off by default). A target partitioned by a transform over the cluster keys, such as `bucket(n, id)`, needs only the latter, whatever the co-partition key requirement is set to.\n\nA source-reported keyed layout is kept only when the consumer\u0027s shuffle group cannot coalesce: `spark.sql.adaptive.coalescePartitions.enabled` off, `spark.sql.adaptive.pushDownShuffleThroughUnion.keepNonCoalescibleBranches.enabled` on, or a consumer whose inputs do not all reach an exchange, which the rule admits without either setting.\n\nKeeping a join branch (case 6) additionally needs `spark.sql.adaptive.pushDownShuffleThroughUnion.keepJoinBranches.enabled` on (off by default).\n\nNo plan changes under the defaults above.\n\n### How was this patch tested?\n\n- `KeyGroupedPartitioningSuite`: end-to-end tests over V2 bucketed tables, asserting the executed plan and its shuffle count. They include a pair of window sites that share a hash target, a failed joint attempt that keeps the base push-down, two join inputs that share a hash target at both replay settings, and the keyed domain the planner pairs a union on at both replay settings.\n- `PushDownShuffleExchangeThroughUnionSuite`: plan-level tests for the keyed paths the end-to-end shapes do not reach, such as a marked leg whose key order differs, a leg that lost its routing, a recorded repartition origin that declines only the site that breaks it, a replay that takes a removed layout when no keyed layout exists, a replay that keeps a joint operator\u0027s hash target, and a replay that visits a site the first pass skipped; also the fallback with `partialReplay.enabled` off.\n- `ShuffleSpecSuite`: the `KeyLayout` comparisons, including the type clause that distinguishes two empty key lists.\n- Suites: `ShuffleSpecSuite` 47/47, `PushDownShuffleExchangeThroughUnionSuite` 142/142, `KeyGroupedPartitioningSuite` 272/272.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: DeepSeek Flash\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\n\nCloses #60553 from ulysses-you/worktree-pushdown-keyed-union.\n\nAuthored-by: Xiduo You \u003culyssesyou18@gmail.com\u003e\nSigned-off-by: Xiduo You \u003culyssesyou@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "662f09cfca2922d6b22dcf99e37627200cda5925",
      "tree": "4a68ce80b11059b3dc97ad9316f08ec7322411f4",
      "parents": [
        "cc06d93f74e7482234fb9bb7399e3aad1dbe615a"
      ],
      "author": {
        "name": "shuxuwan",
        "email": "232565519+shuxuwan@users.noreply.github.com",
        "time": "Tue Nov 24 18:30:52 2026 +0800"
      },
      "committer": {
        "name": "Ruifeng Zheng",
        "email": "ruifengz@apache.org",
        "time": "Tue Nov 24 18:30:52 2026 +0800"
      },
      "message": "[SPARK-62121][ML] Fix KMeans auto solver density check\n\n### Changes\n\nFix `KMeans.preferBlockSolver` so the `auto` solver sums the per-feature non-zero counts from the `numNonZeros` summary instead of the feature indices. This makes `solver\u003dauto` actually select the block solver for dense datasets as documented.\n\nFixing the density check surfaced a latent bug in the block solver: `initialize` deduplicates centers, so a dataset with fewer distinct points than `k` yields fewer than `k` centers, but `trainWithBlock` passed the requested `k` to `KMeansAggregator` and failed with `ArrayIndexOutOfBoundsException`. It now uses the actual number of initialized centers, matching the row solver\u0027s behavior. This bug was previously hidden because `auto` always selected the row solver.\n\nAdded unit tests covering dense/sparse auto selection and the fewer-distinct-points case.\n\n### Background\n\n`activeIterator` yields `(index, count)` pairs, so `map(_._1)` sums feature indices. The resulting sum is at most `numFeatures * (numFeatures - 1) / 2`, far below the `count * numFeatures * 0.5` threshold for any dataset with at least as many rows as features, so `auto` has always chosen `row` since the block solver was introduced in SPARK-30661. Dense datasets never benefit from the block solver.\n\nBefore this fix, `preferBlockSolver` also ran a full-dataset aggregation job before every training run, so for dense data the scan was pure overhead. In a benchmark of 384 concurrent KMeans jobs on the same hardware, explicitly setting `solver\u003drow` (which kept the effective algorithm unchanged but skipped the scan) improved the throughput score by 9.7% and reduced the slowest job\u0027s elapsed time by 8.9%.\n\n### User-facing change\n\nYes. `solver\u003dauto` (the default) now behaves as documented and selects the block solver for dense input. Users who want to force the row solver can set `solver\u003drow`. The block solver also no longer fails when the training data contains fewer distinct points than `k`.\n\n### Testing\n\nAdded unit tests in `KMeansSuite`. Ran on master (87d177b) with JDK 21:\n\n    build/sbt \"mllib/testOnly org.apache.spark.ml.clustering.KMeansSuite\"\n    ...\n    [info] Tests: succeeded 18, failed 0, canceled 0, ignored 0, pending 0\n    [info] All tests passed.\n\nReverting only the `map(_._2)` change makes the dense/sparse test fail. `mllib` scalastyle (main + test): 0 errors, 0 warnings.\n\nCloses #60748 from shuxuwan/SPARK-62121-kmeans-density.\n\nAuthored-by: shuxuwan \u003c232565519+shuxuwan@users.noreply.github.com\u003e\nSigned-off-by: Ruifeng Zheng \u003cruifengz@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "cc06d93f74e7482234fb9bb7399e3aad1dbe615a",
      "tree": "5edc0687b421dc6b69015bf4c7d306ffaaf0c41e",
      "parents": [
        "77308eb9b3832d62c3bc5f1f1245dc95ea69df70"
      ],
      "author": {
        "name": "Vladan Vasić",
        "email": "vladan.vasic@databricks.com",
        "time": "Tue Nov 24 06:11:57 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 06:11:57 2026 +0000"
      },
      "message": "[SPARK-61004][SQL] Extract shared SHOW command analysis helpers\n\n### What changes were proposed in this pull request?\n\nExtract reusable analysis helpers and keep the existing rules as their callers:\n\n- Extend `CatalogIdentifierResolution` with current and explicit namespace resolution, optional\n  metadata loading, and input origin/tag preservation.\n- Move SHOW TABLES, SHOW TABLE EXTENDED without PARTITION, SHOW VIEWS and SHOW FUNCTIONS lowering\n  into `ShowCommandHelper`, preserving namespace validation, V1 guards and output attributes.\n- Share the legacy SHOW TABLES column rename between `KeepLegacyOutputs` and extended listings.\n\n`ResolveSessionCatalog` supplies its configuration lazily, preserving an overridden owning-rule\nconfiguration and its lookup timing. Standalone helper calls default to the active configuration.\n\nJira: https://issues.apache.org/jira/browse/SPARK-61004\n\n\n### Why are the changes needed?\n\nNamespace resolution and SHOW lowering are embedded in analyzer rules, and the legacy first-column\nrename is duplicated. These helpers expose the per-command operations for reuse while retaining\nthe current analyzer pipeline\u0027s configuration, catalog-routing and error-ordering contracts.\n\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. This preserves current Spark behavior and adds no SQL feature or configuration.\n\n\n### How was this patch tested?\n\nWith JDK 21 and `build/sbt -Phive`, using the normal project dependency set:\n\n- Full `PlanResolutionSuite`: 107 tests passed.\n- Catalyst `CatalogSuite`: 7 tests passed.\n- V1/V2 `ShowTablesSuite`, `ShowViewsSuite`, `ShowFunctionsSuite` and `ShowNamespacesSuite`:\n  159 tests passed across all 8 suites, including the V2-tagged suites.\n- `SQLQueryTestSuite` for `show-commands.sql`, `show-tables.sql` and `show-views.sql`:\n  6 execution/analyzer golden cases passed with no golden changes.\n- Hive `ShowTablesSuite`, `ShowFunctionsSuite` and `ShowNamespacesSuite`: 98 tests passed.\n- `catalyst/scalastyle`, `catalyst/Test/scalastyle`, `sql/scalastyle` and\n  `sql/Test/scalastyle`: zero errors or warnings. Whitespace, line-length and ASCII checks passed.\n\nThe two owner-configuration regression cases were verified to fail without the lazy forwarding\nand pass with it; the deferred-lookup case passes in both versions.\n\nThe new plan-level tests cover opposite owner/ambient configuration values, exact owning-config\nlookup counts, namespace errors before configuration reads, and paths that require no configuration.\nThe existing standalone helper matrix remains covered. Namespace tests exercise current versus\nexplicit catalog-root targets, metadata loading, direct and rule-level origin/tag preservation,\nand restoration of a direct caller\u0027s origin.\n\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Codex (GPT-6)\n\nCloses #60169 from vladanvasi-db/vladanvasi-db/show-namespace-helpers.\n\nAuthored-by: Vladan Vasić \u003cvladan.vasic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "77308eb9b3832d62c3bc5f1f1245dc95ea69df70",
      "tree": "8f6cddd572048b7d9ecc7751a53316478e0d1e64",
      "parents": [
        "ef6fa61f1fb5d7cfb3b8d0f46302e80c2204c241"
      ],
      "author": {
        "name": "marko-radoicic-db",
        "email": "marko.radoicic@databricks.com",
        "time": "Tue Nov 24 06:08:53 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 06:08:53 2026 +0000"
      },
      "message": "[SPARK-62126][SQL][TEST] Add SQL UDF tests for scalar functions in join conditions\n\n### What changes were proposed in this pull request?\n\nThis PR adds golden-file tests for SQL scalar UDFs used in `JOIN ... ON` conditions to `sql/core/src/test/resources/sql-tests/inputs/sql-udf.sql`. The new cases cover:\n\n- A temporary SQL UDF (`foo3_1h`) in an inner join, created and dropped within the test.\n- A SQL UDF in a `LEFT OUTER JOIN` condition.\n- A SQL UDF in a `LEFT SEMI JOIN` condition.\n- A SQL UDF with a parameter default (`foo3_1i`) in an inner join.\n\nThe corresponding `results/sql-udf.sql.out` and `analyzer-results/sql-udf.sql.out` golden files are regenerated. Existing entries are unchanged.\n\n### Why are the changes needed?\n\nThe existing `-- in join` cases in `sql-udf.sql` do not cover temporary SQL UDFs, outer or semi joins, or functions that rely on parameter defaults inside a join condition. These cases check that the function inputs are inlined correctly into the join condition for these forms.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. This PR only adds test cases and golden files.\n\n### How was this patch tested?\n\nThe golden files were regenerated with `SPARK_GENERATE_GOLDEN_FILES\u003d1`:\n\n```\nSPARK_GENERATE_GOLDEN_FILES\u003d1 build/sbt \"sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z sql-udf.sql\"\n```\n\nThe regeneration run completed successfully, and the regenerated output for the new queries was reviewed. The diff contains only the added entries for the new queries.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\n\nCloses #60753 from marko-radoicic-db/sql-udf-join-condition-tests.\n\nAuthored-by: marko-radoicic-db \u003cmarko.radoicic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "ef6fa61f1fb5d7cfb3b8d0f46302e80c2204c241",
      "tree": "3c38bf0ff59ba2d91de3d4b77edf5cb06eb2e619",
      "parents": [
        "7c360b53a4aa2171e86a0b40fd4725331c23b0a6"
      ],
      "author": {
        "name": "marko-radoicic-db",
        "email": "marko.radoicic@databricks.com",
        "time": "Tue Nov 24 06:04:09 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 06:04:09 2026 +0000"
      },
      "message": "[SPARK-62127][SQL] Extract SQL function input inlining helpers from Analyzer\n\n### What changes were proposed in this pull request?\n\nMoves the logic that replaces SQL function input aliases with their input expressions in join conditions into helpers in `object Analyzer`: `inlineSQLFunctionInputs`, `buildSQLFunctionInputAliasMap` and `replaceSQLFunctionInputAttributes`. The join case of `ResolveSQLFunctions` now calls `inlineSQLFunctionInputs`.\n\nThe attribute replacement uses `transformUp` instead of `transform`. The pattern only matches leaf `Attribute` nodes, and the replacement expressions are never traversed again, so both traversals produce the same result. The replacement inputs come from the `OneRowRelation` project built in `rewriteSQLFunctions`, so they cannot reference the alias attributes that the map is keyed on.\n\n### Why are the changes needed?\n\nThis is a refactor with no functional change. Other resolution paths, such as join resolution in the single-pass resolver, can apply the same substitution through these helpers and produce identical plans.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo.\n\n### How was this patch tested?\n\nNo new tests. The change is covered by the existing SQL UDF join-condition cases in `sql/core/src/test/resources/sql-tests/inputs/sql-udf.sql` (around lines 639-651, for example `SELECT * FROM t1 JOIN t2 ON foo3_1a(t1.c1, t2.c2) \u003e\u003d 2;`), which go through this rewrite path. I did not run these suites or compile catalyst for this PR, so the result is unverified.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\n\nCloses #60754 from marko-radoicic-db/sql-function-input-inlining-helpers.\n\nAuthored-by: marko-radoicic-db \u003cmarko.radoicic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "7c360b53a4aa2171e86a0b40fd4725331c23b0a6",
      "tree": "4c50a02acf9134e6c291811941c7f034c6b4d183",
      "parents": [
        "36f0c9c5b367134da1dba1951995bcbe66b4ce31"
      ],
      "author": {
        "name": "johannes-ehls-db",
        "email": "johannes.ehls@databricks.com",
        "time": "Tue Nov 24 06:02:12 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 06:02:12 2026 +0000"
      },
      "message": "[SPARK-62083][SQL][TEST] Add golden tests for functions whose rewrite uses an argument twice\n\n### What changes were proposed in this pull request?\n\nThis PR adds golden test cases to `scalar-subquery-select.sql` for functions that are rewritten into an expression that references an argument more than once: `nullif`, `between` and `decode`. The arguments are scalar subqueries (also correlated), an aggregate, a window function and a lambda variable, with `spark.sql.alwaysInlineCommonExpr` on and off.\n\n### Why are the changes needed?\n\nWith `spark.sql.alwaysInlineCommonExpr\u003dtrue`, `nullif(a, b)` is rewritten to `NullIfResult(EqualTo(a, b), a)`, so the same resolved argument occurs twice in the replacement. The single-pass resolver can resolve such an argument a second time (SPARK-62083). These cases pin the results of these shapes, so that changes to how the analyzer handles duplicated arguments are covered by golden files.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo, test-only.\n\n### How was this patch tested?\n\nGenerated the golden files with `SPARK_GENERATE_GOLDEN_FILES\u003d1 build/sbt \"sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z scalar-subquery-select.sql\"` and ran the same suite again without the flag.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #60719 from johannes-ehls-db/subtree-boundary-scopes.\n\nAuthored-by: johannes-ehls-db \u003cjohannes.ehls@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n"
    },
    {
      "commit": "36f0c9c5b367134da1dba1951995bcbe66b4ce31",
      "tree": "7a91a779277126832a5a228effd928d326c45846",
      "parents": [
        "e2132f31c769632c5fd65c6b90d0de837e8a0e68"
      ],
      "author": {
        "name": "aleksandar-trajkovic-db",
        "email": "aleksandar.trajkovic@databricks.com",
        "time": "Tue Nov 24 05:59:29 2026 +0000"
      },
      "committer": {
        "name": "Uros Bojanic",
        "email": "221401595+uros-b@users.noreply.github.com",
        "time": "Tue Nov 24 05:59:29 2026 +0000"
      },
      "message": "[SPARK-61982][SQL] Classify PostgreSQL permission-denied errors during JDBC schema resolution\n\n### What changes were proposed in this pull request?\n\nAdd the dialect hook `JdbcDialect.isPermissionDeniedException` (PostgreSQL: SQLSTATE 42501). When it matches, raise the new `JDBC_EXTERNAL_ENGINE_PERMISSION_ERROR` (SQLSTATE 42501), with the subclass `DURING_OUTPUT_SCHEMA_RESOLUTION` or `DURING_QUERY_EXECUTION`. It has the same parameters and subclasses as `JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR`, and the driver exception is kept as the cause. Both errors are now built in `QueryExecutionErrors`. The shared Docker suites gain restricted-user hooks so other dialects can opt in to the permission tests.\n\n### Why are the changes needed?\n\nA PostgreSQL permission-denied error should be reported as a permission error. Today it is unclassified (SPARK-59336 stopped it from being reported as a syntax error): `spark.read.format(\"jdbc\")` as a user without `SELECT` throws the raw `PSQLException: ERROR: permission denied ...`, a JDBC catalog read reports `FAILED_JDBC.LOAD_TABLE`, and a denial on the data query (e.g. after a `sessionInitStatement` role switch) fails the job with the raw driver error.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. For PostgreSQL, a permission-denied error now raises `JDBC_EXTERNAL_ENGINE_PERMISSION_ERROR`. In Spark 4.3.0 it was reported as `JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR`; on master since SPARK-59336 (unreleased) it is the raw `SQLException` (V1 read and data query) or `FAILED_JDBC.LOAD_TABLE` (catalog). If another dialect is also registered for `jdbc:postgresql` URLs, a catalog read of such a table used to report it as not found; it now raises the same error. The hook is `Since(\"4.4.0\")`, so this should also be merged to `branch-4.4`.\n\n### How was this patch tested?\n\nNew tests in `JDBCSuite`, `PostgresDialectSuite`, and the shared Docker suites `SharedJDBCIntegrationSuite` and `V2JDBCTest` (run against PostgreSQL).\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60673 from aleksandar-trajkovic-db/SPARK-61982-jdbc-postgres-permission-denied.\n\nAuthored-by: aleksandar-trajkovic-db \u003caleksandar.trajkovic@databricks.com\u003e\nSigned-off-by: Uros Bojanic \u003c221401595+uros-b@users.noreply.github.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "e2132f31c769632c5fd65c6b90d0de837e8a0e68",
      "tree": "8e237a7a118cd6584c14e1f9e695c17551e1a0c9",
      "parents": [
        "efaeec37c9b9c0fbceb7862ef624d53e559ffe5a"
      ],
      "author": {
        "name": "Sudhanva Huruli",
        "email": "sudhanva.huruli@databricks.com",
        "time": "Tue Nov 24 14:53:17 2026 +0900"
      },
      "committer": {
        "name": "Hyukjin Kwon",
        "email": "hyukjin.kwon@databricks.com",
        "time": "Tue Nov 24 14:53:17 2026 +0900"
      },
      "message": "[SPARK-62033][SQL] Keep session-catalog table comment and default collation across ALTER TABLE\n\n### What changes were proposed in this pull request?\n\n`V2SessionCatalog.alterTable` keeps the table comment and default collation unless a change sets or removes that property. It previously read both from `properties`, which does not hold them for a table created by `CREATE TABLE`, so a change naming one of them cleared the other. The v1 `SET/UNSET TBLPROPERTIES` path already behaves this way. Other fields are unchanged.\n\n### Why are the changes needed?\n\nOn the session catalog, `COMMENT ON TABLE t IS \u0027new comment\u0027` clears the default collation, and `ALTER TABLE t DEFAULT COLLATION UNICODE` clears the comment. The comment tests of #60462 ([SPARK-57670][SDP] Remove table properties dropped from the dataset definition), which alters pipeline tables through this method, depend on this fix.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. An `ALTER TABLE` or `COMMENT ON TABLE` no longer clears a session-catalog table\u0027s comment or default collation when it does not name it. No migration-guide entry: this restores the v1 behavior.\n\n### How was this patch tested?\n\nNew tests in `V2SessionCatalogTableSuite` and `DDLSuite`, the latter run by `InMemoryCatalogedDDLSuite` and `HiveDDLSuite`. Removing a default collation is covered only in `V2SessionCatalogTableSuite`, since SQL cannot remove it. All new tests fail without the change.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #60680 from suhuruli/sdp/session-catalog-keep-comment-collation.\n\nAuthored-by: Sudhanva Huruli \u003csudhanva.huruli@databricks.com\u003e\nSigned-off-by: Hyukjin Kwon \u003chyukjin.kwon@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "efaeec37c9b9c0fbceb7862ef624d53e559ffe5a",
      "tree": "16c6c308709d0dbf72ae604de7a6b85777e1f77c",
      "parents": [
        "b74438dc0f8df9822a378bb68766778f3ea859ed"
      ],
      "author": {
        "name": "Sudhanva Huruli",
        "email": "sudhanva.huruli@databricks.com",
        "time": "Tue Nov 24 14:50:24 2026 +0900"
      },
      "committer": {
        "name": "Hyukjin Kwon",
        "email": "hyukjin.kwon@databricks.com",
        "time": "Tue Nov 24 14:50:24 2026 +0900"
      },
      "message": "[SPARK-59268][SDP] Preserve desired column metadata during additive schema evolution\n\n### What changes were proposed in this pull request?\n\nOn incremental schema evolution, `DatasetManager.evolveTable` merged schemas with `SchemaMergingUtils.mergeSchemas`, which keeps the current field\u0027s metadata for shared columns. This PR adds `SchemaMergingUtils.mergeSchemasWithDataMetadata`, which takes field metadata from the desired schema for shared fields, including nested ones. `materializeTable` uses it for incrementally updated streaming tables. The AutoCDC auxiliary table and other callers keep `mergeSchemas`.\n\n- `SchemaInferenceUtils.rejectUnsupportedNestedTypeChanges` raises `PIPELINE_NESTED_COMPLEX_TYPE_COMMENT_CHANGE_UNSUPPORTED` for a comment change under an array or map element that is itself an array or map, naming every such field.\n- The internal SQL conf `spark.sql.legacy.pipelines.streamingTable.keepExistingColumnMetadata` (default `false`) keeps the table\u0027s existing column metadata on shared columns.\n\n### Why are the changes needed?\n\nA comment added, changed, or removed on a streaming table\u0027s column was never applied between runs, while the same change on a materialized view was. Users who set comments directly on a streaming table need a way to keep them without a full refresh.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Column comment changes are applied on incremental updates of streaming tables.\n\nRelease note: incremental updates of Declarative Pipelines streaming tables now apply column comment changes from the pipeline\u0027s declared or inferred schema, removed comments included, and a comment change under consecutive arrays or maps fails the update with a comment-specific error, also for materialized views and full refreshes (SPARK-59188). Set `spark.sql.legacy.pipelines.streamingTable.keepExistingColumnMetadata` to `true` to keep the table\u0027s existing column comments, as in Spark 4.4.\n\n### How was this patch tested?\n\nThe `SPARK-59268` tests in `MaterializeTablesSuite` run with the setting both `false` and `true`, and `AutoCdcAuxiliaryTableMaterializationSuite`, `SchemaInferenceUtilsSuite`, and `SchemaMergingUtilsSuite` cover the merge and the error. I ran the pipelines suites, `HiveMaterializeTablesSuite` and scalastyle after merging master.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\n\n\nCloses #60463 from suhuruli/sdp/SPARK-59268-schema-evo-metadata.\n\nAuthored-by: Sudhanva Huruli \u003csudhanva.huruli@databricks.com\u003e\nSigned-off-by: Hyukjin Kwon \u003chyukjin.kwon@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b74438dc0f8df9822a378bb68766778f3ea859ed",
      "tree": "8dfaa5ca42889dfe8351bb5a4905a3ee001b8095",
      "parents": [
        "b81eaca79e6ee961944dafdddd3aa77a155a77e4"
      ],
      "author": {
        "name": "Siying Dong",
        "email": "dong.sy@gmail.com",
        "time": "Tue Nov 24 11:24:00 2026 +0900"
      },
      "committer": {
        "name": "Jungtaek Lim",
        "email": "kabhwan.opensource@gmail.com",
        "time": "Tue Nov 24 11:24:00 2026 +0900"
      },
      "message": "[SPARK-60850][SS] Preserve event time for simple streaming joins\n\n### What changes were proposed in this pull request?\n\nPreserve a watermarked timestamp that column pruning would otherwise remove from a new stream-stream equality join. The timestamp stays in the ordinary input and join state row, so the join can filter late records even when the final projection only needs the join key.\n\nThe scope is intentionally narrow: the plan must contain exactly one stateful operator, that operator must be a stream-stream join with equality predicates and no residual condition after predicate pushdown, and each input must have at most one distinct watermarked `TimestampType` attribute. Plans with multiple stateful operators, unexpanded CTE references, residual predicates such as time ranges, or ambiguous or window-valued watermarks keep legacy pruning. The eligibility check is part of the checkpoint state schema contract. Changing which plans qualify requires a separately pinned mode or state migration.\n\nThe internal `spark.sql.streaming.join.preserveEventTimeColumns.enabled` setting defaults to `true` for new queries and is pinned in offset-log metadata. Existing checkpoints without the setting use legacy `false`. On restart, offset-log metadata supplies the recorded value to query optimization.\n\n### Why are the changes needed?\n\nWhen only a join key is referenced downstream, column pruning can remove the watermarked timestamp from a join input. The physical join then has no late-row predicate for that input and can admit records older than its watermark. Restricting retention to simple equality joins avoids changing the state-eviction behavior of range and chained joins in this PR.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. New queries in the supported shape now filter late rows that previously passed through, and their join state includes the timestamp. Existing checkpoints without the setting keep their previous pruning and state layout. Changing the session setting on restart does not override the value recorded in the checkpoint.\n\nEditing a join or a filter that compares its two inputs can change which columns the join stores. On restart, Spark rejects a value schema mismatch. It also rejects an otherwise type-compatible timestamp replacement when the names differ and exactly one field is watermarked. Spark reports `STREAM_STREAM_JOIN_STATE_TIMESTAMP_COLUMN_CHANGED` for that case. The check uses the existing state schema and preserves renames that keep the watermark. A new checkpoint with retention enabled cannot restart on a binary that does not know the setting and stored row layout. The downgrade-then-upgrade round trip is also unsupported.\n\n### How was this patch tested?\n\n- `ColumnPruningSuite` and 54 focused streaming join cases passed. The predicate pushdown tests check that one-sided filters allow retention and filters that compare both inputs keep legacy pruning.\n- Re-ran all 12 timestamp replacement cases with a recovery assertion. They cover both join inputs and join state formats 2, 3, and 4. Restarting the original query after the rejection still returns the buffered match.\n- `StateSchemaCompatibilityCheckerSuite`, `OffsetSeqLogSuite`, and `StreamingV2ScanPushDownSuite` passed, along with the real-time mode offset-log purge regression.\n- Catalyst and SQL Scalastyle checks and `git diff --check` passed.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Codex (GPT-6)\n\nCloses #60068 from siying/codex/es-2141110-stream-join-watermark.\n\nAuthored-by: Siying Dong \u003cdong.sy@gmail.com\u003e\nSigned-off-by: Jungtaek Lim \u003ckabhwan.opensource@gmail.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "b81eaca79e6ee961944dafdddd3aa77a155a77e4",
      "tree": "bc236a635683af58842b3874ad27f2d6c6b43e53",
      "parents": [
        "8621489fe807e1b61d68f58add00fcf6b6c67132"
      ],
      "author": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Mon Nov 23 16:03:02 2026 -0800"
      },
      "committer": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Mon Nov 23 16:03:02 2026 -0800"
      },
      "message": "[SPARK-62107][SQL] Keep the zero digit when to_char formats zero with no fractional digits\n\n### What changes were proposed in this pull request?\n\n`to_char` (and its alias `to_varchar`) leaves out the ones digit when it formats a zero value with some format strings that have no digits after the decimal point:\n\n```sql\nSELECT to_char(0, \u0027999\u0027);   -- \u0027   \u0027 (three spaces)\nSELECT to_char(0, \u00279\u0027);     -- \u0027 \u0027\nSELECT to_char(0, \u0027999S\u0027);  -- \u0027+   \u0027\n```\n\n`ToNumberParser.formatSplitInputBeforeAndAfterDecimalPoint` strips all leading zeros from the integer part of the input, which leaves no digits for a zero value. With digits after the decimal point, those still render the zero (`to_char(0, \u0027999.9\u0027)` returns `\u0027  0.0\u0027`). Without them, the zero is rendered only if something else in the format puts it there: for `\u0027999.\u0027` the decimal point turns the last blank into `0`, and for `\u0027099\u0027` the digit run that starts with `0` pads with zeros. Otherwise the ones digit is left out.\n\nThis PR keeps a single zero digit for the integer part in that case, so `to_char(0, \u0027999\u0027)` returns `\u0027  0\u0027` and `to_char(0, \u00279\u0027)` returns `\u00270\u0027`. Only the zero results whose ones digit used to be left out change. Formats that already rendered the zero, such as `\u0027999.\u0027`, `\u0027099\u0027` and `\u0027999.9\u0027`, give the same results. The width of the result is unchanged, and `$`, `PR` and a trailing `.` keep their positions. The `+` that `S` prints for a zero now sits next to the digit: `to_char(0, \u0027999S\u0027)` changes from `\u0027+   \u0027` to `\u0027  0+\u0027`, and `to_char(0, \u0027S999\u0027)` from `\u0027   +\u0027` to `\u0027  +0\u0027`.\n\nIt also adds the internal config `spark.sql.legacy.toChar.formatZeroAsBlank` (default `false`, binding policy `SESSION`) to restore the previous results. `ToCharacter` reads it when the expression is built and keeps it as a constructor parameter, so expressions built under different values are not semantically equal, and a cached query result computed under one value is not reused under the other.\n\n### Why are the changes needed?\n\nIt is a correctness bug. The `to_char` documentation says a sequence of `0` or `9` in the format string matches a sequence of digits in the input value and pads it with spaces to the length of the format sequence. Zero has one digit, so it should be rendered. PostgreSQL and Oracle also print the zero digit. Silently printing a blank makes a zero count or balance in a report indistinguishable from a missing value.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. For a zero value and a format string with no digits after the decimal point, `to_char` now keeps the ones digit where it used to leave it out. For example, `to_char(0, \u0027999\u0027)` returns `\u0027  0\u0027` instead of `\u0027   \u0027`, and `to_char(0, \u0027$999\u0027)` returns `\u0027$  0\u0027` instead of `\u0027$   \u0027`. Values other than zero, and formats that already rendered the zero, are unchanged. The previous results can be restored by setting `spark.sql.legacy.toChar.formatZeroAsBlank` to `true`. The SQL migration guide is updated.\n\n### How was this patch tested?\n\n- A test in `StringExpressionsSuite` checks zero values with `9`, `G`, `$`, a leading and a trailing `S`, `MI`, `PR`, a leading `0`, a trailing `.` and fractional digits, with the legacy config off and on. It also checks that the config value is captured when the expression is built, that rebuilding the expression with new children keeps it, and that expressions built under the two values are not semantically equal.\n- A test in `StringFunctionsSuite` caches a `to_char` query, then runs the same query with the legacy config on and checks that it does not reuse the cached result.\n- `StringExpressionsSuite`, `ToNumberParserSuite` and `StringFunctionsSuite` pass.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Isaac (Claude Opus 5.5)\n\nThis pull request and its description were written by Isaac.\n\nCloses #60734 from dtenedor/to-char-zero-digit.\n\nAuthored-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\nSigned-off-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "8621489fe807e1b61d68f58add00fcf6b6c67132",
      "tree": "376008c3d56598747fe55b396d412540696e07c4",
      "parents": [
        "1aa1e8fc68a1026eda4cc11395bf64277a530aae"
      ],
      "author": {
        "name": "Maxim Gekk",
        "email": "max.gekk@gmail.com",
        "time": "Mon Nov 23 15:17:53 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Mon Nov 23 15:17:53 2026 -0800"
      },
      "message": "[SPARK-61352][SQL] Keep the query context of interval errors after serialization and rewrites\n\n### What changes were proposed in this pull request?\n\n`DivideYMInterval` and `DivideDTInterval` share the `IntervalDivide` trait. Both build the context for their errors (`INTERVAL_ARITHMETIC_OVERFLOW.WITH_SUGGESTION`, `INTERVAL_DIVIDED_BY_ZERO`) from `origin.context`, read at evaluation time in the interpreted path and at code-generation time in `doGenCode`. This PR makes the division keep its context the way the other arithmetic expressions do:\n\n- `IntervalDivide` now mixes in `SupportQueryContext`, with `initQueryContext() \u003d Some(origin.context)`. The division raises in every mode, so the context is set unconditionally rather than only under ANSI as in `Divide`.\n- The interpreted `evalFunc` of both classes calls `getContextOrNull()`, and `doGenCode` calls `getContextOrNullCode(ctx)`, in place of `origin.context`.\n- `SupportQueryContext.copyTagsFrom`, shared by every expression with a query context, now copies the context of the node it replaces only when that node has one that comes from an origin (`SupportQueryContext.hasOrigin`: a SQL context with a text and a start index, or any other context such as a `DataFrameQueryContext`). Until now it also copied `None`, and a context built from an empty `Origin`. `TreeNode.transformDown`/`transformUp` call `afterRule.copyTagsFrom(this)` whenever a rule replaces a node, and the replaced node can have no context: the non-ANSI `Divide` that the analyzer (`BinaryArithmeticWithDatetimeResolver`) turns into `DivideYMInterval` / `DivideDTInterval` has a `queryContext` of `None`, and so does a non-ANSI cast that `SimplifyCasts` replaces with `make_ym_interval(...)`. Copying it left the division or `make_*_interval`, which raise in every mode, with no context. Today the division still has one, because it reads `origin.context`; once it reads the field, copying `None` alone would make `select interval 2147483647 month / 0.5` in `nonansi/interval.sql` lose it.\n\n  The copy still does what SPARK-39166 added it for. On an executor the deserialized expression has an empty `origin`, and a transform there (`BindReferences` while a projection is built) rebuilds the node, which then takes the serialized context. A replaced node with a context still gives it to its replacement, so the other ANSI expressions, the DataFrame API and the body of a SQL function keep their contexts as before. Under ANSI, `SimplifyCasts` dropping `CAST(\u003cym\u003e / -1 AS INTERVAL YEAR TO MONTH)` now leaves the division with the cast\u0027s context too, as ANSI `Add` gets under a same-type cast. So does a same-type `try_cast` in every mode, since `Cast.ansiEnabled` holds for `EvalMode.TRY` unless it casts a string to a fractional or datetime type, so an interval-to-interval `try_cast` has a context even with `spark.sql.ansi.enabled\u003dfalse`. Before, the division read `origin.context`, so with whole-stage codegen it reported its own fragment there.\n\n  Effect on other expressions: only a `SupportQueryContext` expression with a context of its own that a rule returns in place of a node without one now keeps its context instead of losing it. Such a node is a non-ANSI or `try_*` form, or one built outside an origin, whose replacement has a context in that mode, such as the interval expressions here. Everything else behaves as before.\n- Same pattern in two siblings: the interpreted paths of `MakeYMInterval` and `MakeDTInterval` passed `origin.context`, although both classes are already `SupportQueryContext` and their generated code already uses the field. Both now call `getContextOrNull()`.\n\nNot fixed here: `copyTagsFrom` sets the context of the expression a rule returns in place, and that instance can be shared with a temp view or a parent Dataset, so a division shared that way can report the context of another query that removed a cast over it. This predates the PR for the other `SupportQueryContext` expressions, such as ANSI `Add`, and is tracked in SPARK-61467.\n\n### Why are the changes needed?\n\n`TreeNode` does not implement `java.io.Serializable`, so Java serialization skips its fields. When an expression is deserialized, `TreeNode`\u0027s constructor runs again and sets `origin` from `CurrentOrigin.get`, which is empty on an executor. `SupportQueryContext` exists for this reason (SPARK-39166): its context is a field of the concrete, serializable expression, so it survives the trip to the executor.\n\nThe interval divisions never used it. Whole-stage codegen hides the problem, because it generates code on the driver and puts the context into the references array. Any projection built on the executor from the deserialized expression, though, raises the error with an empty context and no `\u003d\u003d SQL \u003d\u003d` block. That includes `ProjectExec` and the other operators when `spark.sql.codegen.wholeStage\u003dfalse`, and interpreted projections. For example:\n\n```sql\nSET spark.sql.ansi.enabled\u003dtrue;\nSET spark.sql.codegen.wholeStage\u003dfalse;\nSELECT CAST(CAST(id - 2147483648 AS INT) AS INTERVAL MONTH) / -1 FROM range(1);\n```\n\nraises `[INTERVAL_ARITHMETIC_OVERFLOW.WITH_SUGGESTION] ... SQLSTATE: 22015` with a query context whose fragment is empty and whose start and stop are -1. With whole-stage codegen on, the same query reports the fragment and the caret. `CAST(id + 1 AS INTERVAL DAY) / CAST(id AS INT)` gives `INTERVAL_DIVIDED_BY_ZERO` with the same gap. `make_ym_interval` / `make_dt_interval` overflows lose the context the same way, but only in interpreted evaluation, since their generated code already used the field. SPARK-60746 made both evaluation paths raise the same condition with a context. This PR closes the remaining gap, where that context is lost once the expression is serialized. The gap is older than SPARK-60746: released versions read `origin.context` in these classes too.\n\nThe gap was found while comparing errors from a columnar engine\u0027s fallback projections, which are built on the executor, against Spark\u0027s own whole-stage code.\n\nA grep for `origin.context` across the non-test sources under `sql/` finds no other evaluation-time readers. The remaining hits are analysis-time error builders that run on the driver. SPARK-61196 (open) plans to pass a context to the overflow errors of interval add, subtract and negate. It should take it from a `SupportQueryContext` field as here, not from `origin.context`, or it will have the same gap.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Interval division by a number now reports its SQL query context (the `\u003d\u003d SQL \u003d\u003d` block, and the fragment and position in the error\u0027s `queryContext`) when it overflows or divides by zero in a projection built on the executor, for example with `spark.sql.codegen.wholeStage\u003dfalse`. Before, those errors had an empty context there. `make_ym_interval` and `make_dt_interval` already kept their context in generated code; they now keep it in interpreted evaluation too (the codegen fallback, or `spark.sql.codegen.factoryMode\u003dNO_CODEGEN`). In non-ANSI mode, an interval division or `make_ym_interval` / `make_dt_interval` under a cast to its own type, which `SimplifyCasts` removes, keeps a context instead of losing it. Under ANSI, an interval division under such a cast now reports the whole `CAST(...)` as its fragment, as the other ANSI arithmetic does, where before, with whole-stage codegen, it reported the division. The same holds for a same-type `try_cast` in either mode: the query still fails, since `try_cast` does not catch an error of its child, and the fragment is the whole `try_cast(...)`. The error condition, SQLSTATE and message parameters do not change.\n\n### How was this patch tested?\n\nNew tests:\n\n- `IntervalExpressionsSuite`, \"SPARK-61352: an interval error keeps its query context\": builds each expression under `withOrigin` and evaluates it outside, so the serialization round trip in `ExpressionEvalHelper` cannot restore the origin from `CurrentOrigin`. It checks for the `\u003d\u003d SQL (line 1, position 8) \u003d\u003d` block in the interpreted, mutable-projection and unsafe-projection modes. Cases: year-month `MinValue / -1` (integral, double and decimal), year-month `/ 0`, day-time `MinValue / -1` (long, decimal and double), day-time `/ 0`, so that each interpreted division branch is reached, `make_ym_interval(2147483647, 0)`, `make_dt_interval(2147483647)`. Each case is checked in three forms: as built; after `SimplifyCasts`, run on a one-column `Project`, removes a same-type `Cast` around it: with an ANSI or a TRY cast, whose context the expression takes, with a non-ANSI one, which has none, and with an ANSI cast built outside `withOrigin`, whose context has no origin, so the expression keeps its own in the last two; and after a `makeCopy` of a deserialized copy, which rebuilds the node with an empty `origin` as a transform on an executor does. Each form is built from a fresh instance, since `copyTagsFrom` changes the instance a rule returns.\n- `QueryExecutionAnsiErrorsSuite`, \"SPARK-61352: an interval division error keeps its query context\": runs `CAST(CAST(id - 2147483648 AS INT) AS INTERVAL MONTH) / -1` and `CAST(id + 1 AS INTERVAL DAY) / CAST(id AS INT)` end to end, each bare and inside a `CAST` and a `try_cast` to its own type (`INTERVAL YEAR TO MONTH`, `INTERVAL DAY TO SECOND`), with whole-stage codegen on and off, from one case table, and checks the condition, parameters and the `ExpectedContext` fragment: the division, or the whole `CAST(...)` / `try_cast(...)`, whose context the division takes. It also runs `spark.range(1).select(expr(\"CAST(id + 1 AS INTERVAL DAY)\") / $\"id\".cast(\"int\"))` in both modes and checks the `DataFrameQueryContext`: fragment `div` and the call site. The operands read a column, so they are not constant-folded on the driver.\n- `QueryExecutionErrorsSuite`, \"SPARK-61352: an interval error keeps its query context in non-ANSI mode\": the same two divisions plus `make_ym_interval(CAST(id AS INT) + 178956971, 0)` and `make_dt_interval(CAST(id AS INT) + 106751992)`, bare and inside a `CAST` to their own type, whose context they keep, and inside a `try_cast`, whose context they take, under `spark.sql.ansi.enabled\u003dfalse`, with whole-stage codegen on and off.\n\nWith `copyTagsFrom` copying `None` again, the unit test fails on the non-ANSI cast form: the expression under the cast reports no context. Without the `hasOrigin` check, it fails on the ANSI cast built outside `withOrigin`. The two suites share the queries and the expected-context helper through `IntervalErrorContextTestUtils`.\n\nExisting suites pass: `IntervalExpressionsSuite`, `ArithmeticExpressionSuite`, `DecimalExpressionSuite`, `SimplifyCastsSuite`, `CastWithAnsiOnSuite`, `CastWithAnsiOffSuite`, `TryCastSuite`, `QueryExecutionErrorsSuite`, `QueryExecutionAnsiErrorsSuite`, the \"Query context\" tests of `SQLQuerySuite` (SPARK-39166 and its follow-ups, which raise from a projection built on the executor), and the whole `SQLQueryTestSuite` with no golden file changes. Its one failure locally, `udtf/udtf.sql - Python UDTFs` query #29, is the local Python\u0027s `ValueError` wording for `list.index` (`list.index(x): x not in list` against the expected `\u0027input\u0027 is not in list`), unrelated to this change. `catalyst/scalastyle`, `catalyst/Test/scalastyle` and `sql/Test/scalastyle` pass.\n\n```\nbuild/sbt \u0027catalyst/testOnly *IntervalExpressionsSuite *ArithmeticExpressionSuite *DecimalExpressionSuite *SimplifyCastsSuite *CastWithAnsiOnSuite *CastWithAnsiOffSuite *TryCastSuite\u0027 \\\n  \u0027sql/testOnly *QueryExecutionErrorsSuite *QueryExecutionAnsiErrorsSuite\u0027 \\\n  \u0027sql/testOnly org.apache.spark.sql.SQLQuerySuite -- -z \"Query context\"\u0027 \\\n  \u0027sql/testOnly org.apache.spark.sql.SQLQueryTestSuite\u0027\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Opus 5.5)\n\n\n\n\n\nCloses #60285 from MaxGekk/SPARK-61352-interval-divide-context.\n\nLead-authored-by: Maxim Gekk \u003cmax.gekk@gmail.com\u003e\nCo-authored-by: t \u003ct@example.com\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "1aa1e8fc68a1026eda4cc11395bf64277a530aae",
      "tree": "8d3a7d9f4712ed6bf0c11495f28c6e2a1cf80a9f",
      "parents": [
        "d5b01eda3e726d7b53e1a34d80967a3376aacbee"
      ],
      "author": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Mon Nov 23 10:01:43 2026 -0800"
      },
      "committer": {
        "name": "Daniel Tenedorio",
        "email": "daniel.tenedorio@databricks.com",
        "time": "Mon Nov 23 10:01:43 2026 -0800"
      },
      "message": "[SPARK-61494][SQL] Support optional column, field, variable, and named parameter references\n\n### What changes were proposed in this pull request?\n\nThis PR adds optional column, field, variable, and named parameter references to Spark SQL. The syntax is behind a new conf, `spark.sql.optionalReferences.enabled`, which is internal and off by default.\n\nA `?` after an identifier makes that identifier optional. If name resolution finds no match for it, the whole reference becomes a static `NULL` of type `VOID` instead of raising `UNRESOLVED_COLUMN`, `FIELD_NOT_FOUND`, or `UNBOUND_SQL_PARAMETER`. A top-level reference keeps the name of its last identifier.\n\n```sql\n-- t has the columns id INT and addr STRUCT\u003ccity: STRING\u003e.\nSELECT id?, name?, addr.state?, ghost?.city FROM t;  -- id, NULL AS name, NULL AS state, NULL AS city\nSELECT addr?.state FROM t;                           -- FIELD_NOT_FOUND: `?` guards only `addr`\nEXECUTE IMMEDIATE \u0027SELECT :x?, :y?\u0027 USING 1 AS x;    -- 1, NULL\n```\n\n#### Semantics\n\n- Only not-found errors are suppressed. Ambiguous references, field extraction from a value that isn\u0027t a struct, and errors about references that exist but can\u0027t be used (for example `MISSING_AGGREGATION`) are still raised.\n- A reference that resolves without `?` resolves the same way with it. A name becomes `NULL` only after every usual step fails to resolve it. These steps include lateral column aliases, GROUP BY and ORDER BY aliases, the columns below the SELECT list that ORDER BY and HAVING can reference, outer references, SQL function parameters, and session and SQL scripting variables. A name is `NULL` only if its first part that matches nothing has a `?`. A namespace or catalog without the table, or `system` without `session`, isn\u0027t a qualifier, so `default.id?` and `system.x?` fail as they do without `?`.\n- In the body of a persistent SQL function, an optional reference doesn\u0027t resolve to the session or SQL script variables of the caller, and a label of the caller doesn\u0027t qualify it, because a persistent function can\u0027t depend on temporary objects. The body resolves the same way when the function is created and when it is called, as in a persistent view, so a dependency on a label, as in `lbl.x?`, fails at `CREATE FUNCTION`. Temporary SQL functions can read the variables of their caller, with or without `?`.\n- The name of a missing reference is the name of its output column, which ORDER BY and HAVING can reference. It isn\u0027t a lateral column alias or a GROUP BY alias: in `SELECT missing?, missing + 1 FROM t` and in `SELECT missing?, count(*) FROM t GROUP BY missing`, the `missing` without `?` raises `UNRESOLVED_COLUMN`. An explicit alias, as in `SELECT missing? AS m, m + 1 FROM t`, is one as usual.\n- A nested missing reference is a NULL value in the enclosing expression. An extraction from it is NULL, whether a field, a subscript, or a VARIANT path (`missing?:a`). The expression is named like any other expression, so `CAST(deleted_at? AS STRING)` is named `deleted_at` while the column exists and `CAST(NULL AS STRING)` while it doesn\u0027t; an expression over an optional reference needs an alias for a stable output name.\n- `?` is allowed in queries, including the query of every `INSERT` (also `INSERT OVERWRITE`), `VALUES`, `CREATE VIEW`, and `CREATE TABLE ... AS SELECT`. The boundary is the kind of statement: `UPDATE`, `DELETE`, and `MERGE` exist to modify existing rows and reject `?` everywhere, including in the source query of `MERGE`. The query of an `INSERT` produces the rows to write, and a missing column makes the written rows differ as in any other query. That holds for the forms whose written rows also decide which existing rows are replaced, an `INSERT OVERWRITE` with dynamic partition overwrite and `INSERT ... REPLACE ON/USING`; only the `REPLACE` condition, a predicate on the target table, rejects `?`. `CALL` arguments are values, like the arguments of a function in a query, and accept `?`; the procedure decides what a NULL argument means.\n- These raise `OPTIONAL_REFERENCE_NOT_SUPPORTED.IN_DML`, so that a missing column or an unbound parameter can\u0027t silently change which rows a statement modifies:\n  - `UPDATE`, `DELETE`, and `MERGE` statements, including their common table expressions and the source query of `MERGE`, and the same statements built with the DataFrame API or Spark Connect, such as `df.writeTo(\"t\").overwrite(expr(\"deleted_at? IS NULL\"))` and a `mergeInto` whose source DataFrame has a `?`, also in the plans of their subqueries. Only the last operation of a source DataFrame is sure to be unanalyzed (a Dataset operation builds on the analyzed plan of the one before, and Spark Connect analyzes some relations such as `withColumns` when it plans them), so the check also rejects an analyzed source operation whose analysis resolved an optional reference to NULL, and likewise a subquery built from a Dataset (`Dataset.exists`, `Dataset.scalar`, `Column.isin(Dataset)`), except inside views and SQL functions, which resolve their own references.;\n  - the `REPLACE` condition of `INSERT`, in SQL and as the condition of `DataFrameWriterV2.overwrite` (context `INSERT ... REPLACE`);\n  - `AUTO CDC` flows, in SQL and through the pipelines API.\n- Partition specifications, as in `TRUNCATE TABLE t PARTITION (p \u003d :p?)`, raise `OPTIONAL_REFERENCE_NOT_SUPPORTED.IN_PARTITION_SPEC`, and the `DEFAULT` of columns and SQL function parameters, `GENERATED ALWAYS AS`, `CHECK`, and `OPTIONS` clauses of table and function definitions raise `OPTIONAL_REFERENCE_NOT_SUPPORTED.IN_DDL`, and so do metric view definitions (`CREATE VIEW ... WITH METRICS`), which are resolved as a part of each query that reads them rather than on their own like the query of a view. SQL function bodies, view queries, and CTAS queries accept `?`. All use SQLSTATE `0A000`.\n- `:name?` is an optional named parameter marker, and each occurrence is independent: in `SELECT :x?, :x`, an unbound `x` still raises `UNBOUND_SQL_PARAMETER`.\n- `IDENTIFIER(expr)?` is an optional reference to the column that `expr` names.\n- Whitespace and comments before `?` are insignificant.\n- An expression that contains a missing reference is named as if `NULL` were written in its place, for example `typeof(NULL)`.\n- A missing reference has the type `VOID`. A view in the default schema binding mode keeps the types that its columns had when it was created. A view over a column that can appear later should therefore cast the reference, for example `CAST(deleted_at? AS TIMESTAMP)`, or be created `WITH SCHEMA EVOLUTION`.\n- `?` binds to the identifier before it, so `x?::INT` is `CAST(x? AS INT)`.\n\n#### `?` as a parameter marker\n\n`?` is already the positional parameter marker, and most keywords are also valid names of columns. `c IN (SELECT ?)` could therefore also be read as `c IN (select?)`, with a reference to a column named `select`.\n\n- A statement that is valid without optional references keeps its meaning. The parser first parses a statement without optional references, where a `?` is a parameter marker. It parses the statement with optional references only if that fails and leaves a `?` that isn\u0027t a parameter marker. So in `c IN (SELECT ?)`, `first(DISTINCT ?)`, and `INTERVAL ? DAY`, the `?` stays a parameter marker, with the conf on or off.\n- In a statement that is parsed with optional references, a `?` after an identifier or a non-reserved keyword marks an optional reference wherever the syntax allows a reference, and it\u0027s a parameter marker elsewhere: `SELECT missing?, ? FROM t WHERE id \u003d ? LIMIT ?` has one optional reference and three parameter markers. After `SELECT` or `VALUES` at the start of an `IN` subquery, it\u0027s a parameter marker too. In `SELECT missing?, first(DISTINCT ?) FROM t` however, it marks a reference to a column named `distinct`. A quoted name is always a reference, as in ``c IN (`select`?)``.\n- So that the remaining markers of such a statement can\u0027t take the values of a `?` that became a reference silently, a statement with optional references that is given more positional values than it has positional markers fails with `UNUSED_SQL_PARAMETER_VALUES` (SQLSTATE `07001`), in `EXECUTE IMMEDIATE ... USING`, `spark.sql(text, args)`, and the legacy binding mode alike. The check goes by the statement as written, whether or not its optional references resolve: in the legacy mode, `PosParameterizedQuery` and `GeneralParameterizedQuery` carry that fact from the parsed plan. A statement without optional references keeps ignoring extra values, as before. The check applies to statements without named markers; with named markers every value binds by name, and `EXECUTE IMMEDIATE` passes its named `USING` values as positional values too.\n\n#### Implementation\n\n- **Parser.**\n  - `SqlBaseParser.g4` accepts an optional `?` after the identifier of a `#columnReference` and after the field of a `#dereference`, and has a new alternative `#optionalIdentifierClause` for `IDENTIFIER(expr)?`. `namedParameterLiteral` accepts an optional `?`. The markers are inlined into `primaryExpression` rather than rules of their own, because a rule of their own would cost every column reference a rule invocation. To keep the generated `primaryExpression` method under the 8,000 bytes that HotSpot JIT-compiles, the `#overlay` alternative moves to a rule of its own, `overlayExpression`: `primaryExpression` is 7,904 bytes of bytecode with this PR and 7,851 without (measured with `javap`).\n  - Parse time of the generated parser alone (lexer and parser, SLL then LL, no plan building, conf off; median of three JVM runs each, master against this PR): the 103 TPC-DS queries +2.1% (9.19 ms vs 9.38 ms per pass), 500 short statements +3.7%, a WHERE clause with 500 predicates +3.6%, 2,000 column references +6.1%, 2,000 qualified columns +6.5%, 1,000 nested fields +8.6%. That is the cost of the marker alternatives and of the two predicates below; parsing is a small part of query compilation.\n  - In these rules, the `?` is a new token type, `QUESTION_WITH_OPTIONAL_REFERENCES`, which the lexer never produces. `AbstractParser.executeWithTwoStageStrategy` parses a statement as before. With the conf on, it counts the `?` that this parse uses as positional parameter markers. If the parse fails and didn\u0027t use every `?` that way, it turns the `QUESTION` tokens of the statement into the new token type and parses again. The new token type is also a positional parameter marker. Without the conf, the new rules can never match, so the parser accepts the same statements as before, with the same results and errors.\n  - The count, rather than a syntax error, triggers the second parse because some rules accept any tokens: without optional references, `SET VAR v \u003d missing?` is parsed by `SET .*?` and then rejected by `AstBuilder`. A statement that such a rule parses successfully, for example `SET key\u003da?b`, is not parsed again. `SubstituteParamsParser` doesn\u0027t build a plan and can\u0027t tell these apart, so it parses a statement again if a rule for any tokens used a `?`.\n  - A query that is parsed without its end (`spark.sql.legacy.parseQueryWithoutEof`) is parsed again if the first parse stops before a `?`.\n  - `SqlStatementSplitter` parses a region that isn\u0027t a statement again with the new token type, so that it splits a script with optional references like any other.\n  - Two predicates keep parameter markers from being read as optional references. With optional references, a `?` after `IN (SELECT` or `IN (VALUES` starts a subquery rather than a list of expressions. With the conf on, a `?` after `:name` in a string literal makes the named marker optional instead of adding a positional marker to the literal. Without optional references, such a literal is always an error, because it mixes named and positional markers.\n  - `AstBuilder` records the optional name parts of a multipart name in a tree node tag on `UnresolvedAttribute` (and `UnresolvedNamedLambdaVariable`), and it marks optional `UnresolvedExtractValue` and `NamedParameter` nodes. Tags avoid changing the signatures of these widely used case classes.\n- **Validation.** `OptionalReferenceValidation` checks the DML and DDL restrictions in SQL text. `SubstituteParamsParser` leaves an unbound `:name?` marker in the text, so that the analysis resolves it to the `NULL` of a missing reference, as it does without parameter values. It runs this validation on the bound markers, because they\u0027re substituted before `AstBuilder` sees them. A `?` of a `DECLARE CURSOR` query is a parameter marker that is bound when the cursor is opened, so it doesn\u0027t select optional references. The main parser parses the substituted text with optional references if the substitution parsed the statement with them (`ParameterSubstitution.parsedWithOptionalReferences`), because the substitution of a `:name?` can remove the `?` that selected them: in `SELECT :x? AS a, first(DISTINCT ?) FROM t`, `DISTINCT ?` stays an optional reference to a column `distinct`. The new analyzer rule `CheckOptionalReferences` rejects optional references in the plans of DML statements that weren\u0027t parsed from SQL text, and with `IN_DDL` in the `DEFAULT` and generation expressions of column definitions that an API such as `Catalog.createTable` parses on its own. The analysis of a default from column metadata rejects them too.\n- **Names of missing references.** `OptionalReferences.implicitAlias` tags the alias that gives a missing top-level reference its name. Lateral column alias resolution and GROUP BY alias resolution skip a tagged alias, in both analyzers.\n- **Tags.** The parser records the optional name parts and markers of a reference in tree node tags. These describe the statement and stay true in every analysis of the plan. Spark\u0027s generic transforms copy the tags of a node to the node that replaces it, but only if that node has no tags of its own (`TreeNode.copyTagsFrom`). A rule that rebuilds a reference another way forwards them itself: the optional name parts of a multipart name with `OptionalReferences.withOptionalNamePartsOf` (HAVING does, when it re-resolves a column that is neither grouped nor aggregated), and the marker of a field extraction, a named parameter marker, or an IDENTIFIER clause with `copyTagsFrom` or a generic tree transform. The analyzer tags the NULL of a missing reference and its implicit alias, nodes that one analysis creates, and gives them the position of the reference. It also marks the root of the plan that it returns with the position of the first such NULL (`OptionalReferences.RESOLVED_NULL_REFERENCE`), because the rest of the analysis can replace the NULL itself, as in `attrs?[\u0027active\u0027]`; the DML check reads the mark in the analyzed operations of a `MERGE` source. The analyzer never tags a node of the plan it receives. Later analyses copy the mark under the same condition, and a node with a Dataset id or a Spark Connect plan id already has tags. So code outside the analyzer that replaces or rebuilds an analyzed node must keep the mark with `OptionalReferences.withResolvedNullReferenceOf`. The `Dataset` rewrites do so: the union flattening of `union`, `unionAll`, and `unionByName`, also of a Union below a distinct union, and the join rewrites of `join` with a condition, `joinWith`, and `joinAsOf`. The other decision an analysis makes, that no resolution step of an operator can resolve an optional field extraction, is a node of the plan that the analysis builds, `LastResortExtractValue`, not a tag: the analyzer can analyze the same unresolved plan again later, e.g. from the Spark Connect plan cache, against a relation that has the field by then. `ResolveOptionalReferences` only waits for the references that it can still replace or wrap, so a `TempResolvedColumn` that HAVING or ORDER BY tried in a subquery is reported like without `?`.\n- **Missing nested fields.** `AttributeSeq.resolve`, `VariableResolution`, and the resolution of lambda variables turn a missing optional field into `NULL` (`OptionalReferences.extractNestedFields`), but only where the error for the same field without `?` is final. A step that only tries to resolve a name, such as ORDER BY against the SELECT list, leaves the reference unresolved, like a reference without `?`.\n- **Missing names.** A name resolves to `NULL` if its first name part that continues no reference is optional (`OptionalReferences.resolvesToNull`). The existing name resolution decides what each prefix of the name is: `AttributeSeq.getCandidatesForResolution` for columns, fields, and their qualifiers, and the new `VariableResolution.isVariableQualifier`, which uses the qualifier and label rules of `lookupVariable`, for variables. The attributes come in the groups that the resolution tries one after the other, such as the SELECT list and then its input for ORDER BY, and a prefix that is ambiguous within a group keeps the error of the name, as in `ORDER BY s.y?` over a join of two tables with a column `s`. In the fixed-point analyzer, the groups follow the operators through which `resolveExprsAndAddMissingAttrs` adds a missing attribute and the sources of outer references, which it shares with `ColumnResolutionHelper` (`canAddMissingAttrsThrough`, `outerReferenceSources`). An extraction from the `NULL` of a missing reference is that `NULL` too, so a VARIANT path of a subscript of a missing column, as in `arr?[0]:a`, is `NULL`.\n  - In the fixed-point analyzer, `ResolveOptionalReferences` runs in a new batch after \"Resolution\". It replaces the optional references of the lowest operators that are still unresolved with `NULL`, then runs \"Resolution\" again, until nothing changes. It doesn\u0027t touch a plan without unresolved optional references. It handles the plan of a subquery expression only after the operator around it can\u0027t be resolved further, because that operator can still change what the subquery resolves to, for example by binding parameters or by extracting a generator. Until then, `RemoveTempResolvedColumn` leaves such a subquery plan alone, so that its HAVING and ORDER BY can still resolve their columns.\n  - In the single-pass resolver, `NameScopeStack.resolveMultipartName` returns `NULL` when no source resolves the name.\n- **SQL functions.** `AnalysisContext.withAnalysisContext(function)` now clears `outerPlan`, unless the new legacy conf `spark.sql.legacy.sqlFunctionBodyResolvesOuterReferences` is set. See \"Does this PR introduce any user-facing change?\". `ResolveOptionalReferences` tells the plan of a subquery from the body of a function that the subquery calls by `AnalysisContext.isSubqueryPlan`, not by the outer plan, so the legacy conf applies with or without optional references. The analysis of the body of a persistent function sets `AnalysisContext.isPersistentSQLFunctionBody`, and `VariableResolution` then resolves no name with a `?` to a variable.\n- **SQL scripting.** The label of a compound statement and the variable of a FOR statement are qualifiers of the variables of their scope, so `lbl.missing?`, `lbl.missing?.f`, and `r.missing?` are NULL (`VariableManager.isScopeLabel`), except in the query of a view, when the view is read or defined (`AnalysisContext.isViewDefinition`): a view sees only the script variables it referenced when it was created, so a definition that depends on a label, also in the body of a SQL function that the view calls, fails at `CREATE VIEW` (also for a temporary view named by an IDENTIFIER clause, whose plan the parser tags because the analysis builds its command), `ALTER VIEW ... AS`, or `CACHE TABLE ... AS SELECT` instead of at every read. The analysis sets `isViewDefinition` also while the session disables optional references, because a SQL function keeps the setting it was created with. A view also depends on a variable whose missing optional field (`v.missing?`) resolved to NULL, which the NULL doesn\u0027t mention: `VariableResolution` records it with the variables that an IDENTIFIER clause reads (`AnalysisContext.referredTempVariableNamesUnderIdentifier`), so that a temporary view keeps the variable and a persistent view rejects it.\n- **Single-pass resolver coverage.** `ResolverGuard` sends two cases to the fixed-point analyzer: optional named parameter markers, because the single-pass resolver doesn\u0027t resolve named parameters, and optional fields of expressions other than names (`arr[0].f?`), because the two analyzers would produce different plans for them in ORDER BY.\n- **Confs.**\n  - `spark.sql.optionalReferences.enabled` (internal, default `false`) enables the syntax. Views and SQL functions capture the conf, so one that was created while it was on still works in a session that doesn\u0027t set it. A session that sets it to `false` turns it off in their bodies too.\n  - `spark.sql.analyzer.singlePassResolver.enableOptionalReferenceResolution` (internal, default `true`) lets `ResolverGuard` admit plans with optional references to the single-pass resolver.\n\n### Why are the changes needed?\n\nThe main use case is a query or a view that keeps working while its source tables evolve. `CREATE VIEW v AS SELECT id, CAST(deleted_at? AS TIMESTAMP) AS deleted_at FROM t` is valid whether or not `t` has the column `deleted_at`, and its schema is the same either way. Today this takes either a catalog lookup before the query is built or one query variant per schema.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes, one bug fix that doesn\u0027t depend on the new conf. The body of a SQL function that is called in a subquery no longer resolves its names against the query around the subquery:\n\n```sql\nDECLARE VARIABLE v INT DEFAULT 100;\nCREATE TEMPORARY FUNCTION f() RETURNS INT RETURN v;\nSELECT (SELECT f()) FROM VALUES (5) AS t(v);  -- 5 before this PR, 100 with it\n```\n\nBefore this PR, `v` in the body of `f` resolved to the column `t.v` of the calling query, because the body was analyzed with the outer plan of the subquery. The body of a function is not a part of the query that calls it, like the query of a view, and an optional reference in it should not resolve differently depending on where the function is called. The internal conf `spark.sql.legacy.sqlFunctionBodyResolvesOuterReferences` (default `false`) restores the old resolution, with or without optional references, and `docs/sql-migration-guide.md` describes the change. `SQLFunctionSuite` tests both settings.\n\nThe new syntax is not a user-facing change: it\u0027s only accepted while `spark.sql.optionalReferences.enabled` is `true`, and the conf is internal and `false` by default. While it\u0027s off, the parser accepts the same statements as before, with the same results and the same errors.\n\n### How was this patch tested?\n\n- New golden file `optional-references.sql`, with results and analyzer results. It has positive and negative cases for:\n  - missing and existing columns, and qualified, nested, and three-part names with every placement of `?`, also behind a prefix that isn\u0027t a whole qualifier, such as `default.id?` and `system.x?`, and session-variable qualifiers in a case-sensitive analysis;\n  - the errors that are still raised: ambiguity, also of the base of a missing field in ORDER BY, invalid field extraction, `MISSING_AGGREGATION`, and not-found errors for identifiers without `?`;\n  - expressions, predicates, GROUP BY, HAVING (including a field that exists below the SELECT list but not in the alias it falls back to), QUALIFY, and ORDER BY (including SELECT-list aliases and names that resolve differently in the SELECT list and below it), window functions, GROUP BY ALL, joins, common table expressions, set operations, lateral column aliases, session and SQL scripting variables (also qualified by a label or a FOR variable), `SET VAR`, correlated, nested, and lateral subqueries, lambda functions, field, subscript, and VARIANT path extraction from other expressions and from missing references, the IDENTIFIER clause, SQL scalar and table functions (also called in subqueries), and SQL pipe syntax;\n  - casts with `::`, optional named parameter markers (bound, unbound, mixed with unmarked occurrences, and mixed with positional markers), positional markers in statements with and without optional references;\n  - temporary and persistent views, including a missing field of a session or script variable, `WITH SCHEMA EVOLUTION`, the default schema binding mode, a source table that gains or loses a column, and a session that doesn\u0027t set the conf;\n  - `INSERT ... SELECT`, `VALUES`, and CTAS;\n  - the `IN_DML`, `IN_PARTITION_SPEC`, and `IN_DDL` errors, including common table expressions before DML statements, and named parameter markers with and without parameter values; `INSERT OVERWRITE` with optional references;\n  - syntax errors, and the disabled conf, also in a view and in scalar and table SQL functions that were created while it was on.\n- New streaming golden file `streaming/optional-references.sql`, with optional references in a flow over a streaming source, and the `IN_DML` error for an `AUTO CDC` flow.\n- New `OptionalReferencesParserSuite` with parser, parameter substitution, and statement splitter tests, including statements that are valid without optional references, a marker before an optional reference, `SET VAR` statements, `spark.sql.legacy.parseQueryWithoutEof`, double-quoted parameter names, and the `IN_DDL` rejection of an optional field of an expression and of an optional `IDENTIFIER` clause.\n- New `OptionalReferencesSuite`: analyzing the same unresolved plan instance again after the referenced struct gained the optional field sorts by the field, like a newly parsed plan (the plan-cache case); the `DEFAULT` of a SQL function parameter; a metric view definition with `?` in its source, filter, dimension, or measure, which fails with `IN_DDL`; and a HAVING column that is not grouped and keeps its optional name parts when HAVING resolves it again against the SELECT list (fixed-point analyzer only: the single-pass resolver doesn\u0027t resolve a qualified name like `s.y` against the SELECT list, with or without `?`); and a `DEFAULT` and a generation expression of a column definition of `Catalog.createTable`, and a default from column metadata, which fail with `IN_DDL`.\n- New tests in existing suites:\n  - `ResolverGuardSuite`: the single-pass conf and the two cases that fall back to the fixed-point analyzer.\n  - `ParametersSuite`: optional named parameter markers with `spark.sql(sqlText, args)`, in and outside of subqueries, an optional marker after a supplementary character, and positional values that a statement with optional references doesn\u0027t use, both with and without `spark.sql.legacy.parameterSubstitution.constantsOnly`, whether or not the references resolve, including references in common table expressions, and in the legacy binding mode under `EXPLAIN`, under `DESCRIBE QUERY`, and in a `WINDOW` clause; the plan string of a parameterized query, which doesn\u0027t show the new flag; and a statement in which the substitution of `:x?` removes the `?` that selected optional references, in both binding modes and under `EXECUTE IMMEDIATE`; a VARIANT path of an unbound `:p?` when other parameters have values; and a script whose `DECLARE CURSOR` query has a `?`, which doesn\u0027t select optional references.\n  - `DataFrameSuite`: `selectExpr`, `expr`, and `filter` with optional references, including a filter on a column below an aggregate, which fails like without `?`.\n  - `DataFrameWriterV2Suite` and `MergeIntoDataFrameSuite`: the `IN_DML` error for `overwrite(condition)` and `mergeInto`, including an optional reference in the subquery of a `MERGE` assignment, in the source DataFrame, in an analyzed operation of the source (followed by `.as` or `filter`, a VARIANT path, an extraction from a missing reference, an IF over one, an inline table row, a SQL table function argument), in a source analyzed by the single-pass resolver, in a source built while the conf was on and merged after it was turned off, in a CTE of the source, in a subquery built from a Dataset in a `MERGE` assignment and in an `overwrite` condition, and in a source that `union`, `unionAll`, `unionByName`, a self-join through `join`, `joinWith`, or `joinAsOf` built from such an operation, also when the union flattens the Distinct of a SQL `UNION` or the Deduplicate of a Dataset `distinct`. Also covered: sources where type coercion replaced the NULL in an analyzed operation (`status? \u003d \u0027deleted\u0027` with ANSI mode on, and `size(tags?)`), alone, after `union`, and after a self-join with a condition, with both analyzers. Sources that read a view or a SQL function whose body uses `?` still merge, and so does a source whose drop of a missing optional field dropped nothing. A source with an unbound `:p?` built with other parameter values fails with `IN_DML`, in both binding modes. `DataFrameWriterV2Suite` also writes an `overwrite` source with a `?`.\n  - `SQLFunctionSuite`: the body of a SQL function that is called in a subquery, with and without the legacy conf and optional references, including an optional reference in the body that matches nothing. Persistent scalar and table functions whose plain or session-qualified optional references match nothing stay NULL when the caller declares a session or script variable of that name, while a temporary function reads it, and a persistent function whose body has a label-qualified optional reference fails at `CREATE FUNCTION`, with and without a variable of that label. In a session that leaves the conf unset, a temporary view, a persistent view, `ALTER VIEW ... AS`, and `CACHE TABLE ... AS SELECT` defined in a labeled block fail at creation when they call a function created with the conf on whose body has a label-qualified optional reference.\n  - `SparkDeclarativePipelinesServerSuite`: the `IN_DML` error for the change arguments of an `AUTO CDC` flow defined through the pipelines API, including a `?` in a common table expression of a subquery.\n  - `SqlStatementSplitterSuite`: a `BEGIN ... END` block with an optional reference, with the conf on and off.\n- New `OptionalReferencesAnalysisSuite` (catalyst): the searches for optional references visit every one of 20 nested subquery plans once, in `hasOptionalReferences` and in the DML check of a `DELETE` condition and of a `MERGE` source; an `UPDATE` built without the parser rejects `?` in an assignment and in its condition.\n- New `OptionalReferencesConnectSuite` (Spark Connect server, with an in-process client): a `MERGE` whose source has `?` in a `withColumn` step, which the planner analyzes early, fails with `IN_DML`, also when the step extracts a field from the missing reference.\n- The golden files run with both analyzers on every query that the single-pass resolver supports, and the two plans are compared.\n- Manual checks:\n  - Generated 138,018 statements that place `?` after each of the 476 keywords of the lexer in about 290 positions (`SELECT \u003ckeyword\u003e ?`, `c IN (\u003ckeyword\u003e ?, ?)`, `f(\u003ckeyword\u003e DISTINCT ?)`, and so on). Parsed each on master and on this branch, with the default settings, with `spark.sql.legacy.parameterSubstitution.constantsOnly`, and with `spark.sql.ansi.enforceReservedKeywords`. With the conf off, all 414,054 outcomes are the same as on master: the same plan, or the same error at the same position. With the conf on, every statement that parses on master (3,759 with non-reserved keywords, 3,148 with reserved keywords) parses to the same plan, and its parameter markers are substituted at the same positions. The same holds for 284 hand-written statements with `?`.\n  - Measured the bytecode size of `SqlBaseParser.primaryExpression` with `javap`, and the parse time of the generated parser (see Implementation), on master and on this branch.\n- Ran these existing suites:\n  - All suites of the `catalyst` module.\n  - `SQLQueryTestSuite` and `StreamingSQLQueryTestSuite` (all golden files), and `ThriftServerQueryTestSuite` (the new golden file).\n  - `sql/core`: all suites in `org.apache.spark.sql.analysis.resolver`, `org.apache.spark.sql.connector`, `org.apache.spark.sql.errors`, `org.apache.spark.sql.scripting`, and `org.apache.spark.sql.execution.command`, and `ParametersSuite`, `ExecuteImmediateEndToEndSuite`, `LateralColumnAliasSuite`, `SubquerySuite`, `DataFrameSubquerySuite`, `SQLQuerySuite` (except `SPARK-33084: Add jar support Ivy URI in SQL`, which needs access to Maven Central), `SQLViewSuite`, `SQLFunctionSuite`, `SimpleMetricViewSuite`, `MetricViewV2CatalogSuite`, `UDFSuite`, `GeneratorFunctionSuite`, `VariantSuite`, `VariantEndToEndSuite`, `ParseSqlSuite`, `SparkSqlParserSuite`, `DataFrameSuite`, `DataFrameWriterV2Suite`, `DataFrameSetOperationsSuite`, `DataFrameJoinSuite`, `DataFrameSelfJoinSuite`, `DataFrameAsOfJoinSuite`, and `DatasetSuite`.\n  - `sql/connect/server`: `SparkDeclarativePipelinesServerSuite` and `SparkConnectPlannerSuite`.\n  - The streaming state-store suites `StateStoreInstanceMetricSuiteWithRowChecksum` and `StateDataSourceRealTimeSuite`, which failed on the fork\u0027s CI, pass locally. The first depends on an earlier test\u0027s state store maintenance task, which SPARK-61788 fixes on master.\n  - `SparkThrowableSuite` and `SparkConfigBindingPolicySuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code, Fable 5.2 and Opus 5.5\n\nThis pull request and its description were written by Isaac.\n\nCloses #60367 from dtenedor/optional-references.\n\nAuthored-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\nSigned-off-by: Daniel Tenedorio \u003cdaniel.tenedorio@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "d5b01eda3e726d7b53e1a34d80967a3376aacbee",
      "tree": "3182672f9feda4d4a99fe2078dff396301081e3c",
      "parents": [
        "2846aa5db53463b368c1a46dafbe6ecdf7d01d73"
      ],
      "author": {
        "name": "Matthew B",
        "email": "mgball@uci.edu",
        "time": "Tue Nov 24 01:00:04 2026 +0900"
      },
      "committer": {
        "name": "Kousuke Saruta",
        "email": "sarutak@apache.org",
        "time": "Tue Nov 24 01:00:04 2026 +0900"
      },
      "message": "[SPARK-60592][UI][TEST] Fix flaky CSP compliance ui-tests caused by the default Jest timeout\n\n### What changes were proposed in this pull request?\n\nThis PR adds an explicit 60s per-test timeout to the two Content-Security-Policy tests in `ui-test/tests/csp-compliance.test.js`, declared through a `SCAN_TIMEOUT_MS` constant, replacing Jest\u0027s default 5000ms per-test timeout. What the tests verify is unchanged: the `img-src` test checks whether any CSS uses a `data:image/` URI and, if so, asserts `HttpSecurityFilter`\u0027s CSP allows `data:`; the nonce test flags any `\u003cscript\u003e` tag without a `src` attribute and without `nonce\u003d{CspNonce.get}`.\n\n### Why are the changes needed?\n\nBoth tests glob every `*.css` and `*.scala` file under the repository root and scan the matches, and run under Jest\u0027s default 5000ms per-test timeout, since `ui-test/package.json` sets none. On a loaded CI runner the repository-wide glob intermittently exceeds 5s and the tests fail with `Exceeded timeout of 5000 ms for a test`. Observed on fork CI:\n\n- https://github.com/Ma77Ball/spark/actions/runs/40570940333/job/122425515632 — both tests timed out. The `img-src` test exceeded 5s even though it reads only ~20 CSS files, so the time went into the repository-wide glob or a slow runner rather than the file reads.\n- https://github.com/szehon-ho/spark/actions/runs/40007567459/job/120600314519 — only the nonce test timed out.\n\nThe explicit 60s timeout leaves ample headroom for a slow glob so the tests stop failing for reasons unrelated to the CSP properties they check.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo. The change is limited to a test file; no production code or behavior changes.\n\n### How was this patch tested?\n\nRan the `csp-compliance.test.js` suite locally: both tests pass in ~2.7s. Also ran the full `ui-test` Jest suite: 11 suites / 31 tests pass in ~3.8s.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 4.8\n\nCloses #59840 from Ma77Ball/fix-csp-ui-test-flaky-timeout.\n\nAuthored-by: Matthew B. \u003cmgball@uci.edu\u003e\nSigned-off-by: Kousuke Saruta \u003csarutak@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "2846aa5db53463b368c1a46dafbe6ecdf7d01d73",
      "tree": "aaeab989649a74ec46ffe32f6bd50b89bc167b44",
      "parents": [
        "13348f79732bf26dac74d98bb2db4a098a4336c1"
      ],
      "author": {
        "name": "John Zhuge",
        "email": "jzhuge@apache.org",
        "time": "Tue Nov 24 00:58:19 2026 +0900"
      },
      "committer": {
        "name": "Kousuke Saruta",
        "email": "sarutak@apache.org",
        "time": "Tue Nov 24 00:58:19 2026 +0900"
      },
      "message": "[SPARK-60483][SQL] Add spark.sql.extensions.defaultList for platform default session extensions\n\n### What changes were proposed in this pull request?\nAdd `spark.sql.extensions.defaultList`, a static SQL conf holding operator-provided session extensions that are applied ahead of the user-provided `spark.sql.extensions`. An extension listed in both configs is de-duplicated with last-win semantics: every occurrence of it is dropped from the default list, so it is applied only at its positions in `spark.sql.extensions`, and a warning is logged; other repeats within a single list stay allowed (as SPARK-26493 allowed for `spark.sql.extensions`). The doc of `spark.sql.extensions` is updated to describe this, and to note that `SET` / `spark.conf.get` show only its own value.\n\n### Why are the changes needed?\nPlatform or cluster operators often need a set of SparkSessionExtensions active for every application, but a user-supplied `spark.sql.extensions` value replaces the operator\u0027s value, silently dropping operator extensions. This config lets operators guarantee a baseline set of extensions while users still add their own. Proposal: https://issues.apache.org/jira/browse/SPARK-60483\n\n### Does this PR introduce _any_ user-facing change?\nYes, a new static SQL config `spark.sql.extensions.defaultList` (unset by default). Behavior is unchanged when it is not set. An extension listed in both configs is applied only at its positions in `spark.sql.extensions`, with a warning. Note that `spark.conf.get(\"spark.sql.extensions\")` / `SET spark.sql.extensions` show only the user-provided value; the effective list also includes the default-list extensions.\n\n### How was this patch tested?\nNew unit tests in `SparkSessionExtensionSuite`:\n- default list applied ahead of user-specified extensions\n- default list honored when user-specified `spark.sql.extensions` is unset\n- an extension listed in both configs is applied once instead of twice\n- a shared extension is applied last-win: it runs only at its positions in the user-specified list, keeping the user list\u0027s repeats, with a warning logged; plain concatenation or first-win would give a different rule order\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Pi 1.5.2 (DeepSeek-V4.1-Flash-1017)\n\nCloses #59743 from jzhuge/SPARK-60483.\n\nAuthored-by: John Zhuge \u003cjzhuge@apache.org\u003e\nSigned-off-by: Kousuke Saruta \u003csarutak@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "13348f79732bf26dac74d98bb2db4a098a4336c1",
      "tree": "2224da42bc7867eeeee7ee02943d9eac743de385",
      "parents": [
        "659273a41595e2ed86976c0be6d0a6e6b9923ef7"
      ],
      "author": {
        "name": "Luka Zdravić",
        "email": "lukazdravic10@gmail.com",
        "time": "Mon Nov 23 14:49:30 2026 +0000"
      },
      "committer": {
        "name": "Wenchen Fan",
        "email": "wenchen@databricks.com",
        "time": "Mon Nov 23 14:49:30 2026 +0000"
      },
      "message": "[SPARK-62245][SQL] Keep the DataFrame as-of join tolerance bound inclusive when allowExactMatches is false\n\n### What changes were proposed in this pull request?\n`AsOfJoin.makeAsOfCond` no longer makes the tolerance bound strict when `allowExactMatches \u003d false`. `allowExactMatches` now changes only the match itself (`\u003e` instead of `\u003e\u003d`, `\u003c` instead of `\u003c\u003d`, and `l \u003c\u003e r` for nearest). The tolerance bound stays `\u003e\u003d` / `\u003c\u003d` for backward, forward and nearest. Both engines share this condition (the old rewrite and the sort-merge operator), so both change.\n\nA line in `docs/sql-migration-guide.md` describes the change.\n\n### Why are the changes needed?\nA right row that is exactly `tolerance` away was dropped only when `allowExactMatches \u003d false`. SQL `ASOF JOIN` and pandas `merge_asof` (for exact key types) keep it.\n\n```\nleft 5, right 3, tolerance 2, backward, allowExactMatches \u003d false\nSQL: MATCH_CONDITION (l.t \u003e r.t) ON r.t \u003e\u003d l.t - 2   -\u003e keeps 3\npandas merge_asof(tolerance\u003d2, allow_exact_matches\u003dFalse) -\u003e keeps 3\nDataFrame joinAsOf, before this PR                    -\u003e no row\n```\n\n### Does this PR introduce _any_ user-facing change?\nYes. `pyspark.pandas.merge_asof` (and the internal DataFrame as-of join under it) with `tolerance` and `allow_exact_matches\u003dFalse` now keeps a right row exactly `tolerance` away. Before, that row was dropped. There is no switch for the old result. Known difference: on an equal-distance tie, nearest with the old rewrite picks any one row. Now a tie can also happen with one row on each bound. Not changed here.\n\n### How was this patch tested?\n- `DataFrameAsOfJoinSuite`: new tests for backward, forward and nearest with INT, DATE and TIMESTAMP keys. Each runs with the sort-merge flag off and on (and the single-pass analyzer with it on), ANSI off and on, `allowExactMatches` off and on. They check rows on the bound (kept), one past the bound (dropped) and an exact match (still dropped for backward and forward).\n- `RewriteAsOfJoinSuite`: the three tolerance + `allowExactMatches \u003d false` plan tests now expect `\u003e\u003d` / `\u003c\u003d`.\n- `SortMergeAsOfJoinSuite`: the \"boundary\" case of the interval tolerance test now expects a match.\n- `test_merge_asof.py`: new test compares `ps.merge_asof` with `pd.merge_asof` on the bound, all directions. Not run here (no pandas).\n- Also ran `AsOfJoinSQLSuite`, `AsOfJoinSortMergeSQLSuite`, `SortMergeAsOfJoinScannerSuite`, `StreamingAsOfJoinSuite`, `FilterPushdownSuite`, `InferFiltersFromConstraintsSuite`.\n\n### Was this patch authored or co-authored using generative AI tooling?\nGenerated-by: Claude Code\n\nThis pull request and its description were written by Isaac.\n\nCloses #60798 from LukaZdravic/asof-df-tolerance-inclusive.\n\nAuthored-by: Luka Zdravić \u003clukazdravic10@gmail.com\u003e\nSigned-off-by: Wenchen Fan \u003cwenchen@databricks.com\u003e\n"
    },
    {
      "commit": "659273a41595e2ed86976c0be6d0a6e6b9923ef7",
      "tree": "37e0cc6089e6f929eb1e7e2288befd55b4bd3871",
      "parents": [
        "783a4907a17f240e9122519a1971f278355fb2bf"
      ],
      "author": {
        "name": "Tengfei Huang",
        "email": "tengfei.huang@databricks.com",
        "time": "Mon Nov 23 15:22:57 2026 +0800"
      },
      "committer": {
        "name": "Yi Wu",
        "email": "yi.wu@databricks.com",
        "time": "Mon Nov 23 15:22:57 2026 +0800"
      },
      "message": "[SPARK-60548][CORE] Handle shuffle checksum mismatches detected in stage attempt 0\n\n### What changes were proposed in this pull request?\n\nThis PR initializes `Stage.maxChecksumMismatchedId` to `-1` instead of `nextAttemptId`, which is always `0` when a stage is constructed.\n\nWhen a shuffle checksum mismatch is detected while registering map output, `DAGScheduler` rolls back the succeeding stages only if the following guard passes:\n\n```scala\nif (shuffleStage.maxChecksumMismatchedId \u003c smt.stageAttemptId) {\n  shuffleStage.maxChecksumMismatchedId \u003d smt.stageAttemptId\n  if (shuffleStage.shuffleDep.checksumMismatchQueryLevelRollbackEnabled) {\n    rollbackSucceedingStagesForQuery(shuffleStage)\n  } else {\n    rollbackSucceedingStages(shuffleStage)\n  }\n}\n```\n\nWith the marker starting at `0`, the guard can never pass for a task from stage attempt `0`. With `-1`, the first checksum mismatch in attempt `0` goes through the existing rollback/abort handling. Later mismatches in the same attempt are still deduplicated, and the behavior for attempts `1` and later is unchanged.\n\n### Why are the changes needed?\n\nA checksum mismatch can be detected by a task from stage attempt `0` in two cases, and both were silently accepted:\n\n1. **A shuffle map stage is recreated for an existing shuffle.** When a job finishes, its stages are cleaned up, but `MapOutputTracker` keeps the shuffle\u0027s map statuses and their checksums. If some map output is later lost and a subsequent job that depends on the same shuffle recomputes the missing partitions, the new `ShuffleMapStage` starts at attempt `0`. If the recomputed output differs from the previous output, the mismatch is detected in attempt `0`.\n2. **A late task from attempt `0` replaces the output of a later attempt.** When attempt `0` of a non-barrier shuffle map stage fails with a `FetchFailed`, its other running tasks are not killed. If one of them finishes after attempt `1` has recomputed the same partition, it replaces attempt `1`\u0027s registered map output. A changed checksum here was ignored, while the reverse order (a late task from attempt `1` replacing attempt `0`\u0027s output) already triggered rollback.\n\nIn both cases, consumers that already read the previous output keep results computed from it, which can lead to incorrect query results.\n\n### Does this PR introduce _any_ user-facing change?\n\nNo\n\n### How was this patch tested?\n\nUTs added.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Code (Claude Opus 5.5)\n\nCloses #59793 from ivoson/SPARK-60548.\n\nAuthored-by: Tengfei Huang \u003ctengfei.huang@databricks.com\u003e\nSigned-off-by: Yi Wu \u003cyi.wu@databricks.com\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "783a4907a17f240e9122519a1971f278355fb2bf",
      "tree": "60d0a1b74f9fb15d6e85b3daf5565544b237857a",
      "parents": [
        "082cf160890a0a0a748f70ffb5a993144b0de079"
      ],
      "author": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Sun Nov 22 20:37:13 2026 -0800"
      },
      "committer": {
        "name": "Dongjoon Hyun",
        "email": "dongjoon@apache.org",
        "time": "Sun Nov 22 20:37:13 2026 -0800"
      },
      "message": "[SPARK-62146][SQL] Fix INTERNAL_ERROR when a UDF registered with `spark.udf.register` is called with named arguments\n\n### What changes were proposed in this pull request?\n\nThis PR makes the functions registered with `spark.udf.register` reject named arguments, as the built-in functions and the Python UDFs without named argument support do.\n\nThe builder of such a function passes the arguments of a call as they are. So for `f(x \u003d\u003e 1L)`, the call gets a `NamedArgumentExpression` as its argument, which is `Unevaluable`, and the query passes analysis and fails during execution. This PR wraps the builders that the classic `UDFRegistration` registers, so that a call with a named argument fails with `NAMED_PARAMETERS_NOT_SUPPORTED`, which `FunctionRegistryBase.build` raises for a built-in function and `UserDefinedPythonFunction.builder` for a Python UDF. The wrapped builders are those of:\n\n- Scala and Java UDFs and typed `Aggregator`s, registered through `register(name, udf, source, validateParameterCount)`.\n- `UserDefinedAggregateFunction`s, registered through the deprecated `register(name, udaf)`.\n\nSpark Connect registers these functions with the same methods (`SparkConnectPlanner`), so it gets the same error.\n\n### Why are the changes needed?\n\nA call of such a function with a named argument fails with an INTERNAL_ERROR, instead of a user-facing error.\n\n```scala\nscala\u003e spark.udf.register(\"f1\", (x: Long) \u003d\u003e x + 1)\n\nscala\u003e spark.sql(\"SELECT f1(x \u003d\u003e 1L)\").collect()\norg.apache.spark.SparkException: [INTERNAL_ERROR] Cannot generate code for expression: x \u003d\u003e 1 SQLSTATE: XX000\n```\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. Such a call fails during analysis with `NAMED_PARAMETERS_NOT_SUPPORTED`, instead of failing with `INTERNAL_ERROR` during execution.\n\n```\n[NAMED_PARAMETERS_NOT_SUPPORTED] Named parameters are not supported for function `f1`; please retry the query with positional arguments to the function call instead. SQLSTATE: 4274K\n```\n\nThe builders have not checked named arguments since #41796 (SPARK-43922) added them in [v3.5.0](https://github.com/apache/spark/releases/tag/v3.5.0) (2023-09-09). I confirmed the INTERNAL_ERROR above on the released [v4.0.5](https://github.com/apache/spark/releases/tag/v4.0.5) (2026-10-21), [v4.1.4](https://github.com/apache/spark/releases/tag/v4.1.4) (2026-10-21), [v4.2.1](https://github.com/apache/spark/releases/tag/v4.2.1) (2026-10-21) and [v4.3.0](https://github.com/apache/spark/releases/tag/v4.3.0) (2026-10-27).\n\n### How was this patch tested?\n\nPass the CIs with the newly added test case, which fails without this PR.\n\n- `UDFSuite`: a call with a named argument fails with `NAMED_PARAMETERS_NOT_SUPPORTED`, with the query context of the call, for a Scala function, a `UserDefinedFunction`, a typed `Aggregator` and a `UserDefinedAggregateFunction` registered with `spark.udf.register`.\n\nI also ran `UDFSuite`, `JavaUDFSuite`, `JavaUDAFSuite`, `FunctionQualificationSuite` and `named-function-arguments.sql` of `SQLQueryTestSuite` locally.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #60768 from dongjoon-hyun/SPARK-62146.\n\nAuthored-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\nSigned-off-by: Dongjoon Hyun \u003cdongjoon@apache.org\u003e\n\n\nskip-checks: true\n"
    },
    {
      "commit": "082cf160890a0a0a748f70ffb5a993144b0de079",
      "tree": "6942e3149493189eacbfe87d03e93dd3b02911ce",
      "parents": [
        "0716d47bf5d0e67b42c0b4a0a61dc26b1d7cf898"
      ],
      "author": {
        "name": "YangJie",
        "email": "yangjie01@baidu.com",
        "time": "Mon Nov 23 10:46:53 2026 +0800"
      },
      "committer": {
        "name": "yangjie01",
        "email": "yangjie01@baidu.com",
        "time": "Mon Nov 23 10:46:53 2026 +0800"
      },
      "message": "[SPARK-60451][SQL] Fix wrong results from V2 CHECK constraints, defaults and generated columns on special datetime values\n\n### What changes were proposed in this pull request?\n\n`V2ExpressionBuilder` folds an expression by evaluating it when `contextIndependentFoldable` is true. That is true for a cast of a special datetime string such as \u0027today\u0027 or \u0027epoch\u0027 to DATE, TIMESTAMP_NTZ or TIMESTAMP_NTZ(p), but only the optimizer rule `SpecialDatetimeValues` gives the string its value. Evaluating the cast treats the string as malformed.\n\nThis PR makes such a cast not context independent. The builder handles every cast that `SpecialDatetimeValues` replaces, including one to TIMESTAMP or TIMESTAMP_LTZ(p), which under ANSI mode became a V2 cast of the string. A cast of \u0027epoch\u0027 becomes its fixed value, also inside another expression other than such a cast, unless its string reads the current date. A cast of \u0027now\u0027, \u0027today\u0027, \u0027tomorrow\u0027 or \u0027yesterday\u0027 gets no V2 form, like `current_date()`, so Spark reads the SQL text of the CHECK constraint, DEFAULT value or generation expression.\n\n### Why are the changes needed?\n\nOn a Data Source V2 catalog, since SPARK-52875 (4.1.0), these give wrong results with ANSI mode off and fail with it on:\n\n```sql\nCREATE TABLE t (id INT, d DATE, CONSTRAINT c CHECK (d \u003c\u003d CAST(\u0027today\u0027 AS DATE)));\n-- ANSI on: fails with CAST_INVALID_INPUT\n-- ANSI off: stores the predicate d \u003c\u003d NULL, so every row passes\nCREATE TABLE t (id INT, d DATE DEFAULT CAST(\u0027today\u0027 AS DATE));\n-- ANSI on: fails with CAST_INVALID_INPUT\n-- ANSI off: INSERT INTO t(id) VALUES (1) writes NULL\n```\n\n`CHECK (d \u003c\u003d \u0027today\u0027)`, REPLACE TABLE, `ADD COLUMNS`, `ALTER COLUMN ... SET DEFAULT` and `GENERATED ALWAYS AS (CAST(\u0027today\u0027 AS DATE))` behave the same.\n\n### Does this PR introduce _any_ user-facing change?\n\nYes. On a Data Source V2 catalog, such a CHECK constraint, DEFAULT value or generated column is accepted under ANSI mode, and each write computes its value. For all but \u0027epoch\u0027, `Check.predicate()` and the expressions of `ColumnDefaultValue` and `GenerationExpression` are null, so a connector reads the SQL text. For \u0027epoch\u0027 they hold its value.\n\nA table created before this fix with ANSI mode off keeps what it stored, such as the predicate `d \u003c\u003d NULL` or a `NULL` default, and writes keep using it. The migration guide says how to fix it.\n\n### How was this patch tested?\n\nNew tests:\n\n- `CastSuiteBase`: casts of special values to DATE, TIMESTAMP_NTZ and TIMESTAMP_NTZ(p) are not context independent. Other strings still are.\n- `CheckConstraintSuite`: with ANSI on and off, CREATE and REPLACE TABLE on \u0027today\u0027 or \u0027now\u0027 with DATE, TIMESTAMP, TIMESTAMP_NTZ(9) and TIMESTAMP_LTZ(9) store no predicate. On \u0027epoch\u0027, or `CAST(\u0027epoch\u0027 AS DATE) - 1`, CREATE TABLE stores the predicate ALTER TABLE stores. Each accepts one row and rejects another.\n- `DataSourceV2DataFrameSuite`: DEFAULT and generated column `CAST(\u0027today\u0027 AS DATE)` have no V2 expression, DEFAULT `CAST(\u0027epoch\u0027 AS DATE) + 1` has a date literal, and a write fills them in. Defaults on \u0027today\u0027 or \u0027tomorrow\u0027 set by `ADD COLUMNS` or `ALTER COLUMN` have no V2 expression either. A filter with a cast of \u0027epoch\u0027 that the optimizer fails to fold is not translated.\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Claude Opus 5.5\n\nCloses #60549 from LuciferYang/SPARK-60451.\n\nAuthored-by: YangJie \u003cyangjie01@baidu.com\u003e\nSigned-off-by: yangjie01 \u003cyangjie01@baidu.com\u003e\n\n\nskip-checks: true\n"
    }
  ],
  "next": "0716d47bf5d0e67b42c0b4a0a61dc26b1d7cf898"
}
