Skip to content

Commit 1ec381d

Browse files
committed
Revert "fix: if field contains space in constraint expression, the check will fail"
This reverts commit 6babfb6.
1 parent e06e47d commit 1ec381d

File tree

1 file changed

+5
-17
lines changed
  • crates/core/src/delta_datafusion

1 file changed

+5
-17
lines changed

crates/core/src/delta_datafusion/mod.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,16 +1591,15 @@ impl DeltaDataChecker {
15911591
return Ok(());
15921592
}
15931593
let table = MemTable::try_new(record_batch.schema(), vec![vec![record_batch.clone()]])?;
1594-
let schema = table.schema();
1594+
15951595
// Use a random table name to avoid clashes when running multiple parallel tasks, e.g. when using a partitioned table
15961596
let table_name: String = uuid::Uuid::new_v4().to_string();
15971597
self.ctx.register_table(&table_name, Arc::new(table))?;
15981598

15991599
let mut violations: Vec<String> = Vec::new();
16001600

16011601
for check in checks {
1602-
let check_name = check.get_name();
1603-
if check_name.contains('.') {
1602+
if check.get_name().contains('.') {
16041603
return Err(DeltaTableError::Generic(
16051604
"Support for nested columns is not supported.".to_string(),
16061605
));
@@ -1609,23 +1608,12 @@ impl DeltaDataChecker {
16091608
let field_to_select = if check.as_any().is::<Constraint>() {
16101609
"*"
16111610
} else {
1612-
check_name
1611+
check.get_name()
16131612
};
1614-
1615-
// Loop through schema to find the matching field. If the field has a whitespace, we
1616-
// need to backtick it, since the expression is an unquoted string
1617-
let mut expression = check.get_expression().to_string();
1618-
for field in schema.fields() {
1619-
if expression.contains(field.name()) {
1620-
expression =
1621-
expression.replace(field.name(), format!("`{}` ", field.name()).as_str());
1622-
break;
1623-
}
1624-
}
1625-
16261613
let sql = format!(
16271614
"SELECT {} FROM `{table_name}` WHERE NOT ({}) LIMIT 1",
1628-
field_to_select, expression
1615+
field_to_select,
1616+
check.get_expression()
16291617
);
16301618

16311619
let dfs: Vec<RecordBatch> = self.ctx.sql(&sql).await?.collect().await?;

0 commit comments

Comments
 (0)