-
Notifications
You must be signed in to change notification settings - Fork 29.4k
[SPARK-58814][SQL] Cover CHAR/VARCHAR round-trips and stop ORC truncating scans #58317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srielau
wants to merge
22
commits into
apache:master
Choose a base branch
from
srielau:SPARK-58814-format-roundtrips
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,082
−184
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
643441e
[SPARK-58814][SQL] Cover CHAR/VARCHAR round-trips and stop ORC trunca…
srielau 3f66711
[SPARK-58814][SQL] Fix ORC CHAR/VARCHAR row decoding and legacy enfor…
srielau b958ad5
[SPARK-58814][SQL] Bind ORC scans to analyzed CHAR/VARCHAR semantics
srielau d529bca
[SPARK-58814][SQL] Keep ORC CHAR/VARCHAR scan mode internal
srielau 81b5717
[SPARK-58814][SQL] Always bind first-class ORC scan semantics
srielau 1df5d7b
[SPARK-58814][SQL] Include CHAR/VARCHAR scan mode in plan identity
srielau b76ff09
[SPARK-58814][SQL] Invalidate V1 caches by BaseRelation and gate priv…
srielau 90a69e4
[SPARK-58814][SQL] Carry a typed CHAR/VARCHAR scan mode through a Fil…
srielau 96669e2
fix: [SPARK-58814] address cache and ORC review feedback
srielau bd2cc6f
fix: [SPARK-58814] close scan-mode cache gaps
srielau 4854ae0
fix: [SPARK-58814] retain mode-specific caches
srielau 069f3d2
fix: [SPARK-58814] satisfy cache test scalastyle
srielau cd20ef6
fix: [SPARK-58814] recache all CHAR/VARCHAR modes on refresh and micr…
srielau 3bd8d61
fix: [SPARK-58814] bind CHAR/VARCHAR scan mode only on first-class re…
srielau 65a2bb4
fix: [SPARK-58814] preserve mode-specific caches across rename
srielau 312f164
fix: [SPARK-58814] stabilize cache lifecycle follow-ups
srielau b8d27c0
[SPARK-58814][SQL] Preserve legacy and multi-mode caches
srielau 66461ef
Revert "[SPARK-58814][SQL] Preserve legacy and multi-mode caches"
srielau d161b01
[SPARK-58814][SQL] Fix V2 rename cache identity and bound recache tests
srielau 08dc28c
[SPARK-58814][SQL] Address remaining cache review feedback
srielau 85be94c
[SPARK-58814][SQL] Rebind temp-view CHAR padding and isolate cache re…
srielau de77ceb
[SPARK-58814][SQL] Fix temp-view rebinding and cache regressions
srielau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CharVarcharScanMode.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.catalyst.util | ||
|
|
||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
||
| /** | ||
| * The CHAR/VARCHAR scan mode bound to a relation (and its scan) during analysis. | ||
| * | ||
| * A relation carries `Option[CharVarcharScanMode]`: `None` means no mode was bound, including for | ||
| * a relation with no CHAR/VARCHAR columns. A `Some` value pins the mode so that `sameResult` | ||
| * comparisons and cache reuse keep the two variants distinct. | ||
| */ | ||
| private[sql] sealed trait CharVarcharScanMode | ||
|
|
||
| /** | ||
| * A scan builder that accepts the CHAR/VARCHAR mode captured during relation analysis. | ||
| * | ||
| * For example, if `SELECT c FROM t` is analyzed with standard semantics enabled, the relation | ||
| * binds [[CharVarcharScanMode.SparkStandard]] before the builder creates the physical scan. | ||
| */ | ||
| private[sql] trait SupportsCharVarcharScanMode { | ||
| def bindCharVarcharScanMode(mode: CharVarcharScanMode): Unit | ||
| } | ||
|
|
||
| private[sql] object CharVarcharScanMode { | ||
| /** | ||
| * Preserve the native, constrained CHAR/VARCHAR types of the source (e.g. native ORC | ||
| * padding/truncation). Corresponds to preserve-only semantics. | ||
| */ | ||
| case object PreserveNative extends CharVarcharScanMode | ||
|
|
||
| /** | ||
| * Request physical STRING from readers that honor this mode so Spark observes the original | ||
| * value and applies standard CHAR/VARCHAR length checks. Corresponds to standard semantics. | ||
| * Native Hive ORC with CONVERT_METASTORE_ORC=false does not implement this contract and still | ||
| * applies native CHAR/VARCHAR truncation. | ||
| */ | ||
| case object SparkStandard extends CharVarcharScanMode | ||
|
|
||
| /** | ||
| * Maps the boolean `spark.sql.charVarchar.standardSemantics.enabled` value to the typed mode. | ||
| */ | ||
| def apply(standardSemantics: Boolean): CharVarcharScanMode = | ||
| if (standardSemantics) SparkStandard else PreserveNative | ||
|
|
||
| /** | ||
| * Configures `conf` so analysis binds `mode` and generates the matching read-side Project. | ||
| */ | ||
| def configure(conf: SQLConf, mode: CharVarcharScanMode): Unit = mode match { | ||
| case SparkStandard => | ||
| conf.setConfString(SQLConf.CHAR_VARCHAR_STANDARD_SEMANTICS.key, "true") | ||
| case PreserveNative => | ||
| conf.setConfString(SQLConf.PRESERVE_CHAR_VARCHAR_TYPE_INFO.key, "true") | ||
| conf.setConfString(SQLConf.CHAR_VARCHAR_STANDARD_SEMANTICS.key, "false") | ||
| } | ||
|
|
||
| /** Parses a mode from its `toString` name; the inverse of [[CharVarcharScanMode.toString]]. */ | ||
| def fromName(name: String): CharVarcharScanMode = name match { | ||
| case "PreserveNative" => PreserveNative | ||
| case "SparkStandard" => SparkStandard | ||
| case other => throw new IllegalArgumentException(s"Unknown CharVarcharScanMode: $other") | ||
|
srielau marked this conversation as resolved.
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.