@@ -1418,15 +1418,16 @@ impl DeltaDataChecker {
1418
1418
return Ok ( ( ) ) ;
1419
1419
}
1420
1420
let table = MemTable :: try_new ( record_batch. schema ( ) , vec ! [ vec![ record_batch. clone( ) ] ] ) ?;
1421
-
1421
+ let schema = table . schema ( ) ;
1422
1422
// Use a random table name to avoid clashes when running multiple parallel tasks, e.g. when using a partitioned table
1423
1423
let table_name: String = uuid:: Uuid :: new_v4 ( ) . to_string ( ) ;
1424
1424
self . ctx . register_table ( & table_name, Arc :: new ( table) ) ?;
1425
1425
1426
1426
let mut violations: Vec < String > = Vec :: new ( ) ;
1427
1427
1428
1428
for check in checks {
1429
- if check. get_name ( ) . contains ( '.' ) {
1429
+ let check_name = check. get_name ( ) ;
1430
+ if check_name. contains ( '.' ) {
1430
1431
return Err ( DeltaTableError :: Generic (
1431
1432
"Support for nested columns is not supported." . to_string ( ) ,
1432
1433
) ) ;
@@ -1435,12 +1436,23 @@ impl DeltaDataChecker {
1435
1436
let field_to_select = if check. as_any ( ) . is :: < Constraint > ( ) {
1436
1437
"*"
1437
1438
} else {
1438
- check . get_name ( )
1439
+ check_name
1439
1440
} ;
1441
+
1442
+ // Loop through schema to find the matching field. If the field has a whitespace, we
1443
+ // need to backtick it, since the expression is an unquoted string
1444
+ let mut expression = check. get_expression ( ) . to_string ( ) ;
1445
+ for field in schema. fields ( ) {
1446
+ if expression. contains ( field. name ( ) ) {
1447
+ expression =
1448
+ expression. replace ( field. name ( ) , format ! ( "`{}` " , field. name( ) ) . as_str ( ) ) ;
1449
+ break ;
1450
+ }
1451
+ }
1452
+
1440
1453
let sql = format ! (
1441
1454
"SELECT {} FROM `{table_name}` WHERE NOT ({}) LIMIT 1" ,
1442
- field_to_select,
1443
- check. get_expression( )
1455
+ field_to_select, expression
1444
1456
) ;
1445
1457
1446
1458
let dfs: Vec < RecordBatch > = self . ctx . sql ( & sql) . await ?. collect ( ) . await ?;
0 commit comments