Skip to content

Commit

Permalink
Merge branch 'main' into merge-barrier
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco authored Dec 20, 2023
2 parents 51a4d70 + c14d577 commit a9ddc9e
Show file tree
Hide file tree
Showing 21 changed files with 635 additions and 231 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ of features outlined in the Delta [protocol][protocol] is also [tracked](#protoc
| Version 2 | Column Invariants | ![done] |
| Version 3 | Enforce `delta.checkpoint.writeStatsAsJson` | [![open]][writer-rs] |
| Version 3 | Enforce `delta.checkpoint.writeStatsAsStruct` | [![open]][writer-rs] |
| Version 3 | CHECK constraints | [![open]][writer-rs] |
| Version 3 | CHECK constraints | [![semi-done]][check-constraints] |
| Version 4 | Change Data Feed | |
| Version 4 | Generated Columns | |
| Version 5 | Column Mapping | |
Expand All @@ -185,5 +185,6 @@ of features outlined in the Delta [protocol][protocol] is also [tracked](#protoc
[merge-py]: https://github.com/delta-io/delta-rs/issues/1357
[merge-rs]: https://github.com/delta-io/delta-rs/issues/850
[writer-rs]: https://github.com/delta-io/delta-rs/issues/851
[check-constraints]: https://github.com/delta-io/delta-rs/issues/1881
[onelake-rs]: https://github.com/delta-io/delta-rs/issues/1418
[protocol]: https://github.com/delta-io/delta/blob/master/PROTOCOL.md
15 changes: 12 additions & 3 deletions crates/deltalake-core/src/delta_datafusion/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,10 @@ impl<'a> fmt::Display for ScalarValueFormat<'a> {
mod test {
use arrow_schema::DataType as ArrowDataType;
use datafusion::prelude::SessionContext;
use datafusion_common::{DFSchema, ScalarValue};
use datafusion_common::{Column, DFSchema, ScalarValue};
use datafusion_expr::{col, decode, lit, substring, Cast, Expr, ExprSchemable};

use crate::delta_datafusion::DeltaSessionContext;
use crate::kernel::{DataType, PrimitiveType, StructField, StructType};
use crate::{DeltaOps, DeltaTable};

Expand Down Expand Up @@ -388,6 +389,11 @@ mod test {
DataType::Primitive(PrimitiveType::Integer),
true,
),
StructField::new(
"Value3".to_string(),
DataType::Primitive(PrimitiveType::Integer),
true,
),
StructField::new(
"modified".to_string(),
DataType::Primitive(PrimitiveType::String),
Expand Down Expand Up @@ -442,7 +448,10 @@ mod test {
}),
"arrow_cast(1, 'Int32')".to_string()
),
simple!(col("value").eq(lit(3_i64)), "value = 3".to_string()),
simple!(
Expr::Column(Column::from_qualified_name_ignore_case("Value3")).eq(lit(3_i64)),
"Value3 = 3".to_string()
),
simple!(col("active").is_true(), "active IS TRUE".to_string()),
simple!(col("active"), "active".to_string()),
simple!(col("active").eq(lit(true)), "active = true".to_string()),
Expand Down Expand Up @@ -536,7 +545,7 @@ mod test {
),
];

let session = SessionContext::new();
let session: SessionContext = DeltaSessionContext::default().into();

for test in tests {
let actual = fmt_expr_to_sql(&test.expr).unwrap();
Expand Down
12 changes: 9 additions & 3 deletions crates/deltalake-core/src/delta_datafusion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ impl DeltaDataChecker {
Self {
invariants,
constraints: vec![],
ctx: SessionContext::new(),
ctx: DeltaSessionContext::default().into(),
}
}

Expand All @@ -1057,10 +1057,16 @@ impl DeltaDataChecker {
Self {
constraints,
invariants: vec![],
ctx: SessionContext::new(),
ctx: DeltaSessionContext::default().into(),
}
}

/// Specify the Datafusion context
pub fn with_session_context(mut self, context: SessionContext) -> Self {
self.ctx = context;
self
}

/// Create a new DeltaDataChecker
pub fn new(snapshot: &DeltaTableState) -> Self {
let metadata = snapshot.metadata();
Expand All @@ -1074,7 +1080,7 @@ impl DeltaDataChecker {
Self {
invariants,
constraints,
ctx: SessionContext::new(),
ctx: DeltaSessionContext::default().into(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/deltalake-core/src/kernel/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};

pub(crate) mod schemas;
mod serde_path;
pub(crate) mod serde_path;
pub(crate) mod types;

pub use types::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/deltalake-core/src/kernel/actions/serde_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn encode_path(path: &str) -> String {
percent_encode(path.as_bytes(), INVALID).to_string()
}

fn decode_path(path: &str) -> Result<String, Utf8Error> {
pub fn decode_path(path: &str) -> Result<String, Utf8Error> {
Ok(percent_decode_str(path).decode_utf8()?.to_string())
}

Expand Down
Loading

0 comments on commit a9ddc9e

Please sign in to comment.