@@ -199,6 +199,77 @@ pub fn create_catalog_filter_pushdown(catalog_path: &Path) -> Result<()> {
199199 Ok ( ( ) )
200200}
201201
202+ /// Creates a catalog with an empty table (no data)
203+ ///
204+ /// Table schema:
205+ /// - tbl (i INT)
206+ /// - 0 rows (after inserting and deleting)
207+ pub fn create_catalog_empty_table ( catalog_path : & Path ) -> Result < ( ) > {
208+ let conn = duckdb:: Connection :: open_in_memory ( ) ?;
209+
210+ conn. execute ( "INSTALL ducklake;" , [ ] ) ?;
211+ conn. execute ( "LOAD ducklake;" , [ ] ) ?;
212+
213+ let ducklake_path = format ! ( "ducklake:{}" , catalog_path. display( ) ) ;
214+ conn. execute ( & format ! ( "ATTACH '{}' AS test_catalog;" , ducklake_path) , [ ] ) ?;
215+
216+ conn. execute (
217+ "CREATE TABLE test_catalog.tbl (
218+ i INTEGER
219+ );" ,
220+ [ ] ,
221+ ) ?;
222+
223+ // Insert a dummy row to create the file structure
224+ conn. execute ( "INSERT INTO test_catalog.tbl VALUES (1);" , [ ] ) ?;
225+
226+ // Delete it to make the table effectively empty
227+ conn. execute ( "DELETE FROM test_catalog.tbl WHERE i = 1;" , [ ] ) ?;
228+
229+ Ok ( ( ) )
230+ }
231+
232+ /// Creates a catalog matching ducklake_basic.test scenario
233+ ///
234+ /// Tables:
235+ /// - test (i INT, j INT) with 4 rows: (1,2), (NULL,3), (4,5), (6,7)
236+ /// - test2 (j VARCHAR, date DATE) with 1 row: ('hello world', '1992-01-01')
237+ pub fn create_catalog_basic_test ( catalog_path : & Path ) -> Result < ( ) > {
238+ let conn = duckdb:: Connection :: open_in_memory ( ) ?;
239+
240+ conn. execute ( "INSTALL ducklake;" , [ ] ) ?;
241+ conn. execute ( "LOAD ducklake;" , [ ] ) ?;
242+
243+ let ducklake_path = format ! ( "ducklake:{}" , catalog_path. display( ) ) ;
244+ conn. execute ( & format ! ( "ATTACH '{}' AS test_catalog;" , ducklake_path) , [ ] ) ?;
245+
246+ // Create first table: test(i INTEGER, j INTEGER)
247+ conn. execute (
248+ "CREATE TABLE test_catalog.test (
249+ i INTEGER,
250+ j INTEGER
251+ );" ,
252+ [ ] ,
253+ ) ?;
254+
255+ // Insert data in two batches (as in original test)
256+ conn. execute (
257+ "INSERT INTO test_catalog.test VALUES (1, 2), (NULL, 3);" ,
258+ [ ] ,
259+ ) ?;
260+
261+ conn. execute ( "INSERT INTO test_catalog.test VALUES (4, 5), (6, 7);" , [ ] ) ?;
262+
263+ // Create second table: test2 with VARCHAR and DATE
264+ conn. execute (
265+ "CREATE TABLE test_catalog.test2 AS
266+ SELECT 'hello world' AS j, DATE '1992-01-01' AS date;" ,
267+ [ ] ,
268+ ) ?;
269+
270+ Ok ( ( ) )
271+ }
272+
202273/// Helper to convert anyhow errors to DataFusion errors
203274///
204275/// This is useful for converting anyhow::Error to DataFusionError in test code.
0 commit comments