Repository navigation
Conversation
|
Can one of the admins verify this patch? |
Resolved conflict: project/SparkBuild.scala
There was a problem hiding this comment.
Looks like a copy-paste error? Did you mean to use "spark-kinesis-asl" here instead of "spark-ganglia-lgpl"?
There was a problem hiding this comment.
good catch, stephen. thanks!
|
Jenkins, this is ok to test |
|
Chris, is this new code from scratch, or is it based on Parviz's old pull request? |
|
QA tests have started for PR 1434. This patch merges cleanly. |
|
@mateiz - this is a completely brand-new, from-scratch implementation. parviz's old code was actually a Scala port of the Java-based Kinesis sample app found here: https://github.com/aws/aws-sdk-java/blob/master/src/samples/AmazonKinesisApplication/SampleRecordProcessor.java this was fine for a quick/dirty sample of kinesis functionality, but my goal was to make this code more reusable, testable, readable, configurable, production-ready, and well-documented. the old code did not support the new Streaming 1.0 API and extras/ build structure (due to ASL-license). i also updated the AWS Java SDK and Kinesis Client Libraries to their latest versions. here is parviz's PR for reference/comparison: #223. thanks and i look forward to getting this merged! -chris |
|
also, can someone address the questions i have here regarding the ec2 scripts and other peripheral aspects of this PR: https://issues.apache.org/jira/browse/SPARK-1981?focusedCommentId=14072761 thanks! -chris |
|
this PR worked for @srosenthal , btw. |
There was a problem hiding this comment.
Why is there a need for a complete script to run the kinesis example? Shouldnt the standard bin/run-example be sufficient?
The thing is that we want to have one streamlined way for running all the examples. The more special cases we make, the more we have to explicitly maintain in the future.
There was a problem hiding this comment.
@pdeyhim explained me that this script is necessary as the jar for kinesis is not included in the spark jar. That makes sense.
But its best not to put such module-specific scripts in the main spark/bin directory. Its best to put this in extras/kinesis/bin/ .
There was a problem hiding this comment.
yup, yup. this is a special circumstance due to the licensing. i didn't want to complicate the examples build by depending on an optional package, so this was the best workaround.
i put the scripts alongside the other scripts to reduce confusion, but i can move it to extras/kinesis/bin for sure. i'll update the docs accordingly.
|
@pdeyhim can you take a look over this too when you have a chance? |
|
Jenkins, this is ok to test. |
|
Jenkins, test this please. |
|
QA tests have started for PR 1434. This patch DID NOT merge cleanly! |
|
QA results for PR 1434: |
|
Hey @cfregly, My apologies for being so late to review this. Seems like the PR requires merging with the master, probably because of changes to pom.xml. Would you get a chance to merge with the master once again? |
There was a problem hiding this comment.
Can you rename is the directory spark-kinesis-asl to just kinesis. Its already in spark code base, so does not quite need another spark in the directory name. :)
There was a problem hiding this comment.
Aah, I understand, you must have followed the existing spark-ganglia-gpl directory name. Let me figure out why it was named so.
There was a problem hiding this comment.
Okay, I spoke to @pwendell and there is not need to have spark- as part of the name directory name and profile name. So can you make it kinesis-asl at all places.
There was a problem hiding this comment.
makes sense. i'll update.
There was a problem hiding this comment.
This lines was removed. as this property does not determine that.
updated the build to only include kinesis-asl inside the examples jar when -Pkinesis-asl is specified
|
QA tests have started for PR 1434. This patch merges cleanly. |
There was a problem hiding this comment.
Nit: Change this, this will be super confusing in future.
There was a problem hiding this comment.
oh yikes. yeah, that's just plain wrong.
There was a problem hiding this comment.
Correction, this is not a nit. Its already confusing ... please change this!
There was a problem hiding this comment.
Haha, didnt see your response. Good 👍
|
QA results for PR 1434: |
There was a problem hiding this comment.
This does not need to extend Logging.
There was a problem hiding this comment.
removed and cleaned up imports
retries around store() method
|
QA tests have started for PR 1434. This patch merges cleanly. |
|
QA results for PR 1434: |
|
Thanks you very much @cfregly! I have merged this!! |
Author: Chris Fregly <chris@fregly.com> Closes #1434 from cfregly/master and squashes the following commits: 4774581 [Chris Fregly] updated docs, renamed retry to retryRandom to be more clear, removed retries around store() method 0393795 [Chris Fregly] moved Kinesis examples out of examples/ and back into extras/kinesis-asl 691a6be [Chris Fregly] fixed tests and formatting, fixed a bug with JavaKinesisWordCount during union of streams 0e1c67b [Chris Fregly] Merge remote-tracking branch 'upstream/master' 74e5c7c [Chris Fregly] updated per TD's feedback. simplified examples, updated docs e33cbeb [Chris Fregly] Merge remote-tracking branch 'upstream/master' bf614e9 [Chris Fregly] per matei's feedback: moved the kinesis examples into the examples/ dir d17ca6d [Chris Fregly] per TD's feedback: updated docs, simplified the KinesisUtils api 912640c [Chris Fregly] changed the foundKinesis class to be a publically-avail class db3eefd [Chris Fregly] Merge remote-tracking branch 'upstream/master' 21de67f [Chris Fregly] Merge remote-tracking branch 'upstream/master' 6c39561 [Chris Fregly] parameterized the versions of the aws java sdk and kinesis client 338997e [Chris Fregly] improve build docs for kinesis 828f8ae [Chris Fregly] more cleanup e7c8978 [Chris Fregly] Merge remote-tracking branch 'upstream/master' cd68c0d [Chris Fregly] fixed typos and backward compatibility d18e680 [Chris Fregly] Merge remote-tracking branch 'upstream/master' b3b0ff1 [Chris Fregly] [SPARK-1981] Add AWS Kinesis streaming support (cherry picked from commit 91f9504) Signed-off-by: Tathagata Das <tathagata.das1565@gmail.com>
|
This was an epic pull request. Nice work, people. |
Author: Chris Fregly <chris@fregly.com> Closes apache#1434 from cfregly/master and squashes the following commits: 4774581 [Chris Fregly] updated docs, renamed retry to retryRandom to be more clear, removed retries around store() method 0393795 [Chris Fregly] moved Kinesis examples out of examples/ and back into extras/kinesis-asl 691a6be [Chris Fregly] fixed tests and formatting, fixed a bug with JavaKinesisWordCount during union of streams 0e1c67b [Chris Fregly] Merge remote-tracking branch 'upstream/master' 74e5c7c [Chris Fregly] updated per TD's feedback. simplified examples, updated docs e33cbeb [Chris Fregly] Merge remote-tracking branch 'upstream/master' bf614e9 [Chris Fregly] per matei's feedback: moved the kinesis examples into the examples/ dir d17ca6d [Chris Fregly] per TD's feedback: updated docs, simplified the KinesisUtils api 912640c [Chris Fregly] changed the foundKinesis class to be a publically-avail class db3eefd [Chris Fregly] Merge remote-tracking branch 'upstream/master' 21de67f [Chris Fregly] Merge remote-tracking branch 'upstream/master' 6c39561 [Chris Fregly] parameterized the versions of the aws java sdk and kinesis client 338997e [Chris Fregly] improve build docs for kinesis 828f8ae [Chris Fregly] more cleanup e7c8978 [Chris Fregly] Merge remote-tracking branch 'upstream/master' cd68c0d [Chris Fregly] fixed typos and backward compatibility d18e680 [Chris Fregly] Merge remote-tracking branch 'upstream/master' b3b0ff1 [Chris Fregly] [SPARK-1981] Add AWS Kinesis streaming support
There was a problem hiding this comment.
question: why do we need this log4j file here?
…MP_NTZ (apache#1434) ### What changes were proposed in this pull request? Spark builds a `TIMESTAMP_NTZ` from a date and a time of day in two ways: `make_timestamp_ntz(d, t)`, and `CAST(t AS TIMESTAMP_NTZ)`, which takes the date from `CURRENT_DATE`. The optimizer's `ComputeCurrentTime` rewrites the cast into the first form with the query's current date as a literal, so both reach Varka as one call, `DateTimeUtils.makeTimestampNTZ(days, nanos)`. That call is `LocalDateTime.of(date, time)` read at UTC, which is exactly `days * 86,400,000,000 + nanos / 1000` (the nanoseconds truncated), and it raises an `ArithmeticException` in every evaluation mode where that sum leaves the long. Before this change neither form fused. This change fuses both. - One arm in the `TIME` family, matched on the `makeTimestampNTZ` call through the table the family already keys its `TIME` functions by. It computes the date's midnight on the long lane (the int day widened and multiplied by the microseconds of a day, wrapping), adds the time's nanoseconds divided by 1000 with a checked add, and declines a batch to the row engine where the add overflows. The row engine then raises Spark's error on the row. - The multiply is exact only for a day whose midnight is a long, `|day| <= 106,751,991`. A date column is guarded to that range, the same guard `CAST(d AS TIMESTAMP_NTZ)` already uses (its body is factored into two helpers beside it). So a batch with a live day outside goes to the row engine. Inside the range the checked add raises exactly where Spark raises: on day 106,751,991 after 04:00:54.775807. It cannot underflow on day -106,751,991. Day -106,751,992 is declined whole, although its evening is a long, and the row engine answers it. - A date literal, which is what the rewritten cast carries, is checked against the same range when the kernel compiles. Outside it, the expression declines. Inside it, the literal takes a literal slot with no guard. Slot values travel as runtime arguments and are not part of the kernel's shape key, so every query date, and every session time zone, shares one emitted kernel class. - An unrewritten `CAST(time AS TIMESTAMP_NTZ)` now declines with a reason that names the rewrite. Such a cast reads the clock on every evaluation, and a real plan never carries one. - The test resolver (`VarkaSqlResolve.resolve`) applies `ComputeCurrentTime`, as a session's optimizer does (though in a different order, see below). So the coverage table, the cast matrix and the type conformance suite see the cast as a query compiles it. The coverage table reads its cast pairs from the expression as written, so the `TIME` to `TIMESTAMP_NTZ` pair still counts as cast. - Generated files regenerated: `coverage.json` and the docs (three rows), `casts_fused.tsv` and `casts.tsv` (`time` to `ntz` fused in LEGACY, ANSI and TRY), the census, `width_audit.json` and `emitted_bytes.json` (new shapes only). ### Why are the changes needed? A query that builds a timestamp from a date column and a time column, or casts a `TIME` to a timestamp, ran on Spark's row engine for that expression alone, while the date and `TIME` columns it reads and the fields of the result already fuse. This is the last expression step of the `TIMESTAMP_NTZ` decomposition. ### Does this PR introduce _any_ user-facing change? No change in results: answers and errors are Spark's in every mode. When Varka is enabled, `make_timestamp_ntz(date, time)` and `CAST(time AS TIMESTAMP_NTZ)` now run in Varka's fused kernels. A batch the guard or the checked add declines still goes to the row engine. ### How was this patch tested? - `VarkaTimestampNtzCastSuite` (kernels against Spark's own evaluation). The column form runs at the default, two and eight long lanes, in LEGACY and ANSI. Inside the bound it is answered: day 106,751,991 at 04:00:54.775807, day -106,751,991 at both ends of the day, and a `TIME(9)` ending in .999999999, truncated. A batch is declined at each point past the bound: the next microsecond on the last day, day -106,751,992 at both ends of the day, and the ends of the int range. A date literal is answered at both ends of the bound and declined at compile time past them, and two literal dates emit byte-identical kernels. The rewritten cast fuses at every width, and the unrewritten one declines with its reason. - `VarkaTimestampNtzSuite` (queries: fused plan, answers against the row engine, declined-batch metrics). The column form is served on the kernel at the bound in both modes. The add's overflow raises from the row engine, with the plan fused around it. Day -106,751,992 is answered by the row engine with only its batch declined. The date-pinning test runs `SELECT CAST(tm AS TIMESTAMP_NTZ), year(t)` over a view whose `t` is past the calendar guard in every other batch, so half the batches go to the row engine. Every row carries one date, today's in the session zone. The query runs under `Etc/GMT-14` and then `Etc/GMT+12`, which are 26 hours apart: the second run's kernel has the first's shape (the same shape-cache key, read from each plan's fused node) and answers its own date. - Coverage rows `make_timestamp_ntz(d, t)`, `make_timestamp_ntz(DATE'2021-06-01', t)` and `CAST(t AS TIMESTAMP_NTZ)`, each with its domain, run through the coverage, differential and harness suites (the ANSI form's taken and untaken `CASE` positions included). The literal row and the cast are listed as total domains in the harness's domain check, since only the last day whose midnight is a long can overflow the add, and neither date is that day. `VarkaCastMatrixSuite` now records `TIME` to `TIMESTAMP_NTZ` as fused in all three modes, and the `TIME` conformance suite holds those forms to Spark. The Catalyst grammar gains `make_timestamp_ntz` over a date literal. The NTZ fields baseline now lists all of its sections as fusing. - Catalyst: `VarkaTimestampNtzCastSuite`, `VarkaExpressionCompilerSuite`, `VarkaCastMatrixSuite`, `VarkaTypesSuite`, `VarkaCoverageSuite`, `VarkaEmittedBytesSuite`, every `*ConformanceSuite`, `VarkaFamilySwitchSuite`, `VarkaDivisorProofSuite`, `VarkaIrFuzzSuite`, `VarkaLaneTypeSuite`, `VarkaWithChildrenSuite`, `VarkaEmitCostSuite`: 356 passed, 0 failed, 22 canceled (the registers' owed forms). SQL (`-Phive`): `VarkaTimestampNtzSuite`, `VarkaTimestampNtzFieldsBaselineQueriesSuite`, `VarkaCoverageDifferentialSuite`, `VarkaDifferentialHarnessSuite`, `VarkaCoverageHarnessSuite`, `VarkaFamilySwitchQuerySuite`, `VarkaHarnessParitySuite`, `VarkaFarDaySuite`, `VarkaSparkFuzzSuite`: 2374 passed and 2 failed on the first run. The two failures were the total-domain listing, which is fixed. After the review fixes, the affected suites were rerun: catalyst 36 passed, 2 canceled; sql 2286 passed, 0 failed. - `dev/varka_census.py --check` passes. `dev/varka_precommit.sh` and `dev/varka_errorprone.sh` pass. No existing shape's emitted bytes move: `emitted_bytes.json` gains the new shapes, and its only changed lines are the `option_arms` digests, which aggregate every shape. No date value reaches a generated file. Review (one round, triaged). Fixed: the fuzzer's `CAST(t AS TIMESTAMP_NTZ)` production was dropped, because each of the fuzzer's two sessions reads its own current date, so a comparison that spans midnight would differ by a day (the literal form stays). Also fixed: a `var` whose right-hand side does not name its type, a duplicated emit sequence in the kernel suite, a parse helper written out twice (now `VarkaSqlResolve.parseAsWritten`), two stale comments and the import order. Trade-offs left as they are: - The coverage differential's `CAST(t AS TIMESTAMP_NTZ)` row compares two sessions that each read the clock, so a run that spans midnight in the session zone could differ on that row, as the baseline benchmark's rerun rule already allows for. - That row's `catalyst` column names `StaticInvoke`, the class the compiler is given after the rewrite, while its `casts` column records the cast as written. - Only a bare date literal skips the guard. A constant date of any other shape takes the guarded column path, which is correct and costs one range check per batch. - `VarkaSqlResolve.resolve` runs `ComputeCurrentTime` after its folding rules, unlike the optimizer, so some current-time shapes the tests resolve are not ones a session builds; aligning the order is left for a separate change. - `castsOf` resolves each coverage row a second time, before the rewrite, which adds a small amount of analyzer time per render of the table. Owed from the runners, not part of this pull request: step 6, the after-run of `VarkaTimestampNtzFieldsBaselineBenchmark` at 256 and 128 bits against the committed baseline. Added test time: three tests in `VarkaTimestampNtzSuite` (0.4 s together), three in `VarkaTimestampNtzCastSuite` (the whole suite, its own JVM, takes 12.8 s), and three coverage rows. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-5-5)
…e#1509) ### What changes were proposed in this pull request? This is a plan-only change to milestone 8's task table (`sql/varka/plans/m8/PLAN.md` section 3). I read every row whose state is not `Done` against the pull requests merged under its id and against its done-when. Eleven rows are closed, one is marked done in part, and two rows that lag merged work have their state text corrected. Only the state clause of each row changes. Merge dates are in CET. | row | old state -> new state | evidence | | ---: | :--- | :--- | | 554 | Started -> Done | apache#1312 merged 3 November. Its own Build was cancelled. The size step later failed the lint job of apache#1427's Build (run 42606922446) with "1357 counted lines ... at or over the cap of 1000" and the largest files. Passing changes print their count. That 1357 is the over-count row 588 later fixed, but it still shows the failure path. | | 558 | Started -> Done | apache#1320 merged 3 November. `varka_lint.py --selftest` passes in the Varka docs checks job, `ci-gates` included. The Build of the plan-only apache#1506 (run 43087405861) skipped both the protobuf job and the UI job. | | 559 | Started -> Done | apache#1329 merged 4 November. Every chain explains in under 2 ms at depth 20, with verdicts and bytes unchanged (`VARKA-559.md` 6, `results/VARKA-559-planning-cost.txt`). | | 569 | Started -> Done | apache#1367 merged 5 November. The hook refuses the wrong checkout and names the fix. `dev/varka_prepush.sh --selftest` is in the lint job and passes. | | 580 | Started -> Done | apache#1426 merged 9 November. The row was done when it merged. The grammar draws a narrow `BitCount` again (`VarkaIrGrammar` case 10). | | 581 | Started -> Done | apache#1416 merged 9 November. The first three Builds whose heads hold it passed catalyst shard 1 of 3: runs 42589018437, 42602246363 and 42602326887. No later run of that job failed through 03:00 UTC on 10 November. In their JUnit reports `VarkaWidthAuditSuite` spends 538 to 1099 s in `beforeAll`, and its longest test takes 1.0 s. | | 582 | Started -> Done | apache#1429 merged 9 November. The row's only open item was review and merge. `VarkaChildProcess` and `VarkaChildProcessSuite` are on master. | | 585 | Started -> Done | apache#1441 merged 10 November. The Build of its head `f017ecac0e8` (run 42699618930) passed all seven suites, according to its JUnit reports. The census suite's one skipped test is the host-census file check, not a child-JVM test. | | 588 | Started -> Done | apache#1471 merged 11 November. The lint job's other steps continue on error. apache#1427's merge commit is in master's history, so the self-test's pinned case counts 52 lines both in the docs-checks job's full clone and on the laptop. | | 589 | Started -> Done | apache#1465 merged 11 November. `notify_test_workflow.yml` is gone, and no `pull_request_target` sync has run since. apache#1506's `Build` check (check run 130755752876) was created while fork run 43087405861 was still running, and it completed with that run's success. | | 595 | Started -> Done | apache#1481 merged 11 November. `dev/varka_precommit.sh --selftest` passes. | | 594 | Started -> Done in part | apache#1463 merged 10 November. Its dry-run table passes every baseline but one at both widths, on AVX-512 and under `-XX:UseAVX=2` on the same laptop. Left: `VarkaBooleanOutputBenchmark`, which stops by design until row 27's step 6, and a dry run on a real AVX2 host. | | 340 | Started (text) | "built on branch" now reads "merged as apache#1397" for steps 2 to 4 and "merged as apache#1434" for step 5. The runner measurement is still owed. | | 414 | Started (text) | "built" now reads "built and merged as apache#1454". The fuse after the SPARK-61352 sync is still owed. | Rows left as they are: - 591: apache#1464 merged, and retry runs exist on vecbricks/varka, for example 43039739304. The post-merge check of `VARKA-591.md` 3 is not recorded on master, so this is unverified. - 572: this change does the reading that row 572 leaves open. The row can close once this change merges. - 414: its done-when is met by its "stays declined with the reason recorded" branch. The row still names the post-sync fuse as owed, so I left the state to the owner. - 27, 157, 332, 341 to 344, 347 to 349, 352, 359, 361, 363, 506 and 577: the type rows. Each one names steps or runner measurements that are still left, and merged work does not finish them. - 483, 490, 491, 493, 507, 508, 510, 512 to 517, 519 to 521, 523 to 530, 532, 533, 536, 538, 546, 555, 557, 563, 565 and 573: the harness rows. Each one's open item is a CI measurement, a matrix run or an owner decision, and master records none of them. For 565, the EPYC regeneration is still owed. For 573, a scheduled run (42355859989) is cited in row 330, but the row's own list of open items is longer. - Planned rows with only plan PRs merged, and every row with an open PR today (103, 104, 339, 342, 345, 360, 541, 578, 584, 592, 593, 596 to 598, 603, 606), were not changed. ### Why are the changes needed? The owner asked on 11 November 2026 for the rows whose work had finished to stop reading as Started. A count of the milestone reads these states. ### Does this PR introduce _any_ user-facing change? No. Only the plan changes. ### How was this patch tested? - `python3 dev/varka_plan_lint.py --check`, online so that the run-head pairing of row 585 is checked: 0 findings. - `python3 dev/varka_push_check.py`: passed (28 counted lines). - `varka_msg_check.py`, `varka_precommit.sh`, `varka_prepush.sh` and `varka_lint.py` self-tests: ok. - One `/code-review high` pass: found 10 / fixed 5 / left 5. Fixed: - row 588 wrongly said CI runs the apache#1427 case vacuously; - rows 558, 569 and 588 named the lint job for self-tests that run in the Varka docs checks job; - row 594 contradicted itself and did not say its AVX2 columns are emulated; - row 554 claimed "every Build since" without a source; - row 589 still named its branch. Left: - `VARKA-559.md` 9 still says "not opened". This change rewrites only the plan's state clauses. - Row 414 meets its done-when through the "stays declined" branch, but the row keeps the post-sync fuse as owed. That is the owner's call. - `varka_plan_lint.py` reads run heads from vecbricks/varka, so a fork Build citation such as row 585's can never be checked. That is a tool change, not a row change. - Row 585's skipped census test is the host-file check (see the table). - Row 595's "differs from both parents" rule is the reading of "what it adds over its first parent" that leaves out what master brings, which is the row's intent. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
… value (apache#1442) ### What changes were proposed in this pull request? Varka now compiles `timestampadd` over a `TIMESTAMP_NTZ` value, by every unit from a microsecond to a year, and a `TIMESTAMP_NTZ` value plus or minus a year-month interval, into its kernels. Spark used to evaluate these on its row path. `add_months(ntz, i)` fuses too. **Why the units up to a week are long arithmetic.** Spark reads an NTZ value at UTC, where every day has 86,400 seconds. So `timestampadd(unit, q, t)` (`DateTimeUtils.timestampAdd`) is `t + q * f`, with `f` the unit's microseconds. Spark raises `DATETIME_OVERFLOW` where the product or the sum leaves a long, in every mode. The kernel: - guards `q` to `+-floor(Long.MAX_VALUE / f)`, so a wrapping multiply is exact; - adds with the long lane's checked add, so a batch with an overflowing lane goes to the row engine, which raises Spark's error on the row. For MILLISECOND to HOUR the guard is exactly `multiplyExact`'s domain. For DAY and WEEK, Spark also narrows `q` to an int (and multiplies by seven in int for WEEK), but every `q` those raise on lies past the guard, so its batch goes to the row engine, which answers or raises. MICROSECOND needs no guard. An int quantity needs none up to an hour, since every int is inside the bound. A literal quantity folds to its product; at MICROSECOND there is no product, so every long literal fuses, `Long.MIN_VALUE` included, as every column value does. **Why the month forms are the date's `add_months`.** `ntz + ym`, `ntz - ym` and `timestampadd` by MONTH, QUARTER or YEAR are `LocalDateTime.plusMonths` at UTC: the date moves with its day-of-month clamp, and the time of day stays. The kernel takes the date as the floor division of the count by a day, under the date guard that the NTZ calendar fields already use. It moves the date with the existing `AddMonths` node and adds the change of day, times a day, back to the count. The count is held to the range the month arithmetic is exact over: `ntz +/- ym` takes the date forms' month count, and `timestampadd`'s quantity is guarded and scaled by 3 or 12 in int. Inside both bounds the sums cannot overflow. A batch with a value outside either bound goes to the row engine. One operand position changes: `AddMonths`' month count now takes a bigint narrowed to the int lane under a guard that declines a batch with a lane past the month range. That is the shape `timestampadd(MONTH, l, ntz)` builds, and only that shape. Its guard declines a batch rather than nulling a lane, so the narrowing is exact on every lane the guard passes, and `AddMonths` still guards the count's value at run time, as for any derived count. A cast's narrowing is not taken, since its guard spans the whole int range. So `timestampadd(MONTH, CAST(l AS INT), ntz)` declines in LEGACY, ANSI and TRY alike. QUARTER and YEAR over the same cast fuse, because their count is the cast int guarded to the month range and scaled, like an int column's. No IR node, lowering or emit option is new. **What still declines:** `timestampadd` by NANOSECOND or an unknown unit, a quantity past its guard when it is a literal, `timestampadd(MONTH, CAST(l AS INT), ntz)` in every mode, and a zoned `TIMESTAMP`. **What checks it:** - **`VarkaTimestampNtzArithmeticSuite`** holds the guarded product and the checked add to Spark's `timestampAdd` over the ends of the long range, at each unit's bound and one past. It also checks that MILLISECOND to HOUR always raise past the bound, and pins the trees and the declines. - **`VarkaTimestampNtzMonthSuite`**, new, holds the month composition to Spark's `timestampAddMonths` and to `LocalDateTime.plusMonths` over the days the date guard admits, for twelve counts at the month range's ends and around zero. It runs the emitted kernel over the same days and counts, and checks that a batch one microsecond past either end of the guard declines. At pull-request time it walks a sample of the days; `-Dvarka.sweep=true` walks every day. - **Mixed lanes.** `VarkaEmitterMixedLaneSuite` runs `AddMonths` over a narrowed long day by a narrowed, guarded bigint count, at two and eight long lanes and every null pattern. - **Coverage.** Seventeen rows in the NTZ arithmetic family and `add_months(ntz, i)` in the fields family, each with its domain. An int count of microseconds is under 36 minutes, and no fixture holds an NTZ value that close to the long's top, so the int row is SECOND's and MICROSECOND's row is over a bigint. The domain-edges fixture gains two rows near the long's top, beside the int's and the long's maximum, where the sums leave the long. The ANSI form lists `DATETIME_OVERFLOW` by its first row. The guarded rows join `add_months(d, i)` and `ntz + dt` on the list of rows not served at the right side of a false AND, for the reason those are listed. - **End to end.** `VarkaTimestampNtzSuite` runs every unit at its guard's ends on the kernel, and one past each end in a batch of its own, which the row engine answers or raises `DATETIME_OVERFLOW` on, in LEGACY and ANSI. It also runs the month forms at the date guard's ends and with a date one past, and the least month count negated. A bigint quantity cast to INT, by CAST and by `try_cast` and under LEGACY and ANSI, includes values past the int range: `2^32 + 1` and `-2^32 - 2`, whose low bits are small counts, and `Int.MaxValue + 1`. LEGACY wraps them, raising `DATETIME_OVERFLOW` only on `Int.MinValue`; ANSI raises `CAST_OVERFLOW`; TRY nulls them. Every case answers or raises as Spark does. MONTH is checked as declined, and QUARTER and YEAR as fused, with their kernels running. - **The Spark-level fuzzer.** Its grammar gains `timestampadd` by HOUR, DAY and MONTH and the year-month sums. A hostile year-month interval moves an NTZ value past the long, and Spark raises that as `Math`'s bare long overflow with no error condition, inside the job's failure. The fuzzer now names that overflow by its class, as the coverage harness already does, and `expected_errors.tsv` lists it and `DATETIME_OVERFLOW` for the family. **The baseline lists what this fuses.** In `VarkaTimestampNtzArithmeticBaselineBenchmark`, the month section and `timestampadd(HOUR, q, ntz)` are now listed as fusing at both null densities, so its queries suite checks them. **Generated files** are regenerated in the documented order: - `coverage.json` and `docs/sql-varka.md` add the rows and the families' new text; - `width_audit.json` adds them; - `emitted_bytes.json` adds the new shapes and moves only the option-arm digests; - `census.tsv` marks `ntz_plus_ym` and `timestampadd` fused for NTZ, and `datetime_sub` for its day-time interval. ### Why are the changes needed? A query that shifts a `TIMESTAMP_NTZ` column by `timestampadd`, or by a year-month interval, ran entirely on Spark's row path. Yet the arithmetic is a checked long add and the month shift of a date that Varka's kernels already have. ### Does this PR introduce _any_ user-facing change? Yes, for users who enable Varka: these NTZ expressions are now evaluated by Varka's vector kernels. The answers are unchanged, including Spark's errors on overflow. ### How was this patch tested? - On the laptop, through `dev/varka_matrix.sh`: - catalyst at the defaults: 16 suites, including every suite that lists node types (`VarkaIrFuzzSuite`, `VarkaLaneTypeSuite`, `VarkaWithChildrenSuite`, `VarkaEmitCostSuite`, `VarkaTypesSuite`, `VarkaEmittedBytesSuite`, `VarkaCoverageSuite`), `VarkaFamilyChainSuite`, the NTZ suites, the mixed-lane and calendar emitter suites and `VarkaRangeRulesSuite`. 388 tests passed and none failed; the 10 cancelled are opt-in sweeps and skips owed by other rows. - sql: `VarkaCoverageHarnessSuite`, `VarkaCoverageDifferentialSuite`, `VarkaDifferentialHarnessSuite`, `VarkaTimestampNtzSuite`, `VarkaSparkFuzzSuite` and both NTZ baseline queries suites. At the defaults, 2,406 tests passed. Under `lanesOverride=16`, 2,393 passed with 13 cancelled; under `validityByWidth=false`, 2,328 passed with 78 cancelled. Neither configuration needed a skip line. - Under `checkIntOverflow=false`, the checked add wraps where Spark raises. So `timestampadd` by MICROSECOND, SECOND and HOUR takes the skip lines `ntz + dt` already carries, in the harness, differential and NTZ suites. With those lines, the harness, differential and NTZ suites pass: 2,249 tests, 55 cancelled. The other four suites passed in the run before. - `dev/varka_scoped_suites.sh sql --shard 1/3`, the harness shard with the untaken-CASE-arm checks: 27 suites, 2,539 tests passed, 4 cancelled, none failed. - `dev/varka_census.py --check`, the quote check, `dev/varka_precommit.sh` and Error Prone are clean. `emitted_bytes.json` gains the new shapes, and only the 22 option-arm digests move. - **Added test time.** `VarkaTimestampNtzMonthSuite` takes 6.0 s in a matrix JVM. On a laptop JVM, that adds well under 1% to the "Run the Varka suites of catalyst" step, whose median in `step-budget.tsv` is 724 s. The new sql tests add about 7 s to the sql Varka suites: the NTZ suite's three new tests from the first round take 5.6 s and the new harness rows 1.3 s. - `VarkaTimestampNtzMonthSuite`'s sweep over the whole range (`-Dvarka.sweep=true`) is registered for the sweeps job and was not run here. At the kernel walk's rate it would take hours. - One review of the diff (`/code-review high`), then one triaged fix round: - (a) Bugs, fixed: the time family's `timestampadd` arm also claimed the month units, which only the chain's order kept from the calendar arm, so `VarkaFamilyChainSuite` would have found two claimants; and a bigint quantity off the long lane was dropped with no decline reason. - (b) Rule breaks, fixed: a constant split from its doc comment, a static field placed between methods, and `MONTH_COUNT` admitting any narrowing rather than one under a guard inside the int range. - (c) Trade-offs, left as they are: - The month forms build the date of an NTZ value from the same `floorDivLong` and `ntzDay` helpers as `CAST(ntz AS DATE)`, not through that cast's private method. Sharing it would make a larger edit to `VarkaNodeCompiler`, which apache#1434 is changing too. (The second round below opens `VarkaNodeCompiler.longOperand` to the package and touches nothing else there.) - The literal, guard and scale steps for the quantity are written once for each family, since their lanes and bounds differ. - A second review, one triaged fix round: - `MONTH_COUNT` now takes a narrowing only under a failing guard inside the month range, the shape `timestampadd` builds. Before the fix, a cast's narrowing under ANSI or TRY was also taken. A probe run of the new cast test against that wider rule found that `timestampadd(MONTH, CAST(l AS INT), ntz)` under ANSI and TRY answered as Spark does on its data. The rule was narrowed anyway: it now takes only the shape its comment justifies. QUARTER and YEAR over the same cast keep fusing. Their count is the cast int guarded to the month range and scaled, and the new test holds them to Spark in all three modes. - A MICROSECOND literal `Long.MIN_VALUE` used to decline, although no product is formed and the column path takes the same value. It now fuses (`VarkaTimestampNtzArithmeticSuite` pins the tree). - The quantity and the timestamp of `timestampadd` up to a week now decline with a reason when they are off the long lane. - A test name now states what it tests: a timestamp whose date is past the date guard, not a month count past it. - On the laptop, at the defaults with bare sbt: `VarkaTimestampNtzArithmeticSuite`, `VarkaTimestampNtzMonthSuite`, `VarkaEmitterMixedLaneSuite`, `VarkaCoverageSuite`, `VarkaExpressionCompilerSuite`, `VarkaGuardEdgeSuite`, `VarkaVariantSuite` and `VarkaEmitterChronoSuite` (302 passed, 6 cancelled), and `VarkaTimestampNtzSuite` with `VarkaSparkFuzzSuite` (44 passed). `dev/varka_push_check.py` passes. The new cast test takes 3.1 s. The option configurations were not run for the new tests. - **One wording choice.** The calendar family's switch text keeps the phrase "a year-month interval, and the". `VarkaRefinementFile` happens to share it, and the push check's quote rule (R2) would otherwise flag the change. - `VarkaSparkFuzzSuite` gains a test that runs `ntz + ym` past the long inside a task, on both engines. It checks that the fuzzer names the bare overflow by its class, not by the job's failure. - Known gap: row 579 (a calendar node over a guarded, narrowed long is not in the IR fuzzer's mixed draw) is exactly the month forms' shape. It stays that row's. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
No description provided.