Skip to content

Commit 2e5f7b0

Browse files
committed
chore: grab-bag of compiler warning removals
Signed-off-by: R. Tyler Croy <rtyler@brokenco.de>
1 parent 3eee2cd commit 2e5f7b0

14 files changed

Lines changed: 619 additions & 600 deletions

File tree

crates/core/src/kernel/models/actions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ use crate::TableProperty;
1313
pub use delta_kernel::actions::{Metadata, Protocol};
1414

1515
/// Please don't use, this API will be leaving shortly!
16+
///
17+
/// Since the adoption of delta-kernel-rs we lost the direct ability to create [Metadata] actions
18+
/// which is required for some use-cases.
19+
///
20+
/// Upstream tracked here: <https://github.com/delta-io/delta-kernel-rs/issues/1055>
1621
pub fn new_metadata(
1722
schema: &StructType,
1823
partition_columns: impl IntoIterator<Item = impl ToString>,
@@ -263,7 +268,7 @@ impl Default for ProtocolInner {
263268

264269
impl ProtocolInner {
265270
/// Create a new protocol action
266-
pub fn new(min_reader_version: i32, min_writer_version: i32) -> Self {
271+
pub(crate) fn new(min_reader_version: i32, min_writer_version: i32) -> Self {
267272
Self {
268273
min_reader_version,
269274
min_writer_version,

crates/core/src/kernel/snapshot/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ use futures::{StreamExt, TryStreamExt};
3939
use object_store::path::Path;
4040
use object_store::ObjectStore;
4141
use serde_json::Deserializer;
42-
use tokio::task::spawn_blocking;
43-
use tracing::Instrument;
4442
use url::Url;
4543

4644
use super::{Action, CommitInfo, Metadata, Protocol};

crates/core/src/kernel/transaction/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
#[cfg(feature = "datafusion")]
12
#[cfg(test)]
23
mod tests {
34
use crate::{
45
checkpoints, ensure_table_uri, kernel::transaction::CommitProperties, kernel::Transaction,
56
protocol::SaveMode, writer::test_utils::get_record_batch, DeltaOps, DeltaTableBuilder,
67
};
78

8-
#[cfg(feature = "datafusion")]
99
#[tokio::test]
1010
async fn test_app_txn_workload() {
1111
// Test that the transaction ids can be read from different scenarios

crates/core/src/logstore/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ pub fn str_is_truthy(val: &str) -> bool {
300300
#[cfg(test)]
301301
mod tests {
302302
use super::*;
303+
#[cfg(feature = "cloud")]
303304
use std::time::Duration;
304305

305306
// Test retry config parsing

crates/core/src/operations/create.rs

Lines changed: 134 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ mod tests {
404404
use super::*;
405405
use crate::operations::DeltaOps;
406406
use crate::table::config::TableProperty;
407-
use crate::writer::test_utils::{get_delta_schema, get_record_batch};
407+
use crate::writer::test_utils::get_delta_schema;
408408
use tempfile::TempDir;
409409

410410
#[tokio::test]
@@ -517,138 +517,141 @@ mod tests {
517517
}
518518

519519
#[cfg(feature = "datafusion")]
520-
#[tokio::test]
521-
async fn test_create_table_save_mode() {
522-
let tmp_dir = tempfile::tempdir().unwrap();
523-
524-
let schema = get_delta_schema();
525-
let table = CreateBuilder::new()
526-
.with_location(tmp_dir.path().to_str().unwrap())
527-
.with_columns(schema.fields().cloned())
528-
.await
529-
.unwrap();
530-
assert_eq!(table.version(), Some(0));
531-
let first_id = table.snapshot().unwrap().metadata().id().to_string();
532-
533-
let log_store = table.log_store;
534-
535-
// Check an error is raised when a table exists at location
536-
let table = CreateBuilder::new()
537-
.with_log_store(log_store.clone())
538-
.with_columns(schema.fields().cloned())
539-
.with_save_mode(SaveMode::ErrorIfExists)
540-
.await;
541-
assert!(table.is_err());
542-
543-
// Check current table is returned when ignore option is chosen.
544-
let table = CreateBuilder::new()
545-
.with_log_store(log_store.clone())
546-
.with_columns(schema.fields().cloned())
547-
.with_save_mode(SaveMode::Ignore)
548-
.await
549-
.unwrap();
550-
assert_eq!(table.snapshot().unwrap().metadata().id(), first_id);
551-
552-
// Check table is overwritten
553-
let table = CreateBuilder::new()
554-
.with_log_store(log_store)
555-
.with_columns(schema.fields().cloned())
556-
.with_save_mode(SaveMode::Overwrite)
557-
.await
558-
.unwrap();
559-
assert_ne!(table.snapshot().unwrap().metadata().id(), first_id)
560-
}
561-
562-
#[cfg(feature = "datafusion")]
563-
#[tokio::test]
564-
async fn test_create_or_replace_existing_table() {
565-
let batch = get_record_batch(None, false);
566-
let schema = get_delta_schema();
567-
let table = DeltaOps::new_in_memory()
568-
.write(vec![batch.clone()])
569-
.with_save_mode(SaveMode::ErrorIfExists)
570-
.await
571-
.unwrap();
572-
let state = table.snapshot().unwrap();
573-
assert_eq!(state.version(), 0);
574-
assert_eq!(state.log_data().num_files(), 1);
575-
576-
let mut table = DeltaOps(table)
577-
.create()
578-
.with_columns(schema.fields().cloned())
579-
.with_save_mode(SaveMode::Overwrite)
580-
.await
581-
.unwrap();
582-
table.load().await.unwrap();
583-
let state = table.snapshot().unwrap();
584-
assert_eq!(state.version(), 1);
585-
// Checks if files got removed after overwrite
586-
assert_eq!(state.log_data().num_files(), 0);
587-
}
588-
589-
#[tokio::test]
590-
#[cfg(feature = "datafusion")]
591-
async fn test_create_or_replace_existing_table_partitioned() {
592-
let batch = get_record_batch(None, false);
593-
let schema = get_delta_schema();
594-
let table = DeltaOps::new_in_memory()
595-
.write(vec![batch.clone()])
596-
.with_save_mode(SaveMode::ErrorIfExists)
597-
.await
598-
.unwrap();
599-
let state = table.snapshot().unwrap();
600-
assert_eq!(state.version(), 0);
601-
assert_eq!(state.log_data().num_files(), 1);
602-
603-
let mut table = DeltaOps(table)
604-
.create()
605-
.with_columns(schema.fields().cloned())
606-
.with_save_mode(SaveMode::Overwrite)
607-
.with_partition_columns(vec!["id"])
608-
.await
609-
.unwrap();
610-
table.load().await.unwrap();
611-
let state = table.snapshot().unwrap();
612-
assert_eq!(state.version(), 1);
613-
// Checks if files got removed after overwrite
614-
assert_eq!(state.log_data().num_files(), 0);
615-
}
616-
617-
#[tokio::test]
618-
async fn test_create_table_metadata_raise_if_key_not_exists() {
619-
let schema = get_delta_schema();
620-
let config: HashMap<String, Option<String>> =
621-
vec![("key".to_string(), Some("value".to_string()))]
622-
.into_iter()
623-
.collect();
520+
mod datafusion_tests {
521+
use super::*;
522+
523+
use crate::writer::test_utils::get_record_batch;
524+
#[tokio::test]
525+
async fn test_create_table_save_mode() {
526+
let tmp_dir = tempfile::tempdir().unwrap();
527+
528+
let schema = get_delta_schema();
529+
let table = CreateBuilder::new()
530+
.with_location(tmp_dir.path().to_str().unwrap())
531+
.with_columns(schema.fields().cloned())
532+
.await
533+
.unwrap();
534+
assert_eq!(table.version(), Some(0));
535+
let first_id = table.snapshot().unwrap().metadata().id().to_string();
536+
537+
let log_store = table.log_store;
538+
539+
// Check an error is raised when a table exists at location
540+
let table = CreateBuilder::new()
541+
.with_log_store(log_store.clone())
542+
.with_columns(schema.fields().cloned())
543+
.with_save_mode(SaveMode::ErrorIfExists)
544+
.await;
545+
assert!(table.is_err());
546+
547+
// Check current table is returned when ignore option is chosen.
548+
let table = CreateBuilder::new()
549+
.with_log_store(log_store.clone())
550+
.with_columns(schema.fields().cloned())
551+
.with_save_mode(SaveMode::Ignore)
552+
.await
553+
.unwrap();
554+
assert_eq!(table.snapshot().unwrap().metadata().id(), first_id);
555+
556+
// Check table is overwritten
557+
let table = CreateBuilder::new()
558+
.with_log_store(log_store)
559+
.with_columns(schema.fields().cloned())
560+
.with_save_mode(SaveMode::Overwrite)
561+
.await
562+
.unwrap();
563+
assert_ne!(table.snapshot().unwrap().metadata().id(), first_id)
564+
}
624565

625-
// Fail to create table with unknown Delta key
626-
let table = CreateBuilder::new()
627-
.with_location("memory:///")
628-
.with_columns(schema.fields().cloned())
629-
.with_configuration(config.clone())
630-
.await;
631-
assert!(table.is_err());
566+
#[tokio::test]
567+
async fn test_create_or_replace_existing_table() {
568+
let batch = get_record_batch(None, false);
569+
let schema = get_delta_schema();
570+
let table = DeltaOps::new_in_memory()
571+
.write(vec![batch.clone()])
572+
.with_save_mode(SaveMode::ErrorIfExists)
573+
.await
574+
.unwrap();
575+
let state = table.snapshot().unwrap();
576+
assert_eq!(state.version(), 0);
577+
assert_eq!(state.log_data().num_files(), 1);
578+
579+
let mut table = DeltaOps(table)
580+
.create()
581+
.with_columns(schema.fields().cloned())
582+
.with_save_mode(SaveMode::Overwrite)
583+
.await
584+
.unwrap();
585+
table.load().await.unwrap();
586+
let state = table.snapshot().unwrap();
587+
assert_eq!(state.version(), 1);
588+
// Checks if files got removed after overwrite
589+
assert_eq!(state.log_data().num_files(), 0);
590+
}
632591

633-
// Succeed in creating table with unknown Delta key since we set raise_if_key_not_exists to false
634-
let table = CreateBuilder::new()
635-
.with_location("memory:///")
636-
.with_columns(schema.fields().cloned())
637-
.with_raise_if_key_not_exists(false)
638-
.with_configuration(config)
639-
.await;
640-
assert!(table.is_ok());
592+
#[tokio::test]
593+
async fn test_create_or_replace_existing_table_partitioned() {
594+
let batch = get_record_batch(None, false);
595+
let schema = get_delta_schema();
596+
let table = DeltaOps::new_in_memory()
597+
.write(vec![batch.clone()])
598+
.with_save_mode(SaveMode::ErrorIfExists)
599+
.await
600+
.unwrap();
601+
let state = table.snapshot().unwrap();
602+
assert_eq!(state.version(), 0);
603+
assert_eq!(state.log_data().num_files(), 1);
604+
605+
let mut table = DeltaOps(table)
606+
.create()
607+
.with_columns(schema.fields().cloned())
608+
.with_save_mode(SaveMode::Overwrite)
609+
.with_partition_columns(vec!["id"])
610+
.await
611+
.unwrap();
612+
table.load().await.unwrap();
613+
let state = table.snapshot().unwrap();
614+
assert_eq!(state.version(), 1);
615+
// Checks if files got removed after overwrite
616+
assert_eq!(state.log_data().num_files(), 0);
617+
}
641618

642-
// Ensure the non-Delta key was set correctly
643-
let value = table
644-
.unwrap()
645-
.snapshot()
646-
.unwrap()
647-
.metadata()
648-
.configuration()
649-
.get("key")
650-
.unwrap()
651-
.clone();
652-
assert_eq!(String::from("value"), value);
619+
#[tokio::test]
620+
async fn test_create_table_metadata_raise_if_key_not_exists() {
621+
let schema = get_delta_schema();
622+
let config: HashMap<String, Option<String>> =
623+
vec![("key".to_string(), Some("value".to_string()))]
624+
.into_iter()
625+
.collect();
626+
627+
// Fail to create table with unknown Delta key
628+
let table = CreateBuilder::new()
629+
.with_location("memory:///")
630+
.with_columns(schema.fields().cloned())
631+
.with_configuration(config.clone())
632+
.await;
633+
assert!(table.is_err());
634+
635+
// Succeed in creating table with unknown Delta key since we set raise_if_key_not_exists to false
636+
let table = CreateBuilder::new()
637+
.with_location("memory:///")
638+
.with_columns(schema.fields().cloned())
639+
.with_raise_if_key_not_exists(false)
640+
.with_configuration(config)
641+
.await;
642+
assert!(table.is_ok());
643+
644+
// Ensure the non-Delta key was set correctly
645+
let value = table
646+
.unwrap()
647+
.snapshot()
648+
.unwrap()
649+
.metadata()
650+
.configuration()
651+
.get("key")
652+
.unwrap()
653+
.clone();
654+
assert_eq!(String::from("value"), value);
655+
}
653656
}
654657
}

crates/core/src/operations/generate.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! enon-partitioned tables this will generate a `_symlink_format_manifest/manifest` file next to
88
//! the `_delta_log`, for example:
99
//!
10-
//! ```
10+
//! ```ignore
1111
//! COVID-19_NYT
1212
//! ├── _delta_log
1313
//! │   ├── 00000000000000000000.crc
@@ -27,7 +27,7 @@
2727
//! For partitioned tables, a `manifest` file will be generated inside a hive-style partitioned
2828
//! tree structure, e.g.:
2929
//!
30-
//! ```
30+
//! ```ignore
3131
//! delta-0.8.0-partitioned
3232
//! ├── _delta_log
3333
//! │   └── 00000000000000000000.json
@@ -74,12 +74,10 @@ use futures::future::BoxFuture;
7474
use std::collections::HashMap;
7575
use std::sync::Arc;
7676

77-
use itertools::Itertools;
7877
use object_store::path::{Path, PathPart};
7978
use tracing::log::*;
8079

8180
use super::{CustomExecuteHandler, Operation};
82-
use crate::kernel::scalars::ScalarExt;
8381
use crate::kernel::{resolve_snapshot, EagerSnapshot};
8482
use crate::logstore::object_store::PutPayload;
8583
use crate::logstore::LogStoreRef;

crates/core/src/operations/restore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ impl std::future::IntoFuture for RestoreBuilder {
375375
}
376376

377377
#[cfg(test)]
378+
#[cfg(feature = "datafusion")]
378379
mod tests {
379380

380381
use crate::writer::test_utils::{create_bare_table, get_record_batch};
@@ -383,7 +384,6 @@ mod tests {
383384
/// Verify that restore respects constraints that were added/removed in previous version_to_restore
384385
/// <https://github.com/delta-io/delta-rs/issues/3352>
385386
#[tokio::test]
386-
#[cfg(feature = "datafusion")]
387387
async fn test_simple_restore_constraints() -> DeltaResult<()> {
388388
use std::collections::HashMap;
389389

0 commit comments

Comments
 (0)