Skip to content

Commit 0d490b6

Browse files
aokolnychyihuangxiaopingRD
authored andcommitted
[SPARK-54436][SQL] Fix error formatting for incompatible table metadata checks
### What changes were proposed in this pull request? This PR fixes error formatting for recently added incompatible table metadata checks. ### Why are the changes needed? These changes are needed to avoid unnecessary empty lines. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing tests. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#53115 from aokolnychyi/spark-53924-54157-followup. Authored-by: Anton Okolnychyi <aokolnychyi@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 4aa94fb commit 0d490b6

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
21402140
errorClass = "INCOMPATIBLE_TABLE_CHANGE_AFTER_ANALYSIS.COLUMNS_MISMATCH",
21412141
messageParameters = Map(
21422142
"tableName" -> toSQLId(tableName),
2143-
"errors" -> errors.mkString("\n- ", "\n- ", "")))
2143+
"errors" -> errors.mkString("- ", "\n- ", "")))
21442144
}
21452145

21462146
def metadataColumnsChangedAfterAnalysis(
@@ -2150,7 +2150,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
21502150
errorClass = "INCOMPATIBLE_TABLE_CHANGE_AFTER_ANALYSIS.METADATA_COLUMNS_MISMATCH",
21512151
messageParameters = Map(
21522152
"tableName" -> toSQLId(tableName),
2153-
"errors" -> errors.mkString("\n- ", "\n- ", "")))
2153+
"errors" -> errors.mkString("- ", "\n- ", "")))
21542154
}
21552155

21562156
def numberOfPartitionsNotAllowedWithUnspecifiedDistributionError(): Throwable = {
@@ -4477,7 +4477,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
44774477
"viewName" -> toSQLId(viewName),
44784478
"tableName" -> toSQLId(tableName),
44794479
"colType" -> "data",
4480-
"errors" -> errors.mkString("\n- ", "\n- ", "")))
4480+
"errors" -> errors.mkString("- ", "\n- ", "")))
44814481
}
44824482

44834483
def metadataColumnsChangedAfterViewWithPlanCreation(
@@ -4490,6 +4490,6 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
44904490
"viewName" -> toSQLId(viewName),
44914491
"tableName" -> toSQLId(tableName),
44924492
"colType" -> "metadata",
4493-
"errors" -> errors.mkString("\n- ", "\n- ", "")))
4493+
"errors" -> errors.mkString("- ", "\n- ", "")))
44944494
}
44954495
}

sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ class DataSourceV2DataFrameSuite
11171117
condition = "INCOMPATIBLE_TABLE_CHANGE_AFTER_ANALYSIS.COLUMNS_MISMATCH",
11181118
parameters = Map(
11191119
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
1120-
"errors" -> "\n- `extra` STRING has been removed"))
1120+
"errors" -> "- `extra` STRING has been removed"))
11211121
}
11221122
}
11231123

@@ -1141,8 +1141,7 @@ class DataSourceV2DataFrameSuite
11411141
parameters = Map(
11421142
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
11431143
"errors" ->
1144-
"""
1145-
|- `new_col1` INT has been added
1144+
"""- `new_col1` INT has been added
11461145
|- `new_col2` INT has been added""".stripMargin))
11471146
}
11481147
}
@@ -1167,8 +1166,7 @@ class DataSourceV2DataFrameSuite
11671166
parameters = Map(
11681167
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
11691168
"errors" ->
1170-
"""
1171-
|- `col4` STRING has been removed
1169+
"""- `col4` STRING has been removed
11721170
|- `col5` INT has been added""".stripMargin))
11731171
}
11741172
}
@@ -1195,9 +1193,7 @@ class DataSourceV2DataFrameSuite
11951193
"viewName" -> "`v`",
11961194
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
11971195
"colType" -> "data",
1198-
"errors" ->
1199-
"""
1200-
|- `extra` INT has been added""".stripMargin))
1196+
"errors" -> "- `extra` INT has been added"))
12011197
}
12021198
}
12031199

@@ -1220,7 +1216,7 @@ class DataSourceV2DataFrameSuite
12201216
parameters = Map(
12211217
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
12221218
"errors" ->
1223-
("\n- `person` type has changed from STRUCT<name: STRING, age: INT> " +
1219+
("- `person` type has changed from STRUCT<name: STRING, age: INT> " +
12241220
"to STRUCT<name: STRING, age: INT, city: STRING>")))
12251221
}
12261222
}
@@ -1270,7 +1266,7 @@ class DataSourceV2DataFrameSuite
12701266
condition = "INCOMPATIBLE_TABLE_CHANGE_AFTER_ANALYSIS.COLUMNS_MISMATCH",
12711267
parameters = Map(
12721268
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
1273-
"errors" -> "\n- `extra` STRING has been added"))
1269+
"errors" -> "- `extra` STRING has been added"))
12741270

12751271
// DataFrame execution before joins must have pinned used versions
12761272
// subsequent version refreshes must not be visible in original DataFrames
@@ -1400,7 +1396,7 @@ class DataSourceV2DataFrameSuite
14001396
"viewName" -> "`v`",
14011397
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
14021398
"colType" -> "data",
1403-
"errors" -> "\n- `age` INT has been added"))
1399+
"errors" -> "- `age` INT has been added"))
14041400
}
14051401
}
14061402

@@ -1424,7 +1420,7 @@ class DataSourceV2DataFrameSuite
14241420
"viewName" -> "`v`",
14251421
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
14261422
"colType" -> "data",
1427-
"errors" -> "\n- `age` INT has been removed"))
1423+
"errors" -> "- `age` INT has been removed"))
14281424
}
14291425
}
14301426

@@ -1448,7 +1444,7 @@ class DataSourceV2DataFrameSuite
14481444
"viewName" -> "`v`",
14491445
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
14501446
"colType" -> "data",
1451-
"errors" -> "\n- `data` type has changed from STRING NOT NULL to STRING"))
1447+
"errors" -> "- `data` type has changed from STRING NOT NULL to STRING"))
14521448
}
14531449
}
14541450

@@ -1537,7 +1533,7 @@ class DataSourceV2DataFrameSuite
15371533
"viewName" -> "`v`",
15381534
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
15391535
"colType" -> "data",
1540-
"errors" -> "\n- `age` INT has been added"))
1536+
"errors" -> "- `age` INT has been added"))
15411537
}
15421538
}
15431539

@@ -1566,7 +1562,7 @@ class DataSourceV2DataFrameSuite
15661562
"viewName" -> "`v`",
15671563
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
15681564
"colType" -> "data",
1569-
"errors" -> "\n- `age` INT has been added"))
1565+
"errors" -> "- `age` INT has been added"))
15701566
}
15711567
}
15721568
}
@@ -1591,7 +1587,7 @@ class DataSourceV2DataFrameSuite
15911587
"viewName" -> "`v`",
15921588
"tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
15931589
"colType" -> "data",
1594-
"errors" -> "\n- `name` type has changed from VARCHAR(10) to VARCHAR(20)"))
1590+
"errors" -> "- `name` type has changed from VARCHAR(10) to VARCHAR(20)"))
15951591
}
15961592
}
15971593

0 commit comments

Comments
 (0)