Skip to content

[SPARK-2410][SQL] Merging Hive Thrift/JDBC server (with Maven profile fix) - #1620

Closed
liancheng wants to merge 2 commits into
apache:masterfrom
liancheng:jdbc-with-maven-fix
Closed

liancheng wants to merge 2 commits into
apache:masterfrom
liancheng:jdbc-with-maven-fix

Conversation

@liancheng

Copy link
Copy Markdown
Contributor

JIRA issue: SPARK-2410

Another try for #1399 & #1600. Those two PR breaks Jenkins builds because we made a separate profile hive-thriftserver in sub-project assembly, but the hive-thriftserver module is defined outside the hive-thriftserver profile. Thus every time a pull request that doesn't touch SQL code will also execute test suites defined in hive-thriftserver, but tests fail because related .class files are not included in the assembly jar.

In the most recent commit, module hive-thriftserver is moved into its own profile to fix this problem. All previous commits are squashed for clarity.

Starts Hive Thrift server via spark-submit

Make HiveThriftServer2 play well with spark-submit

Starts spark-sql shell with spark-submit

Updated docs for Hive compatibility and Shark migration guide draft

Fixed minor issues in spark-sql and start-thriftserver.sh

Added missing license headers

Fixed more license header issues

Adapts test suites to spark-submit settings

Addressed all comments by @pwendell

Updated documents and build scripts for the newly added hive-thriftserver profile

Starts beeline with spark-submit

Fixed spark-submit application options handling logic

Any options in the application option list with the same option name
that SparkSubmitArguments recognizes (e.g., --help) are stolen by
SparkSubmit instead of passed to the application.

Fixed failed test suites

Disabled MIMA for hive-thriftserver

Reordered spark-submit options in spark-shell[.cmd]

All options behind primary resource are (and should be) recognized as
application options now.

Updated Spark SQL programming guide docs

Revert changes related to SPARK-2678, decided to move them to another PR

Uses random port for HiveThriftServer2 to avoid collision with parallel builds
@SparkQA

SparkQA commented Jul 28, 2014

Copy link
Copy Markdown

QA tests have started for PR 1620. This patch merges cleanly.
View progress: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/17287/consoleFull

@SparkQA

SparkQA commented Jul 28, 2014

Copy link
Copy Markdown

QA results for PR 1620:
- This patch PASSES unit tests.
- This patch merges cleanly
- This patch adds the following public classes (experimental):
class SparkSQLOperationManager(hiveContext: HiveContext) extends OperationManager with Logging {

For more information see test ouptut:
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/17287/consoleFull

@marmbrus

Copy link
Copy Markdown
Contributor

Hopefully third times a charm :)

Merged!

@liancheng

Copy link
Copy Markdown
Contributor Author

Hmm, didn't find related code in master, and this PR is still open, seems it's not successfully merged yet?

@marmbrus

Copy link
Copy Markdown
Contributor

https://git-wip-us.apache.org/repos/asf?p=spark.git;a=commit;h=a7a9d14479ea6421513a962ff0f45cb969368bab

GitHub is lagging... We filled a bug with infra.
On Jul 28, 2014 5:09 PM, "Cheng Lian" notifications@github.com wrote:

Hmm, didn't find related code in master, and this PR is still open, seems
it's not successfully merged yet?

—
Reply to this email directly or view it on GitHub
#1620 (comment).

@liancheng

Copy link
Copy Markdown
Contributor Author

Oh, really "lucky" these days :)

@asfgit asfgit closed this in a7a9d14 Jul 29, 2014
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
… fix)

