@@ -845,6 +845,64 @@ func TestTranspile_OnConflict_DuckLakeMode(t *testing.T) {
845845 }
846846}
847847
848+ func TestTranspile_DropCascade_DuckLakeMode (t * testing.T ) {
849+ // In DuckLake mode, CASCADE should be stripped from DROP statements
850+ // See: https://github.com/duckdb/dbt-duckdb/pull/557
851+ tests := []struct {
852+ name string
853+ input string
854+ notContains string
855+ }{
856+ {
857+ name : "DROP TABLE CASCADE becomes DROP TABLE" ,
858+ input : "DROP TABLE users CASCADE" ,
859+ notContains : "CASCADE" ,
860+ },
861+ {
862+ name : "DROP TABLE IF EXISTS CASCADE" ,
863+ input : "DROP TABLE IF EXISTS users CASCADE" ,
864+ notContains : "CASCADE" ,
865+ },
866+ {
867+ name : "DROP VIEW CASCADE" ,
868+ input : "DROP VIEW my_view CASCADE" ,
869+ notContains : "CASCADE" ,
870+ },
871+ {
872+ name : "DROP SCHEMA CASCADE" ,
873+ input : "DROP SCHEMA my_schema CASCADE" ,
874+ notContains : "CASCADE" ,
875+ },
876+ }
877+
878+ tr := New (Config {DuckLakeMode : true })
879+
880+ for _ , tt := range tests {
881+ t .Run (tt .name , func (t * testing.T ) {
882+ result , err := tr .Transpile (tt .input )
883+ if err != nil {
884+ t .Fatalf ("Transpile(%q) error: %v" , tt .input , err )
885+ }
886+ if strings .Contains (strings .ToUpper (result .SQL ), tt .notContains ) {
887+ t .Errorf ("Transpile(%q) = %q, should NOT contain %q" , tt .input , result .SQL , tt .notContains )
888+ }
889+ })
890+ }
891+ }
892+
893+ func TestTranspile_DropCascade_NonDuckLakeMode (t * testing.T ) {
894+ // Outside DuckLake mode, CASCADE should be preserved
895+ tr := New (DefaultConfig ())
896+
897+ result , err := tr .Transpile ("DROP TABLE users CASCADE" )
898+ if err != nil {
899+ t .Fatalf ("Transpile error: %v" , err )
900+ }
901+ if ! strings .Contains (strings .ToUpper (result .SQL ), "CASCADE" ) {
902+ t .Errorf ("Non-DuckLake mode should preserve CASCADE, got: %q" , result .SQL )
903+ }
904+ }
905+
848906func TestTranspile_JSONOperators (t * testing.T ) {
849907 // DuckDB supports -> and ->> operators
850908 tests := []struct {
0 commit comments