Skip to content

Updated programming-guide.md - #1324

Closed
riverma wants to merge 1 commit into
apache:masterfrom
riverma:patch-1
Closed

riverma wants to merge 1 commit into
apache:masterfrom
riverma:patch-1

Conversation

@riverma

@riverma riverma commented Jul 7, 2014

Copy link
Copy Markdown
Contributor

Made sure that readers know the random number generator seed argument, within the 'takeSample' method, is optional.

Made sure that readers know the random number generator seed argument, within the 'takeSample' method, is optional.
@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@rxin

rxin commented Jul 8, 2014

Copy link
Copy Markdown
Contributor

Thanks. Merging this in master.

@asfgit asfgit closed this in 0128905 Jul 8, 2014
@riverma
riverma deleted the patch-1 branch July 9, 2014 18:50
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
Made sure that readers know the random number generator seed argument, within the 'takeSample' method, is optional.

Author: Rishi Verma <riverma@apache.org>

Closes apache#1324 from riverma/patch-1 and squashes the following commits:

4699676 [Rishi Verma] Updated programming-guide.md
kazuyukitanimura pushed a commit to kazuyukitanimura/spark that referenced this pull request Aug 10, 2022
### What changes were proposed in this pull request?

This PR is required for the following.

rdar://79590736 (ACI Spark on EKS - Error when enabling RPC authentication and encryption)

### Why are the changes needed?

AWS EKS doesn't support SDR while ACI Kube does. We need this.

### Does this PR introduce _any_ user-facing change?

No, this is a recovery of Apache Spark feature.

### How was this patch tested?

