Skip to content

Commit f54433a

Browse files
deepujainuros-b
authored andcommitted
[SPARK-43940][SQL] Test the error class: BATCH_METADATA_NOT_FOUND
### Summary Adds coverage for the missing batch metadata error path. ### Change `HDFSMetadataLog.applyFnToBatchByStream` now has a focused test that checks `BATCH_METADATA_NOT_FOUND`, the missing batch file parameter, and SQLSTATE `42K03`. ### Tests `JAVA_HOME=/opt/homebrew/opt/openjdk17 PATH="/opt/homebrew/opt/openjdk17/bin:$PATH" ./build/sbt "sql/testOnly org.apache.spark.sql.errors.QueryExecutionErrorsSuite -- -z SPARK-43940"` Fixes SPARK-43940 **JIRA assignee for credit:** deepujain Closes #57926 from deepujain/SPARK-43940-cannot-find-batch-test. Authored-by: Deepak Jain (DJ) <deepujain@gmail.com> Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
1 parent 6f4a41e commit f54433a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ import org.apache.spark.sql.execution.datasources.jdbc.connection.ConnectionProv
4848
import org.apache.spark.sql.execution.datasources.orc.OrcTest
4949
import org.apache.spark.sql.execution.datasources.parquet.ParquetTest
5050
import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog
51-
import org.apache.spark.sql.execution.streaming.checkpointing.FileSystemBasedCheckpointFileManager
51+
import org.apache.spark.sql.execution.streaming.checkpointing.{
52+
FileSystemBasedCheckpointFileManager,
53+
HDFSMetadataLog}
5254
import org.apache.spark.sql.execution.vectorized.{
5355
ColumnVectorUtils,
5456
ConstantColumnVector,
@@ -997,6 +999,22 @@ class QueryExecutionErrorsSuite
997999
}
9981000
}
9991001

1002+
test("SPARK-43940: BATCH_METADATA_NOT_FOUND") {
1003+
withTempDir { dir =>
1004+
val metadataLog = new HDFSMetadataLog[String](spark, dir.getAbsolutePath)
1005+
val e = intercept[SparkFileNotFoundException] {
1006+
metadataLog.applyFnToBatchByStream(0L) { _ => () }
1007+
}
1008+
1009+
val batchMetadataFile = new Path(dir.getAbsolutePath, "0").toString
1010+
checkError(
1011+
exception = e,
1012+
condition = "BATCH_METADATA_NOT_FOUND",
1013+
parameters = Map("batchMetadataFile" -> batchMetadataFile),
1014+
sqlState = "42K03")
1015+
}
1016+
}
1017+
10001018
test("UNSUPPORTED_FEATURE.MULTI_ACTION_ALTER: The target JDBC server hosting table " +
10011019
"does not support ALTER TABLE with multiple actions.") {
10021020
withTempDir { tempDir =>

0 commit comments

Comments
 (0)