@@ -1733,22 +1733,6 @@ mod tests {
17331733 . unwrap_or_else ( |e| panic ! ( "register {} failed: {}" , table, e) ) ;
17341734 }
17351735
1736- /// Register a Redis table with declared column schema (for empty tables).
1737- fn register_ci_table_with_columns (
1738- ctx : & mut SessionContext ,
1739- table : & str ,
1740- key_column : & str ,
1741- columns : & str ,
1742- ) {
1743- let mut options = HashMap :: new ( ) ;
1744- options. insert ( "key_space" . to_string ( ) , "mydb" . to_string ( ) ) ;
1745- options. insert ( "table" . to_string ( ) , table. to_string ( ) ) ;
1746- options. insert ( "key_column" . to_string ( ) , key_column. to_string ( ) ) ;
1747- options. insert ( "columns" . to_string ( ) , columns. to_string ( ) ) ;
1748- register_redis_tables ( ctx, table, "redis://127.0.0.1:6379" , Some ( & options) )
1749- . unwrap_or_else ( |e| panic ! ( "register {} failed: {}" , table, e) ) ;
1750- }
1751-
17521736 async fn ci_query_all ( ctx : & SessionContext , sql : & str ) -> Vec < RecordBatch > {
17531737 let df = ctx. sql ( sql) . await . expect ( "parse sql" ) ;
17541738 df. collect ( ) . await . expect ( "collect results" )
@@ -1771,7 +1755,7 @@ mod tests {
17711755 "SELECT product_id, name, category, price, in_stock FROM products ORDER BY product_id" ,
17721756 )
17731757 . await ;
1774- assert_eq ! ( ci_total_rows( & batches) , 5 ) ;
1758+ assert ! ( ci_total_rows( & batches) >= 5 ) ;
17751759 }
17761760
17771761 #[ tokio:: test]
@@ -1781,7 +1765,7 @@ mod tests {
17811765 register_ci_table ( & mut ctx, "products" ) ;
17821766
17831767 let batches = ci_query_all ( & ctx, "SELECT name FROM products ORDER BY product_id" ) . await ;
1784- assert_eq ! ( ci_total_rows( & batches) , 5 ) ;
1768+ assert ! ( ci_total_rows( & batches) >= 5 ) ;
17851769 assert_eq ! ( batches[ 0 ] . num_columns( ) , 1 ) ;
17861770 }
17871771
@@ -1861,8 +1845,12 @@ mod tests {
18611845 . await
18621846 . unwrap ( ) ;
18631847
1864- let before = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1865- let before_count = ci_total_rows ( & before) ;
1848+ let before = ci_query_all (
1849+ & ctx,
1850+ "SELECT product_id FROM products WHERE product_id = 'PROD_DEL_TEST'" ,
1851+ )
1852+ . await ;
1853+ assert_eq ! ( ci_total_rows( & before) , 1 ) ;
18661854
18671855 ctx. sql ( "DELETE FROM products WHERE product_id = 'PROD_DEL_TEST'" )
18681856 . await
@@ -1871,8 +1859,12 @@ mod tests {
18711859 . await
18721860 . expect ( "execute delete" ) ;
18731861
1874- let after = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1875- assert_eq ! ( ci_total_rows( & after) , before_count - 1 ) ;
1862+ let after = ci_query_all (
1863+ & ctx,
1864+ "SELECT product_id FROM products WHERE product_id = 'PROD_DEL_TEST'" ,
1865+ )
1866+ . await ;
1867+ assert_eq ! ( ci_total_rows( & after) , 0 ) ;
18761868 }
18771869
18781870 #[ tokio:: test]
@@ -1881,8 +1873,12 @@ mod tests {
18811873 let mut ctx = SessionContext :: new ( ) ;
18821874 register_ci_table ( & mut ctx, "products" ) ;
18831875
1884- let before = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1885- let before_count = ci_total_rows ( & before) ;
1876+ let before = ci_query_all (
1877+ & ctx,
1878+ "SELECT product_id FROM products WHERE product_id = 'PROD001'" ,
1879+ )
1880+ . await ;
1881+ assert_eq ! ( ci_total_rows( & before) , 1 ) ;
18861882
18871883 ctx. sql ( "DELETE FROM products WHERE product_id = 'NONEXISTENT'" )
18881884 . await
@@ -1891,8 +1887,12 @@ mod tests {
18911887 . await
18921888 . expect ( "execute delete" ) ;
18931889
1894- let after = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1895- assert_eq ! ( ci_total_rows( & after) , before_count) ;
1890+ let after = ci_query_all (
1891+ & ctx,
1892+ "SELECT product_id FROM products WHERE product_id = 'PROD001'" ,
1893+ )
1894+ . await ;
1895+ assert_eq ! ( ci_total_rows( & after) , 1 ) ;
18961896 }
18971897
18981898 // ─── Update tests (integration) ─────────────────────────────────────
@@ -1931,8 +1931,19 @@ mod tests {
19311931 let mut ctx = SessionContext :: new ( ) ;
19321932 register_ci_table ( & mut ctx, "products" ) ;
19331933
1934- let before = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1935- let before_count = ci_total_rows ( & before) ;
1934+ let before = ci_query_all (
1935+ & ctx,
1936+ "SELECT name FROM products WHERE product_id = 'PROD001'" ,
1937+ )
1938+ . await ;
1939+ assert_eq ! ( ci_total_rows( & before) , 1 ) ;
1940+ let before_name = before[ 0 ]
1941+ . column ( 0 )
1942+ . as_any ( )
1943+ . downcast_ref :: < StringArray > ( )
1944+ . unwrap ( )
1945+ . value ( 0 )
1946+ . to_string ( ) ;
19361947
19371948 ctx. sql ( "UPDATE products SET price = '0.0' WHERE product_id = 'NONEXISTENT'" )
19381949 . await
@@ -1941,8 +1952,20 @@ mod tests {
19411952 . await
19421953 . expect ( "execute update" ) ;
19431954
1944- let after = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1945- assert_eq ! ( ci_total_rows( & after) , before_count) ;
1955+ let after = ci_query_all (
1956+ & ctx,
1957+ "SELECT name FROM products WHERE product_id = 'PROD001'" ,
1958+ )
1959+ . await ;
1960+ assert_eq ! ( ci_total_rows( & after) , 1 ) ;
1961+ let after_name = after[ 0 ]
1962+ . column ( 0 )
1963+ . as_any ( )
1964+ . downcast_ref :: < StringArray > ( )
1965+ . unwrap ( )
1966+ . value ( 0 )
1967+ . to_string ( ) ;
1968+ assert_eq ! ( before_name, after_name) ;
19461969 }
19471970
19481971 // ─── Combined DML test (integration) ────────────────────────────────
@@ -1953,9 +1976,6 @@ mod tests {
19531976 let mut ctx = SessionContext :: new ( ) ;
19541977 register_ci_table ( & mut ctx, "products" ) ;
19551978
1956- let before = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1957- let before_count = ci_total_rows ( & before) ;
1958-
19591979 // 1. Insert
19601980 ctx. sql (
19611981 "INSERT INTO products (product_id, name, category, price, in_stock)
@@ -1966,8 +1986,12 @@ mod tests {
19661986 . collect ( )
19671987 . await
19681988 . unwrap ( ) ;
1969- let after_insert = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1970- assert_eq ! ( ci_total_rows( & after_insert) , before_count + 1 ) ;
1989+ let after_insert = ci_query_all (
1990+ & ctx,
1991+ "SELECT product_id FROM products WHERE product_id = 'PROD_RT_TEST'" ,
1992+ )
1993+ . await ;
1994+ assert_eq ! ( ci_total_rows( & after_insert) , 1 ) ;
19711995
19721996 // 2. Update
19731997 ctx. sql ( "UPDATE products SET name = 'RoundTripUpdated', price = '20.0' WHERE product_id = 'PROD_RT_TEST'" )
@@ -1981,6 +2005,7 @@ mod tests {
19812005 "SELECT name, price FROM products WHERE product_id = 'PROD_RT_TEST'" ,
19822006 )
19832007 . await ;
2008+ assert_eq ! ( ci_total_rows( & batches) , 1 ) ;
19842009 let names = batches[ 0 ]
19852010 . column ( 0 )
19862011 . as_any ( )
@@ -1995,8 +2020,12 @@ mod tests {
19952020 . collect ( )
19962021 . await
19972022 . unwrap ( ) ;
1998- let after_delete = ci_query_all ( & ctx, "SELECT product_id FROM products" ) . await ;
1999- assert_eq ! ( ci_total_rows( & after_delete) , before_count) ;
2023+ let after_delete = ci_query_all (
2024+ & ctx,
2025+ "SELECT product_id FROM products WHERE product_id = 'PROD_RT_TEST'" ,
2026+ )
2027+ . await ;
2028+ assert_eq ! ( ci_total_rows( & after_delete) , 0 ) ;
20002029 }
20012030
20022031 // ─── Non-key column filter test (integration) ───────────────────────
0 commit comments