Skip to content

Commit 9fd1e94

Browse files
committed
Rename to DecodeNestedZ85EncodedVariantSuite
1 parent 58ecd1a commit 9fd1e94

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

spark/src/main/scala/org/apache/spark/sql/delta/expressions/ReplaceVariantZ85WithVariantVal.scala renamed to spark/src/main/scala/org/apache/spark/sql/delta/expressions/DecodeNestedZ85EncodedVariantSuite.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ import org.apache.spark.unsafe.types.VariantVal
3535
*
3636
* @param child The expression producing the row with Z85-encoded variants
3737
*/
38-
case class ReplaceVariantZ85WithVariantVal(child: Expression)
38+
case class DecodeNestedZ85EncodedVariant(child: Expression)
3939
extends UnaryExpression with CodegenFallback {
4040

4141
override def dataType: DataType = child.dataType
4242

4343
override def nullable: Boolean = child.nullable
4444

4545
override def checkInputDataTypes(): TypeCheckResult = {
46-
if (!isValidType(child.dataType)) {
46+
if (!child.dataType.isInstanceOf[StructType]) {
47+
TypeCheckResult.TypeCheckFailure(s"The top-level data type for the input to " +
48+
s"DecodeNestedZ85EncodedVariant must be StructType but this is not true " +
49+
s"in: ${child.dataType}.")
50+
} else if (!isValidType(child.dataType)) {
4751
TypeCheckResult.TypeCheckFailure(
48-
s"ReplaceVariantZ85WithVariantVal does not support arrays or maps in schema. " +
52+
s"DecodeNestedZ85EncodedVariant does not support arrays or maps in schema. " +
4953
s"Found: ${child.dataType}")
5054
} else {
5155
TypeCheckResult.TypeCheckSuccess
@@ -100,5 +104,5 @@ case class ReplaceVariantZ85WithVariantVal(child: Expression)
100104
override def prettyName: String = "replace_variant_z85_with_variant_val"
101105

102106
override protected def withNewChildInternal(newChild: Expression)
103-
: ReplaceVariantZ85WithVariantVal = copy(child = newChild)
107+
: DecodeNestedZ85EncodedVariant = copy(child = newChild)
104108
}

spark/src/main/scala/org/apache/spark/sql/delta/stats/DataSkippingReader.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.apache.spark.sql.delta.skipping.clustering.{ClusteredTableUtils, Clus
2525
import org.apache.spark.sql.delta.{DeltaColumnMapping, DeltaLog, DeltaTableUtils}
2626
import org.apache.spark.sql.delta.ClassicColumnConversions._
2727
import org.apache.spark.sql.delta.actions.{AddFile, Metadata}
28-
import org.apache.spark.sql.delta.expressions.ReplaceVariantZ85WithVariantVal
28+
import org.apache.spark.sql.delta.expressions.DecodeNestedZ85EncodedVariant
2929
import org.apache.spark.sql.delta.implicits._
3030
import org.apache.spark.sql.delta.metering.DeltaLogging
3131
import org.apache.spark.sql.delta.schema.SchemaUtils
@@ -268,7 +268,7 @@ trait DataSkippingReaderBase
268268
/** Returns a DataFrame expression to obtain a list of files with parsed statistics. */
269269
private def withStatsInternal0: DataFrame = {
270270
val parsedStats = from_json(col("stats"), statsSchema)
271-
val decodedStats = Column(ReplaceVariantZ85WithVariantVal(parsedStats.expr))
271+
val decodedStats = Column(DecodeNestedZ85EncodedVariant(parsedStats.expr))
272272
allFiles.withColumn("stats", decodedStats)
273273
}
274274

spark/src/test/scala/org/apache/spark/sql/delta/expressions/ReplaceVariantZ85WithVariantValSuite.scala renamed to spark/src/test/scala/org/apache/spark/sql/delta/expressions/DecodeNestedZ85EncodedVariantSuite.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.apache.spark.sql.types.{IntegerType, LongType, StringType, StructFiel
2828
import org.apache.spark.types.variant.Variant
2929
import org.apache.spark.unsafe.types.{UTF8String, VariantVal}
3030

31-
class ReplaceVariantZ85WithVariantValSuite extends QueryTest with DeltaSQLCommandTest {
31+
class DecodeNestedZ85EncodedVariantSuite extends QueryTest with DeltaSQLCommandTest {
3232

3333
test("RoundTrip alternateVariantEncoding Z85") {
3434
val jsonValues = Seq(
@@ -53,10 +53,10 @@ class ReplaceVariantZ85WithVariantValSuite extends QueryTest with DeltaSQLComman
5353
val statsSchema = StructType(Seq(StructField("v", VariantType)))
5454
val parsedDf = df.withColumn("parsed", from_json(col("z85_string"), statsSchema))
5555

56-
// Apply ReplaceVariantZ85WithVariantVal
56+
// Apply DecodeNestedZ85EncodedVariant
5757
val decodedDf = parsedDf.withColumn(
5858
"decoded",
59-
Column(ReplaceVariantZ85WithVariantVal(col("parsed").expr))
59+
Column(DecodeNestedZ85EncodedVariant(col("parsed").expr))
6060
)
6161

6262
// Extract the decoded variant and verify
@@ -109,7 +109,7 @@ class ReplaceVariantZ85WithVariantValSuite extends QueryTest with DeltaSQLComman
109109
val parsedDf = df.withColumn("parsed", from_json(col("stats"), statsSchema))
110110
val decodedDf = parsedDf.withColumn(
111111
"decoded",
112-
Column(ReplaceVariantZ85WithVariantVal(col("parsed").expr))
112+
Column(DecodeNestedZ85EncodedVariant(col("parsed").expr))
113113
)
114114

115115
val result = decodedDf.select(

0 commit comments

Comments
 (0)