diff --git a/crates/core/src/kernel/snapshot/parse.rs b/crates/core/src/kernel/snapshot/parse.rs index a3ccef1902..b87b966230 100644 --- a/crates/core/src/kernel/snapshot/parse.rs +++ b/crates/core/src/kernel/snapshot/parse.rs @@ -11,6 +11,11 @@ use crate::{DeltaResult, DeltaTableError}; pub(super) fn read_metadata(batch: &dyn ProvidesColumnByName) -> DeltaResult> { if let Some(arr) = ex::extract_and_cast_opt::(batch, "metaData") { + // Stop early if all values are null + if arr.null_count() == arr.len() { + return Ok(None); + } + let id = ex::extract_and_cast::(arr, "id")?; let name = ex::extract_and_cast::(arr, "name")?; let description = ex::extract_and_cast::(arr, "description")?; @@ -43,6 +48,11 @@ pub(super) fn read_metadata(batch: &dyn ProvidesColumnByName) -> DeltaResult DeltaResult> { if let Some(arr) = ex::extract_and_cast_opt::(batch, "protocol") { + // Stop early if all values are null + if arr.null_count() == arr.len() { + return Ok(None); + } + let min_reader_version = ex::extract_and_cast::(arr, "minReaderVersion")?; let min_writer_version = ex::extract_and_cast::(arr, "minWriterVersion")?; let maybe_reader_features = ex::extract_and_cast_opt::(arr, "readerFeatures"); @@ -138,6 +148,11 @@ pub(super) fn read_cdf_adds(array: &dyn ProvidesColumnByName) -> DeltaResult(array, "cdc") { + // Stop early if all values are null + if arr.null_count() == arr.len() { + return Ok(result); + } + let path = ex::extract_and_cast::(arr, "path")?; let pvs = ex::extract_and_cast_opt::(arr, "partitionValues"); let size = ex::extract_and_cast::(arr, "size")?; @@ -171,6 +186,11 @@ pub(super) fn read_removes(array: &dyn ProvidesColumnByName) -> DeltaResult(array, "remove") { + // Stop early if all values are null + if arr.null_count() == arr.len() { + return Ok(result); + } + let path = ex::extract_and_cast::(arr, "path")?; let data_change = ex::extract_and_cast::(arr, "dataChange")?; let deletion_timestamp = ex::extract_and_cast::(arr, "deletionTimestamp")?;