JIRA issue: [SPARK-2410](https://issues.apache.org/jira/browse/SPARK-2410)

Another try for apache#1399 & apache#1600. Those two PR breaks Jenkins builds because we made a separate profile `hive-thriftserver` in sub-project `assembly`, but the `hive-thriftserver` module is defined outside the `hive-thriftserver` profile. Thus every time a pull request that doesn't touch SQL code will also execute test suites defined in `hive-thriftserver`, but tests fail because related .class files are not included in the assembly jar.

In the most recent commit, module `hive-thriftserver` is moved into its own profile to fix this problem. All previous commits are squashed for clarity.

Author: Cheng Lian <lian.cs.zju@gmail.com>

Closes apache#1620 from liancheng/jdbc-with-maven-fix and squashes the following commits:

629988e [Cheng Lian] Moved hive-thriftserver module definition into its own profile
ec3c7a7 [Cheng Lian] Cherry picked the Hive Thrift server
@liancheng
liancheng deleted the jdbc-with-maven-fix branch September 24, 2014 00:09
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 23, 2026
…apache#1626)

<!-- title: [VARKA-611] Add a magnitude pre-check for the checked BIGINT multiply -->
### What changes were proposed in this pull request?

An ANSI or TRY `BIGINT` multiply declines when the bounds of its operands do not rule out overflow. It then runs on the row engine.
This PR adds a pre-check in double lanes, behind an option that is off by default, so we can measure it against the decline on each host.

- New IR node `GuardedProduct(left, right)`. A batch declines (status `INT_OVERFLOW`) when a live lane has `|(double) a * (double) b| >= 2^62`. The row engine then raises or returns null on the rows that overflow.
- The test is safe: no overflowing row passes.
- New emit option `checkedLongMultiply`: `BOUND_ONLY` (default, today's decline), `MAGNITUDE`, `BY_HOST`.
- The fuzzer draws the node. The benchmark has a third arm and one new section.

<details>
<summary>Measured baseline, the node, the option and the other changes</summary>

Today, an ANSI or TRY `BIGINT` multiply declines when the bounds of its operands do not rule out overflow (`l * m` over two columns, `try_multiply(l, m)`). It runs on the row engine. Its wrapping twin fuses whole.
On the EPYC runner at 256 bits, the checked products tie the row path at 1.0X. In LEGACY, `l * 3` runs 6.6X and `l * m` runs 8.0X (`sql/core/benchmarks/VarkaBigintArithmeticBaselineBenchmark-jdk25-runner-epyc7763-results.txt`).

This PR adds the second of the three forms that `VARKA-104.md` 3.3 lists: a pre-check in double lanes. It is an option, off by default, so we can measure it against the decline on each host.

- New IR node `GuardedProduct(left, right)` on the long lane. Its value is the wrapping product `a * b`. A batch declines (status `INT_OVERFLOW`) when a live lane has `|(double) a * (double) b| >= 2^62`. The row engine then raises an error under ANSI, or returns null under TRY, on the rows that overflow.
- The kernel converts both operands to double (one `convertShape` at emit level 3, the exact `XOR_SPLIT` form below it), multiplies, clears the sign bit, and compares the bits as longs with the bits of `2^62`.
- The test is safe: a product that overflows a long is at least `2^63`, far past the bound plus the rounding error. So no overflowing row passes. A batch that declines but held no overflow is only answered by the row engine.
- The reference evaluator runs the same double test in Java, so the reference and the kernel decline the same batches.
- The node is not a mode of `IntArith`. An `IntArith(MUL, FAIL)` lowered this way would decline batches that its reference (`Math.multiplyExact`) answers.
- New emit option `checkedLongMultiply` (reason `MACHINE`): `BOUND_ONLY` (default, today's decline), `MAGNITUDE`, `BY_HOST`. `MAGNITUDE` builds a `GuardedProduct` in a projection where `cannotOverflow` fails, at an emit level that lowers the conversion (`DeclineSink.guardsLongProducts`). `BY_HOST` does this on x86 at levels 2 and 3 only, and keeps the decline elsewhere (Arm included, where it is not measured). A filter condition and the unnamed default level keep the decline. The node is refused at the unnamed level with the reason `CONVERSION`.
- Every exhaustive switch over the IR knows the new node.
- The fuzzer draws the node on its own seed (`GUARDED_PRODUCT_FUZZ_SEED`) at levels 2 and 3 in turn. It holds the status to `VarkaGuardSpecs` and an answered batch to the reference.
- `VarkaBigintArithmeticBaselineBenchmark` has a third arm, `varka on, B (checkedLongMultiply=MAGNITUDE)`, and one new section that prices the decline (`l * m, ANSI, products near 2^62`).

</details>

### Why are the changes needed?

Whether the pre-check beats the decline depends on the host.
The prediction, recorded before the run, is that it loses at 128 bits, and may win at AVX-512 and on the AVX2 of the EPYC at 256 bits.
We can choose a default for each host only from the readings of the runners.

<details>
<summary>More on the reason</summary>

Whether the pre-check beats the decline depends on the host.
The prediction, recorded before the run, is that it loses at 128 bits, and may win at AVX-512 and on the AVX2 of the EPYC at 256 bits (`VARKA-611.md` 6.1).
We can choose a default for each host only from the readings of the runners.
For the readings, the form must exist behind an option that changes nothing by default.
I built `BY_HOST` now so that one commit can name the winning levels later. It is not the default.

</details>

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

No.
The option is `BOUND_ONLY` by default, so every session compiles and answers as before. No session configuration sets it.

### How was this patch tested?

On the laptop (AVX-512, 256-bit datapath), on 22 November 2026, at the head after the merge of `origin/master`:

- Regeneration moved nothing. Push check, Error Prone, `lint-scala`, the catalyst suites and the sql queries suite (2 tests) passed. The queries suite first failed on its own expectation, not the node. I fixed the suite.
- After a later merge of `origin/master`, I ran only the push check again: 190 ok, 0 failed, 5 cancelled. I did not repeat the other runs.
- Not run: the benchmark on any host (the runners must read it), a CI Build, and the option matrix.
- Option matrix run 45158540579 failed `VarkaBigIntConformanceSuite` under `useAVX=2` with `checkedLongMultiply=MAGNITUDE` and `BY_HOST`: the registers describe the defaults, so the fused multiply read as drift. The check now asks the options, as the compiler does, and holds each batch to the pre-check's verdict; `dev/varka_matrix.sh` passes both configurations and the defaults (23 November 2026).

<details>
<summary>Full test record and the queries-suite failure</summary>

On the laptop (AVX-512, 256-bit datapath), one sbt at a time, `SPARK_LOCAL_IP=127.0.0.1`, on 22 November 2026, at the head of the branch after the merge of `origin/master`:

- `dev/varka_regen_generated.sh --all`: nothing moved.
- `python3 dev/varka_push_check.py` passed. Its matrix ran 13 suites with the defaults.
- `dev/varka_errorprone.sh` and `dev/lint-scala` passed.
- `build/sbt 'catalyst/testOnly *VarkaEmitCostSuite *VarkaEmitterBudgetSuite *VarkaEmitterLongLaneSuite *VarkaIrFuzzSuite *VarkaLaneTypeSuite *VarkaRangeAnalysisSuite *VarkaReproductionSuite *VarkaWithChildrenSuite'` passed. The fuzz suite runs the guarded draw at levels 2 and 3.
- `build/sbt 'sql/testOnly *VarkaBigintArithmeticBaselineQueriesSuite'` passed (2 tests).

After that, `origin/master` moved to `0378c696c3a` (apache#1618, apache#1620: a fix of the conjunct order rule, and a results-only commit). I merged it without conflict.
I ran only the push check again on that merge. It passed (13 suites, the defaults, 190 ok, 0 failed, 5 cancelled).
I did not repeat the other runs on it.

The queries suite first failed on the B arm of the benchmark.
`l * 3, ANSI, no nulls` planned `NONE`, and the suite expected `WHOLE`.
The cause was the expectation of the suite, not the node.
The shared test sessions pin `spark.sql.codegen.varka.emit.useAVX=-1`, the unnamed level. There, B declines by design, because the kernel plan refuses the long-to-double conversion.
The sessions of the benchmark use the named level of the host.
The suite now checks both. Under `MAGNITUDE` at the unnamed level, a section keeps its class (B declines like A). At level 2, the B arm plans `WHOLE` (`NONE` where the host declines two-lane checks).

Not run: the benchmark on any host (the runners must read it), a CI Build, and the option matrix.

</details>

### Review

`/code-review high`: 0 important findings. Five nits are left. Two are open limits: the benchmark results files are stale until the runner readings land, and the `BY_HOST` level set is provisional.

<details>
<summary>Earlier review and the nit list</summary>

`/code-review high` ran on 22 November 2026 on `varka-611-guarded-product-r` in `/home/max/proj/varka-611w` (merge base `96f7ff5402b`). It found no important defect.
An earlier `/code-review medium` found two defects. I fixed both:

- A misplaced brace in the constructor of `VarkaEmitOptions`.
- A `longValueExact` in the guard spec over operands whose wrapping value can leave the long range.

Five nits are left as they are:

- The `PLAN.md` status cell of row 611 still listed the decline section as left. Fixed on 23 November 2026.
- The results files of the benchmark are not regenerated for the two new columns and the third arm. The readings of the runners are owed, and the file is stale until they land.
- At the unnamed level, the refusal of `GuardedProduct` in the kernel plan only guards hand-built trees, because the compiler never builds one there.
- The level set of `BY_HOST` is provisional until the readings narrow it.
- The guarded fuzz draw runs level-3 kernels on AVX2 hosts through the Java fallback of the Vector API. This is correct but slow.

</details>

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

Generated-by: Claude Code (Claude Sonnet 5.5, Claude Opus 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