dtenedor commented on code in PR #60679:
URL: https://github.com/apache/spark/pull/60679#discussion_r4649101262
##########
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala:
##########
@@ -2063,6 +2065,106 @@ class InsertSuite extends DataSourceTest with
SharedSparkSession {
}
}
+ // Creates a table in `format` with two old rows, then adds columns whose
existence defaults
+ // have a NULL field, a NULL array element, a NULL nested struct or a
decimal whose unscaled
+ // value overflows a long, at the top level or in a struct and array (s, a,
n, ta, as, d, e, f,
+ // w); compact and wide decimals that fit in a long (i, l, c); and defaults
that contain a map
+ // and also a NULL or an overflowing decimal, which keep the old error: in
the map itself (m,
+ // md), in a map in a struct (sm), next to a map in a struct (sn, sw), and
next to a map in an
+ // array (am).
+ private def withNullFieldAndWideDecimalDefaults(format: String)(f: => Unit):
Unit = {
+ val wide = "99999999999999999999999999999999999999"
+ withSQLConf(
+ SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "true",
+ SQLConf.PARQUET_VECTORIZED_READER_NESTED_COLUMN_ENABLED.key -> "true",
+ SQLConf.ORC_VECTORIZED_READER_ENABLED.key -> "true",
+ SQLConf.ORC_VECTORIZED_READER_NESTED_COLUMN_ENABLED.key -> "true") {
+ withTable("t") {
+ sql(s"create table t(id int) using $format")
+ sql("insert into t values (1), (2)")
+ sql("alter table t add columns (" +
+ "s struct<tier: int, nickname: string> " +
+ "default named_struct('tier', 1, 'nickname', cast(null as string)),
" +
+ "a struct<tier: int, scores: array<int>> " +
+ "default named_struct('tier', 1, 'scores', array(1, null, 3)), " +
+ "n struct<x: int, inner: struct<y: int>> " +
+ "default named_struct('x', 1, 'inner', cast(null as struct<y:
int>)), " +
+ "ta array<int> default array(1, null, 3), " +
+ "as array<struct<x: int>> " +
Review Comment:
Renamed to `sa` in 01b0470b.
##########
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala:
##########
@@ -2063,6 +2065,106 @@ class InsertSuite extends DataSourceTest with
SharedSparkSession {
}
}
+ // Creates a table in `format` with two old rows, then adds columns whose
existence defaults
+ // have a NULL field, a NULL array element, a NULL nested struct or a
decimal whose unscaled
+ // value overflows a long, at the top level or in a struct and array (s, a,
n, ta, as, d, e, f,
+ // w); compact and wide decimals that fit in a long (i, l, c); and defaults
that contain a map
+ // and also a NULL or an overflowing decimal, which keep the old error: in
the map itself (m,
+ // md), in a map in a struct (sm), next to a map in a struct (sn, sw), and
next to a map in an
+ // array (am).
+ private def withNullFieldAndWideDecimalDefaults(format: String)(f: => Unit):
Unit = {
+ val wide = "99999999999999999999999999999999999999"
+ withSQLConf(
+ SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "true",
+ SQLConf.PARQUET_VECTORIZED_READER_NESTED_COLUMN_ENABLED.key -> "true",
+ SQLConf.ORC_VECTORIZED_READER_ENABLED.key -> "true",
+ SQLConf.ORC_VECTORIZED_READER_NESTED_COLUMN_ENABLED.key -> "true") {
+ withTable("t") {
+ sql(s"create table t(id int) using $format")
+ sql("insert into t values (1), (2)")
+ sql("alter table t add columns (" +
+ "s struct<tier: int, nickname: string> " +
+ "default named_struct('tier', 1, 'nickname', cast(null as string)),
" +
+ "a struct<tier: int, scores: array<int>> " +
+ "default named_struct('tier', 1, 'scores', array(1, null, 3)), " +
+ "n struct<x: int, inner: struct<y: int>> " +
+ "default named_struct('x', 1, 'inner', cast(null as struct<y:
int>)), " +
+ "ta array<int> default array(1, null, 3), " +
+ "as array<struct<x: int>> " +
+ "default array(named_struct('x', 1), cast(null as struct<x: int>)),
" +
+ s"d decimal(38, 0) default $wide, " +
+ "e decimal(19, 0) default -9999999999999999999, " +
+ "f decimal(38, 30) default 1.5, " +
+ "i decimal(9, 2) default 1.25, " +
+ "l decimal(18, 0) default 999999999999999999, " +
+ "c decimal(38, 10) default 123.5, " +
+ "w struct<v: decimal(38, 0), vs: array<decimal(38, 0)>> " +
+ s"default named_struct('v', $wide, 'vs', array($wide)), " +
+ "m map<string, int> default map('a', cast(null as int), 'b', 2), " +
+ s"md map<string, decimal(38, 0)> default map('a', $wide), " +
+ "sm struct<m: map<string, decimal(38, 0)>> " +
+ s"default named_struct('m', map('a', $wide)), " +
+ "sn struct<n: int, m: map<string, int>> " +
+ "default named_struct('n', cast(null as int), 'm', map('a', 1, 'b',
2)), " +
+ "sw struct<v: decimal(38, 0), m: map<string, int>> " +
+ s"default named_struct('v', $wide, 'm', map('a', 1, 'b', 2)), " +
+ "am array<map<string, int>> " +
+ "default array(map('a', 1, 'b', 2), cast(null as map<string,
int>)))")
+ f
+ }
+ }
+ }
+
+ test("vectorized readers fill existence defaults with NULL fields and wide
decimals") {
Review Comment:
Renamed to `SPARK-62034: vectorized readers fill existence defaults with
NULL fields, wide decimals, binary values and maps` in 01b0470b.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]