@@ -742,9 +742,29 @@ def test_duckdb_attach_ducklake_catalog(make_config):
742742 assert ducklake_catalog .encrypted is True
743743 assert ducklake_catalog .data_inlining_row_limit == 10
744744 # Check that the generated SQL includes DATA_PATH
745- assert "DATA_PATH '/tmp/ducklake_data'" in ducklake_catalog .to_sql ("ducklake" )
746- assert "ENCRYPTED" in ducklake_catalog .to_sql ("ducklake" )
747- assert "DATA_INLINING_ROW_LIMIT 10" in ducklake_catalog .to_sql ("ducklake" )
745+ generated_sql = ducklake_catalog .to_sql ("ducklake" )
746+ assert "DATA_PATH '/tmp/ducklake_data'" in generated_sql
747+ assert "ENCRYPTED" in generated_sql
748+ assert "DATA_INLINING_ROW_LIMIT 10" in generated_sql
749+ # Check that the ducklake: prefix is automatically added
750+ assert "ATTACH IF NOT EXISTS 'ducklake:catalog.ducklake'" in generated_sql
751+
752+ # Test that a path with existing ducklake: prefix is preserved
753+ config_with_prefix = make_config (
754+ type = "duckdb" ,
755+ catalogs = {
756+ "ducklake" : DuckDBAttachOptions (
757+ type = "ducklake" ,
758+ path = "ducklake:catalog.ducklake" ,
759+ data_path = "/tmp/ducklake_data" ,
760+ ),
761+ },
762+ )
763+ ducklake_catalog_with_prefix = config_with_prefix .catalogs .get ("ducklake" )
764+ generated_sql_with_prefix = ducklake_catalog_with_prefix .to_sql ("ducklake" )
765+ assert "ATTACH IF NOT EXISTS 'ducklake:catalog.ducklake'" in generated_sql_with_prefix
766+ # Ensure we don't have double prefixes
767+ assert "'ducklake:catalog.ducklake" in generated_sql_with_prefix
748768
749769
750770def test_duckdb_attach_options ():
@@ -762,6 +782,22 @@ def test_duckdb_attach_options():
762782 assert options .to_sql (alias = "db" ) == "ATTACH IF NOT EXISTS 'test.db' AS db"
763783
764784
785+ def test_ducklake_attach_add_ducklake_prefix ():
786+ # Test that ducklake: prefix is automatically added when missing
787+ options = DuckDBAttachOptions (type = "ducklake" , path = "catalog.ducklake" )
788+ assert (
789+ options .to_sql (alias = "my_ducklake" )
790+ == "ATTACH IF NOT EXISTS 'ducklake:catalog.ducklake' AS my_ducklake"
791+ )
792+
793+ # Test that ducklake: prefix is preserved when already present
794+ options = DuckDBAttachOptions (type = "ducklake" , path = "ducklake:catalog.ducklake" )
795+ assert (
796+ options .to_sql (alias = "my_ducklake" )
797+ == "ATTACH IF NOT EXISTS 'ducklake:catalog.ducklake' AS my_ducklake"
798+ )
799+
800+
765801def test_duckdb_config_json_strings (make_config ):
766802 config = make_config (
767803 type = "duckdb" ,
0 commit comments