Pass the CIs with newly added test case.
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 4, 2026
…time (apache#1329)

### What changes were proposed in this pull request?

Each node of Varka's vector IR now stores its structural hash, computed once when the node is built. Before this change a node's `hashCode` walked its whole subtree on every call, so planning a tree that shares a node between several parents took time in proportion to the number of paths through it, not the number of nodes. Every level that reads a shared operand twice or more doubles the paths.

**The cost on master.** Three lowerings read their operand several times: a year-month interval's `abs` (three paths per level), an interval divided by a literal (seven: the quotient, the remainder under both arms of its rounding, and the sign test) and a `DOUBLE` `signum` (four). Nesting them makes planning exponential, and the planner pays it before the emitter's budget declines the shape:

| expression, nested | depth | before | after |
|---|---:|---:|---:|
| year-month interval `abs(X)` | 16 | 25544.44 ms | 0.48 ms |
| year-month interval `(X) / 3` | 8 | 10017.80 ms | 0.55 ms |
| `signum(X)` over `DOUBLE` | 12 | 17585.49 ms | 0.84 ms |

The table is from `sql/varka/plans/m8/results/VARKA-559-planning-cost.txt`, measured on the laptop. Every chain gets the same verdict at every depth before and after: fused, or the same decline reason. The pending decimal `coalesce` (apache#1324) shares its condition the same way; with this change, its depth-20 chain plans in 1.77 ms instead of 4576.85 ms.

**The design.** Each of the 47 IR records with a child gets a last component, `int hash`, computed in the compact constructor from the other components. `hashCode` returns it. The value is exactly what the record's generated `hashCode` gives (`31 * h + hashCode(component)` from zero, in declaration order), so every hash set and map holds what it held before. A second constructor without `hash` keeps every call site unchanged, and the canonical one ignores the value it is given. The records stay records. Since `hash` is the last component, the generated `equals` compares it first, so two unequal nodes differ after one comparison. The only other code change is a trailing `_` in the 31 record patterns in the test-only reference evaluator.

Two alternatives were set aside (plan section 3). Interning nodes at construction would add a second notion of node identity, which an earlier task (VARKA-222) judged too complex. A memo per walker can't replace the structural sets the budget walk and the kernel plan rely on, and would rebuild this cache in each of eleven walkers.

**What is deliberately unchanged** (plan 2.3): `canonical()`, which renders the pinned shape keys and runs only on shapes the budget admits; the lane lifts, which rebuild a shared node once per path but only for predicates with conjuncts on two lanes; and `equals` between two equal copies that share no object.

**This reopens VARKA-222**, closed on 10 October 2026 on the measurement that IR hashing is at most 5% of emission because the fused budget caps every output's subtree. That premise did not hold, because the hashing is paid before and inside the budget check. Its reopen trigger (3.1) is met; PLAN.md row 559 and a note in VARKA-222's 3.1 record it.

### Why are the changes needed?

A query that nests one of these expressions a dozen levels deep spent seconds to tens of seconds in planning on the driver, and every further level multiplied that. It also blocked the decimal choices (apache#1324), whose nested `coalesce` met the same cost at about four seconds for 20 levels.

### Does this PR introduce _any_ user-facing change?

Yes, for users who enable Varka: planning these nested expressions takes milliseconds instead of seconds. Answers, decline reasons and generated kernels are unchanged.

### How was this patch tested?

- A new `VarkaVectorIRSharingSuite`:
  - a coalesce-shaped DAG 60 levels deep (2^60 paths) on the long, int and short lanes goes through every planning step that hashes nodes, within 20 s;
  - nested `signum`, interval `abs` and interval division explain at depth 20 and are not fused;
  - structurally equal nodes still collapse in a set;
  - one node of every record type with a child, built by reflection, caches the hash the record formula gives;
  - the canonical constructor recomputes the hash it is passed.

  Two known limits of the reflective check, each failing loudly rather than passing silently: it tries at most six constants per enum, the IR's largest enum today, and it builds nodes with equal values in components of one type, so it would not notice two same-type components swapped in a hash (which would still agree with `equals`).
- `dev/varka_regen_generated.sh --all` changed no file: no emitted byte and no coverage row moves.
- The catalyst Varka suites that build or walk the IR (410 tests, including the emitter, shape-cache, fuzz, coverage and emitted-bytes suites) and the sql coverage-differential and filter suites pass.
- An independent high review found no correctness defect: the cached hash agrees with `equals` for every record (no array, mutable, float or double component; the one list is copied), and nothing persisted or pinned changes. Its findings on test robustness and plan text were fixed and had a medium review.
- Error Prone, scalastyle, lint-java and the plan, quote and pre-commit checks pass. The change counts 999 hand-written lines.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5.5)
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 4, 2026
…#1324)

### What changes were proposed in this pull request?

Varka now fuses the choices and the null tests over `DECIMAL` values of precision 18 or less: `IF`, `CASE WHEN` with an `ELSE`, `coalesce`, `greatest` and `least`, and `IS NULL` / `IS NOT NULL` over any decimal value, not only over a column. Before this change each of them sent its filter or projection to Spark's row path.

**The choices.**
- **`IF` and `CASE WHEN ... ELSE`** fold to the long lane's `IfElse`, with each condition lifted to the long lane. A choice whose branches have different scales is compared at the common type, each branch rescaled up as the comparisons already are.
- **`coalesce`** folds to `IfElse(valid(head), head, rest)`.
- **`greatest` and `least`** are the existing null-skipping picks.
- Each of them runs under the family switch that already claims its int form, so turning a family off turns off its decimal form too.

**The null tests.** An IR null test reads only a column's validity word, so a null test over any other decimal value derives its validity from the leaves (`VarkaDecimalCompiler.valid`): a negation or `abs` is null where its operand is, a `coalesce` where every operand is, a pick where every operand is, a choice where the chosen branch is. The value is first compiled as a probe so it declines with the same reasons as when it is read. A null test also reads through a cast that keeps the scale and only widens the precision, such as `CAST(d18 AS DECIMAL(20, 0)) IS NULL`, since that cast can never null or fail.

**What still declines, by name.** A null decimal literal in a branch names row 333, whose typed null value it needs. A wide choice or pick whose branch is rescaled up names row 360 beside 359, on either side of a comparison. A cast that lowers the scale or the integral digits over a wide rescale names row 350 beside them.

**Proofs.** `refinement.smt2` gains three sections for the choices and the null tests, 276 checks in all, which hold under Z3 and cvc5 (`dev/varka_prove.sh`). The `coalesce` and `CASE` rows raise on every column's slot, as Spark's generated filter reads every column a predicate references.

**Tests.**
- **`VarkaDecimalValueSuite`** compiles each choice and null-test form, checks the decline reasons in either operand order, and checks the null test's answers against Spark's on nulls and at the bounds.
- **Coverage rows**, checked against Spark by the differential suites: `greatest(d9, d9s4) > d9b`, `coalesce(d9, d9b) IS NULL`, `(-d18) IS NOT NULL`, and `CASE WHEN d9 < d9b THEN d9 ELSE d9s4 END > 0.0`.
- **The decimal leaf's slot table** covers the bare leaf's null test.

**This is the last of three parts.** Row 348, the 64-bit decimal conditions, lands in three pull requests under the 1000-line cap, cut from the draft apache#1304: comparisons at different scales (apache#1321), negation and `abs` (apache#1323), and this one. The parts table is in `sql/varka/plans/m8/VARKA-348.md` section 5, and its outcome in section 10.

**Generated files**, regenerated with `dev/varka_regen_generated.sh --all`:
- `coverage.json`, `width_audit.json` and `docs/sql-varka.md` gain the four rows.
- `emitted_bytes.json` gains the new shapes; no existing row's hash moves, and only the option-arm digests, which hash every shape, change.
- The census (`census.tsv`) records the choices and null tests over decimals.
- The rendered proof files are as above.

### Why are the changes needed?

Choices and null tests over decimal values are common in real queries: a `CASE` that picks a price by a condition, a `coalesce` of two amounts, a `greatest` of two rates, or a null check on an adjusted value. Each one sent its whole filter back to Spark's row path, even when every other part of it fused.

### Does this PR introduce _any_ user-facing change?

Yes, for users who enable Varka: these choices and null tests over decimals of precision 18 or less now run in Varka's kernels, with the same answers.

### How was this patch tested?

- The tests above, plus `VarkaDecimalLoadSuite`, `VarkaFamilySwitchSuite`, `VarkaProofFilesSuite`, `VarkaEmittedBytesSuite`, `VarkaCoverageSuite` and `VarkaCoverageDifferentialSuite`. `dev/varka_prove.sh --solver both` holds.
- An independent high review found no wrong answers. Its findings are fixed:
  - a null decimal literal and a wide branch rescaled up declined without naming the rows that build them;
  - the null test's probe and its family notes, which the family switch suite requires;
  - a refinement departure that was no longer needed, since Spark's filter reads every referenced column.
- A medium review of those fixes found three more, fixed with a test each: a null test through a widening cast declined, the rescale test did not look through a negation or `abs`, and a lowering cast over a wide rescale did not name row 350.
- **A planning cost found on the way, and fixed separately.** The first matrix run timed out a test that nests a `coalesce` 20 deep. Profiling showed that Varka's compile is linear, but planning a nested `coalesce` took 2^depth time: its IR shares one condition between a value and its validity, and the IR records' `hashCode` walked the shared node once per path (4.6 s at depth 20). The fix, a hash cached in each IR node, landed first as apache#1329, and this branch merges it. The test now counts condition compiles instead of timing them, and its three chains nest 20 deep in well under a second.
- Error Prone, scalastyle, lint-java and the census, generated-file, plan, quote and pre-commit checks pass. The change counts 992 hand-written lines.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5.5)
github-actions Bot pushed a commit to MaxGekk/spark that referenced this pull request Nov 4, 2026
…'s matrix (apache#1335)

### What changes were proposed in this pull request?

**Scope `DeclineSink.java` to Varka.** The Build decides from a pull request's changed files whether it runs only Varka's jobs or Spark's whole module matrix: a file that `is_varka_scoped` (`dev/sparktestsupport/modules.py`) does not recognise selects its Spark module. `sql/catalyst/.../expressions/codegen/DeclineSink.java` is a Varka class - only Varka's compilers use it, and it is package-private - but it carries no Varka name, so a change to it selected `catalyst` and everything that depends on it. apache#1324 changed it and its Build ran the whole matrix, 2 h 18 min, though all its other files were Varka's. The scope list now names the file, with a doctest.

The other files Varka commits added without the name stay unscoped on purpose: Spark-side benchmarks that measure Spark's own code generation, the Arrow cache's shared reader and writer, composite actions Spark's own workflows also use, and the JUnit listener registration every catalyst JUnit run reads.

**Run the tier split's self-test in the Build.** The nightly JIT tier-split job (apache#1332) checks its own night-deciding check on fixture logs before each run. Its line in the Build's Varka checks was left out of apache#1332 so that apache#1332's own Build stayed scoped; it rides here because this change edits a non-Varka file and runs the whole matrix once anyway.

### Why are the changes needed?

Every pull request that touches `DeclineSink.java` paid a full Spark module matrix (about two and a half hours, on the fork's shared runner slots) for a Varka-only change.

### Does this PR introduce _any_ user-facing change?

No. It changes CI test selection and adds one CI step.

### How was this patch tested?

- `cd dev && python3 -m doctest sparktestsupport/modules.py` passes, including the new case; the pattern is anchored and rejects near-miss paths (a prefixed path, the test tree, a `.bak` copy).
- With the pattern, apache#1324's 19 changed files classify as Varka-scoped; without it, `DeclineSink.java` alone makes them Spark's.
- `git grep DeclineSink` finds only Varka files.
- `dev/varka_tier_split.py --self-test` passes on this tree, which now includes apache#1332.
- `dev/varka_plan_lint.py`, `dev/varka_lint.py`, `dev/varka_quote_check.py` and ruff pass. An independent review found the scope change correct and flagged that the self-test step needed apache#1332 merged first; this branch now includes it.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5.5)
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 5, 2026
…l requests (apache#1370)

### What changes were proposed in this pull request?

Seventeen rows of `sql/varka/plans/m8/PLAN.md` still read as before work that has merged. Each is corrected against its merged pull requests, which `git log` lists by the row's `[VARKA-n]` tag:

- **Now `Done`:** row 497 (one `IN` arm for every lane, apache#1259), row 333 (apache#1260) and row 365 (the Arrow cache's small decimals read as vanilla Spark reads them, apache#1306). The done-when of each is met by that pull request, and the "left" text that waited on it is gone.
- **Still `Started` or `Done in part`, with merged parts named:** rows 157, 330, 331, 332, 333, 340, 341, 342, 343, 344, 348, 349, 377, 503 and 538. Branch names that stood for work now merged become the pull request numbers and dates (for example 348's four parts, apache#1321, apache#1323, apache#1324 and apache#1349), and a "left" item that merged is dropped (538's flip, apache#1345; 341's mask crossing, closed by 343a3 and 343a3b; 377's decimal class, apache#1055).
- Row 377 now says what is still open: the floating baseline does not state whether its data holds denormals, which its done-when of 27 October 2026 asks.
- Rows 332 and 333 are read against their done-when. Row 333 is `Done` (apache#1260: its outcome records the census, the coverage rows and the unmoved `date_add` bytes). Row 332 stays `Started`: its 14 non-identity casts fuse (apache#1291), and what is left is 332b's in-range conformance value sets, the measurement against the baseline (no results file exists), two gaps from the 2 November review, and row 352's fuzz productions.

Only row text changes; no code, result or generated file.

### Why are the changes needed?

A reader who takes a row's state at its word re-plans or restarts work that merged, which the triage of 4 November 2026 found for these rows.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

`dev/varka_plan_lint.py` and `dev/varka_quote_check.py` pass. Every pull request number and date in the new text was read from `git log` of master.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Sonnet 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants