Skip to content

[GLUTEN-12863][TEST] Record six reason-less test exclusions, and port the cast from timestamp II rewrite to Spark 3.4/3.5 - #12888

Closed
LuciferYang wants to merge 10 commits into
apache:mainfrom
LuciferYang:spark33-drop-p06-settings-hygiene
Closed

[GLUTEN-12863][TEST] Record six reason-less test exclusions, and port the cast from timestamp II rewrite to Spark 3.4/3.5#12888
LuciferYang wants to merge 10 commits into
apache:mainfrom
LuciferYang:spark33-drop-p06-settings-hygiene

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Six .exclude(...) entries across the Velox and ClickHouse test settings carried no comment saying what fails. This writes down all six reasons, and one of them turned out to be a real coverage gap on Spark 3.4 and 3.5. No production code.

module change
spark34, spark35 a testGluten("cast from timestamp II") rewrite; comments in the Velox settings; a paired exclusion in the ClickHouse settings
spark35 reasons for four ClickHouse exclusions, from a CI run
spark40, spark41 comments in the Velox settings; two claims dropped from the rewrite they already had

Spark 3.4.4 and 3.5.5 both assert six values in cast from timestamp II, the four NaN/Infinity ones plus Long.MaxValue and Long.MinValue. Spark 3.4.0 only had the four, which is why the exclusion predates the extra assertions. 4.0 and 4.1 carry a testGluten("cast from timestamp II") rewrite in GlutenCastWithAnsiOffSuite that keeps five of the six and says why the sixth is dropped: glutenCheckExpression uses collect(), which goes through toJavaTimestamp and rebaseGregorianToJulianMicros, and Long.MinValue microseconds overflows there.

3.4 and 3.5 have the bare exclusion and no rewrite, so on those two versions the other five assertions run nowhere. This ports the 4.0 rewrite to their GlutenCastSuite, which is safe because both wrappers extend the same parent, CastWithAnsiOffSuite. All four modules also get a comment above the vanilla exclusion so the pair is visible from the settings file.

Because the wrapper file is shared by both backends and testGluten registration is not backend-conditional, adding the rewrite would also have started running it under ClickHouse, which has never validated this case. The ClickHouse settings get the matching exclusion that the neighbouring data type casting entry already uses: .excludeCH("Gluten - cast from timestamp II") on spark35 and .excludeGlutenTest("cast from timestamp II") on spark34. Only the spark35 one has any effect, since backends-clickhouse/pom.xml has profiles for 3.3 and 3.5 only; the spark34 line is there to keep the two files the same shape.

The other Velox entry, Stop task set if FileAlreadyExistsException was thrown, is excluded in all four modules with nothing said about why; the comment on the line above it, the native write staing dir is differnt with vanilla Spark for coustom partition paths, belongs to the SPARK-35106 entry between them. I removed the exclusion locally and ran GlutenInsertSuite against Spark 3.4.4 with Velox. 70 of 71 cases pass; this one fails:

- Stop task set if FileAlreadyExistsException was thrown *** FAILED ***
  Expected exception org.apache.spark.SparkException to be thrown,
  but org.apache.hadoop.fs.FileAlreadyExistsException was thrown (InsertSuite.scala:2035)

The case installs a FileSystem that throws FileAlreadyExistsException on create and expects Spark's write path to wrap it. Gluten surfaces the raw Hadoop exception instead, and the new comment records only that. Gluten's native write does have its own task-failure handling: VeloxColumnarWriteFilesExec.scala mirrors both branches of FileFormatWriter, so where the raw exception escapes is not something I established, and the comment does not guess at it.

The four ClickHouse entries came from #12889, now folded in here since it was the same activity on a file this PR already touches. tanh, cast from array II, cast from array III and cast from struct III are excluded on ClickHouse 3.5 with no reason recorded, and all four run on ClickHouse 3.3, so they would have lost their only run site when gluten-ut/spark33 goes away under #12807. That made it worth removing all four and letting the ClickHouse CI answer whether the exclusions were stale. It failed all four:

