@@ -131,6 +131,36 @@ def test_polars_lazy(self, duckdb_cursor):
131131 ]
132132 assert lazy_df .filter (pl .col ("b" ) < 32 ).select ('a' ).collect ().to_dicts () == [{'a' : 'Mark' }, {'a' : 'Thijs' }]
133133
134+ def test_polars_column_with_tricky_name (self , duckdb_cursor ):
135+ # Test that a polars DataFrame with a column name that is non standard still works
136+ df_colon = pl .DataFrame ({"x:y" : [1 , 2 ]})
137+ lf = duckdb_cursor .sql ("from df_colon" ).pl (lazy = True )
138+ result = lf .select (pl .all ()).collect ()
139+ assert result .to_dicts () == [{"x:y" : 1 }, {"x:y" : 2 }]
140+ result = lf .select (pl .all ()).filter (pl .col ("x:y" ) == 1 ).collect ()
141+ assert result .to_dicts () == [{"x:y" : 1 }]
142+
143+ df_space = pl .DataFrame ({"x y" : [1 , 2 ]})
144+ lf = duckdb_cursor .sql ("from df_space" ).pl (lazy = True )
145+ result = lf .select (pl .all ()).collect ()
146+ assert result .to_dicts () == [{"x y" : 1 }, {"x y" : 2 }]
147+ result = lf .select (pl .all ()).filter (pl .col ("x y" ) == 1 ).collect ()
148+ assert result .to_dicts () == [{"x y" : 1 }]
149+
150+ df_dot = pl .DataFrame ({"x.y" : [1 , 2 ]})
151+ lf = duckdb_cursor .sql ("from df_dot" ).pl (lazy = True )
152+ result = lf .select (pl .all ()).collect ()
153+ assert result .to_dicts () == [{"x.y" : 1 }, {"x.y" : 2 }]
154+ result = lf .select (pl .all ()).filter (pl .col ("x.y" ) == 1 ).collect ()
155+ assert result .to_dicts () == [{"x.y" : 1 }]
156+
157+ df_quote = pl .DataFrame ({'"xy"' : [1 , 2 ]})
158+ lf = duckdb_cursor .sql ("from df_quote" ).pl (lazy = True )
159+ result = lf .select (pl .all ()).collect ()
160+ assert result .to_dicts () == [{'"xy"' : 1 }, {'"xy"' : 2 }]
161+ result = lf .select (pl .all ()).filter (pl .col ('"xy"' ) == 1 ).collect ()
162+ assert result .to_dicts () == [{'"xy"' : 1 }]
163+
134164 @pytest .mark .parametrize (
135165 'data_type' ,
136166 [
0 commit comments