Repository navigation
Conversation
…park with Groovy Contributes documentation that explains how one can use Spark with the Groovy without additional wrappers. Also adds some examples that demonstrate the benefits of using Spark with Groovy.
|
Can one of the admins verify this patch? |
|
Thanks for submitting this. While the content can be very helpful to Groovy developers, I think this is best done in a separate repository and/or via blog posts. I'd be happy to link to the separate repo / blog posts if you put them up. |
|
@Artjom-Metro would you be interested in hosting this somewhere as a "semi-official" groovy guide for Spark? We could link to it from the main Spark documentation. I think this would be a good pattern to follow in the future as people experiment with other JVM language API's for Spark. |
|
Okay, I will take care of that in the next weeks and reply when the website is up. |
|
@Artjom-Metro Do you mind closing this PR then? We are trying to clean up some of the older ones. Feel free to e-mail the spark developers list when you have something and we can put up a link on the website. Thanks! |
|
Okay, I'm sorry for the delay. It took some time to get access to a server, I hope to publish the result within the next 2 weeks. |
|
@Artjom-Metro Thanks for the examples. This is a great resource! |
…#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)
Contributes documentation that explains how one can use Spark with the Groovy without additional wrappers. Also adds some examples that demonstrate the benefits of using Spark with Groovy. The examples are similar to the ones provide for Java.