- tanh *** FAILED ***
  Incorrect evaluation: TANH(-0.1), actual: -0.0996695958408681, expected: -0.09966799462495582
- cast from array II *** FAILED ***
  Exception evaluating try_cast([123,true,f] as array<boolean>)
- cast from array III *** FAILED ***
  Incorrect evaluation: try_cast([2.147483648E9] as array<int>),
  actual: ArraySeq(-2147483648), expected: [Lscala.runtime.Null$;@73684390
- cast from struct III *** FAILED ***
  Incorrect evaluation: try_cast([2.147483648E9] as struct<a:int>),
  actual: [-2147483648], expected: [null]

So those exclusions stay and only their reasons were missing. The two array/struct cases are one behaviour, TRY-mode overflow inside a complex type wrapping instead of yielding null; tanh differs at the sixth significant digit; cast from array II throws rather than returning null. Whether ClickHouse should be changed to match is out of scope here.

Two claims came out of the rewrite's own comments while addressing review, in all four modules rather than only the two this patch adds. Velox computes correctly; only the collect path fails is not something this repository can show, so the comment now stops at the mechanism it can. The same explanation also appeared twice, once above the test and once inside it; the inner one is now a pointer. And the exclude comment no longer names the version it was reproduced on, since the identical text sits in the 4.0 and 4.1 settings where no such run was done.

One adjacent thing left alone: the GlutenTryCastSuite block in all four modules excludes cast from timestamp II with // Rewrite test for Gluten not supported with ANSI mode, but no testGluten("cast from timestamp II") exists in that suite's wrapper, so that comment points at a rewrite that is not there. It predates this change, and its real reason is unverified, so replacing one unsupported sentence with another would not help. It needs the exclusion removed and the suite run on 3.4 to settle, which is a separate change.

test-compile and spotless:check pass on -Pspark-3.4, -Pspark-3.5 -Pscala-2.13, -Pspark-4.0 -Pscala-2.13 and -Pspark-4.1 -Pscala-2.13. The five re-enabled assertions on 3.4/3.5 are for CI to confirm; the GlutenInsertSuite run above is on this machine, which is not authoritative for a pass but is enough to read a deterministic exception-type mismatch.

Found while auditing the excludes that have no stated reason, in preparation for removing gluten-ut/spark33 under #12807. Related: #12863, #12886, #12889.

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

Generated-by: Claude claude-opus-5

Copilot AI lite review requested due to automatic review settings August 25, 2026 07:45
@github-actions github-actions Bot added the CORE works for Gluten Core label Aug 25, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents two previously unexplained VeloxTestSettings.exclude(...) entries and restores partial coverage for "cast from timestamp II" on Spark 3.4/3.5 by porting the existing Spark 4.0/4.1 Gluten-specific rewrite (skipping the known Long.MinValue overflow on the collect()/timestamp conversion path). No production code is changed.

Changes:

  • Add explicit rationale comments for excluding "cast from timestamp II" and "Stop task set if FileAlreadyExistsException was thrown" across Spark 3.4–4.1 Velox settings.
  • Add testGluten("cast from timestamp II") in Spark 3.4 and 3.5 GlutenCastSuite, mirroring the Spark 4.x rewrite and intentionally skipping Long.MinValue.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala Adds missing explanations for two excludes in Spark 4.1 Velox test settings.
gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala Adds missing explanations for two excludes in Spark 4.0 Velox test settings.
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/catalyst/expressions/GlutenCastSuite.scala Re-enables most assertions for "cast from timestamp II" via a Gluten rewrite that skips Long.MinValue.
gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala Documents why "cast from timestamp II" and the FileAlreadyExistsException case remain excluded in the vanilla suite.
gluten-ut/spark34/src/test/scala/org/apache/spark/sql/catalyst/expressions/GlutenCastSuite.scala Re-enables most assertions for "cast from timestamp II" via a Gluten rewrite that skips Long.MinValue.
gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala Documents why "cast from timestamp II" and the FileAlreadyExistsException case remain excluded in the vanilla suite.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@LuciferYang LuciferYang changed the title [GLUTEN-12863][VL][TEST] Document two unexplained GlutenInsertSuite/GlutenCastSuite excludes [GLUTEN-12863][VL][TEST] Port the cast from timestamp II rewrite to Spark 3.4/3.5 and record two exclude reasons Aug 25, 2026
…op an unsupported claim from the exclude comment
Copilot AI review requested due to automatic review settings August 25, 2026 09:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

// the native write staing dir is differnt with vanilla Spark for coustom partition paths
.exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
// The case expects a SparkException; Gluten surfaces the raw
// FileAlreadyExistsException instead. Reproduced on Spark 3.4.4.
// the native write staing dir is differnt with vanilla Spark for coustom partition paths
.exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
// The case expects a SparkException; Gluten surfaces the raw
// FileAlreadyExistsException instead. Reproduced on Spark 3.4.4.
Comment on lines +173 to +181
// during rebase. Velox computes correctly; only the collect path fails. Skip Long.MinValue.
testGluten("cast from timestamp II") {
checkEvaluation(cast(Double.NaN, TimestampType), null)
checkEvaluation(cast(1.0 / 0.0, TimestampType), null)
checkEvaluation(cast(Float.NaN, TimestampType), null)
checkEvaluation(cast(1.0f / 0.0f, TimestampType), null)
checkEvaluation(cast(Literal(Long.MaxValue), TimestampType), Long.MaxValue)
// Skip Long.MinValue: Velox result is correct but collect() path overflows in
// rebaseGregorianToJulianMicros when converting extreme timestamp to java.sql.Timestamp.
Copilot AI review requested due to automatic review settings August 25, 2026 09:23
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

// the native write staing dir is differnt with vanilla Spark for coustom partition paths
.exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
// The case expects a SparkException; Gluten surfaces the raw
// FileAlreadyExistsException instead. Reproduced on Spark 3.4.4.
.excludeCH("SPARK-33291: Cast struct with null elements to string")
.excludeCH("SPARK-35111: Cast string to year-month interval")
.excludeCH("Gluten - data type casting")
// Gluten rewrite of the vanilla case excluded below; not vetted on ClickHouse.
Copilot AI review requested due to automatic review settings August 25, 2026 09:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

.excludeCH("SPARK-35111: Cast string to year-month interval")
.excludeCH("Gluten - data type casting")
// Gluten rewrite of the vanilla case excluded below; not vetted on ClickHouse.
.excludeCH("Gluten - cast from timestamp II")
Comment on lines +171 to +173
// Gluten's glutenCheckExpression uses collect(), which triggers
// toJavaTimestamp -> rebaseGregorianToJulianMicros. Long.MinValue micros (~292000 BC) overflows
// during rebase, so the vanilla case's Long.MinValue assertion is dropped here.
.exclude("data type casting")
// Revised by setting timezone through config and commented unsupported cases.
.exclude("cast string to timestamp")
// Rewritten in GlutenCastWithAnsiOffSuite without Long.MinValue, which overflows on the collect path.
Copilot AI review requested due to automatic review settings August 25, 2026 09:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI review requested due to automatic review settings August 25, 2026 10:45
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thanks, five rounds of this got the comments into decent shape. What I took and what I did not:

Taken. The version stamp is gone from the Stop task set if FileAlreadyExistsException was thrown comment: the same text sits in the 4.0 and 4.1 settings where no such run was done, so naming 3.4.4 there was misleading. The reproduction detail lives in the PR description instead. Velox computes correctly; only the collect path fails is gone too, from all four modules rather than just the two this patch adds, since this patch is what would have spread it from one file to three; the comment now stops at the mechanism the repo can show. The duplicate copy of that explanation inside the test body is now a pointer. The rewrite-pair comment leads with the reason for the exclusion and names the path, so the settings file reads on its own: Excluded in favour of the GlutenCastSuite rewrite, which drops the Long.MinValue assertion: collect() -> toJavaTimestamp -> rebaseGregorianToJulianMicros overflows. And the ClickHouse comment no longer depends on where the vanilla exclusion sits in the block.

Not taken, with reasons.

Re-adding the nuance that the failure is in the harness rather than in the Velox cast: that is the claim an earlier comment in this same review series asked me to remove, and rightly. The comment already names toJavaTimestamp -> rebaseGregorianToJulianMicros, which is the harness path. What is missing is the conclusion "so the Velox result is correct", and nothing in the tree supports it, least of all this rewrite, which is defined by not asserting Long.MinValue. Establishing it needs an assertion that checks the cast result without going through collect(), and I did not find a helper for that.

Extracting the rewrite body into a shared helper: per-module duplication is what this repo does for rewrites. gluten-ut/common contains no testGluten bodies at all, and the closest precedent, testGluten("cast string to timestamp"), is copied into twelve wrapper files across the five modules. The four wrappers also extend differently named parents per Spark version. Consolidating them is worth doing, but as its own change rather than inside a comment cleanup.

One correction on a stale comment: Reproduced on Spark 3.4.4 was flagged again at gluten-ut/spark40/.../VeloxTestSettings.scala:870 seventeen seconds after I had pushed its removal, so that one was already fixed.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 25, 2026 11:08
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@LuciferYang LuciferYang changed the title [GLUTEN-12863][VL][TEST] Port the cast from timestamp II rewrite to Spark 3.4/3.5 and record two exclude reasons [GLUTEN-12863][TEST] Record six reason-less test exclusions, and port the cast from timestamp II rewrite to Spark 3.4/3.5 Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings August 25, 2026 12:24
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (4)

Previously missed (4) — in code that hasn't changed since the last review.

gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala:852

  • Fix spelling/grammar in this nearby comment (staging/different/custom; "differs from"), since it sits in the same updated hunk and is easy to correct while touching this block.
    // the native write staing dir is differnt with vanilla Spark for coustom partition paths
    .exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
    // The case expects a SparkException; Gluten surfaces the raw
    // FileAlreadyExistsException instead.

gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala:871

  • Fix spelling/grammar in this nearby comment (staging/different/custom; "differs from"), since it sits in the same updated hunk and is easy to correct while touching this block.
    // the native write staing dir is differnt with vanilla Spark for coustom partition paths
    .exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
    // The case expects a SparkException; Gluten surfaces the raw
    // FileAlreadyExistsException instead.

gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala:601

  • Fix spelling/grammar in this nearby comment (staging/different/custom; "differs from"), since it sits in the same updated hunk and is easy to correct while touching this block.
    // the native write staing dir is differnt with vanilla Spark for coustom partition paths
    .exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
    // The case expects a SparkException; Gluten surfaces the raw
    // FileAlreadyExistsException instead.

gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala:641

  • Fix spelling/grammar in this nearby comment (staging/different/custom; "differs from"), since it sits in the same updated hunk and is easy to correct while touching this block.
    // the native write staing dir is differnt with vanilla Spark for coustom partition paths
    .exclude("SPARK-35106: Throw exception when rename custom partition paths returns false")
    // The case expects a SparkException; Gluten surfaces the raw
    // FileAlreadyExistsException instead.

Copilot AI review requested due to automatic review settings August 25, 2026 12:41
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

.excludeCH("Gluten - data type casting")
// The Gluten rewrite of "cast from timestamp II" is not vetted on ClickHouse;
// the vanilla case is excluded separately in this block.
.excludeCH("Gluten - cast from timestamp II")
Copilot AI review requested due to automatic review settings August 25, 2026 13:05
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants