@@ -29,7 +29,7 @@ DuckDBPyRelation::DuckDBPyRelation(shared_ptr<Relation> rel_p) : rel(std::move(r
2929 this ->executed = false ;
3030 auto &columns = rel->Columns ();
3131 for (auto &col : columns) {
32- names.push_back (col.GetName ());
32+ names.push_back (col.Name (). GetIdentifierName ());
3333 types.push_back (col.GetType ());
3434 }
3535}
@@ -69,9 +69,7 @@ DuckDBPyRelation::DuckDBPyRelation(shared_ptr<DuckDBPyResult> result_p) : rel(nu
6969 }
7070 this ->executed = true ;
7171 this ->types = result->GetTypes ();
72- auto names_str = result->GetNames ();
73- std::transform (names_str.begin (), names_str.end (), this ->names .begin (),
74- [](const std::string &name) { return Identifier (name); });
72+ this ->names = result->GetNames ();
7573}
7674
7775unique_ptr<DuckDBPyRelation> DuckDBPyRelation::ProjectFromExpression (const string &expression) {
@@ -1026,9 +1024,6 @@ PolarsDataFrame DuckDBPyRelation::ToPolars(idx_t batch_size, bool lazy) {
10261024 ArrowSchema arrow_schema;
10271025 auto result_names = names;
10281026 QueryResult::DeduplicateColumns (result_names);
1029- vector<std::string> string_names (result_names.size ());
1030- std::transform (result_names.begin (), result_names.end (), string_names.begin (),
1031- [](const Identifier &name) { return name.GetIdentifierName (); });
10321027 ClientProperties client_properties;
10331028 if (rel) {
10341029 client_properties = rel->context ->GetContext ()->GetClientProperties ();
@@ -1037,10 +1032,10 @@ PolarsDataFrame DuckDBPyRelation::ToPolars(idx_t batch_size, bool lazy) {
10371032 } else {
10381033 throw InternalException (" DuckDBPyRelation To Polars must have a valid relation or result" );
10391034 }
1040- ArrowConverter::ToArrowSchema (&arrow_schema, types, string_names , client_properties);
1035+ ArrowConverter::ToArrowSchema (&arrow_schema, types, result_names , client_properties);
10411036 py::list batches;
10421037 // Now we create an empty arrow table
1043- auto empty_table = pyarrow::ToArrowTable (types, string_names , batches, client_properties);
1038+ auto empty_table = pyarrow::ToArrowTable (types, result_names , batches, client_properties);
10441039
10451040 // And we extract the polars schema from the arrow table
10461041 auto polars_df = py::cast<PolarsDataFrame>(pybind11::module_::import (" polars" ).attr (" DataFrame" )(empty_table));
@@ -1077,8 +1072,8 @@ void DuckDBPyRelation::Close() {
10771072}
10781073
10791074bool DuckDBPyRelation::ContainsColumnByName (const string &name) const {
1080- return std::find_if (names.begin (), names.end (), [&]( const Identifier &item) { return name == item; }) !=
1081- names.end ();
1075+ return std::find_if (names.begin (), names.end (),
1076+ [&]( const string &item) { return StringUtil::CIEquals (name, item); }) != names.end ();
10821077}
10831078
10841079void DuckDBPyRelation::SetConnectionOwner (py::object owner) {
@@ -1122,7 +1117,7 @@ unique_ptr<DuckDBPyRelation> DuckDBPyRelation::GetAttribute(const string &name)
11221117 // e.g 'rel['my_struct']['my_field']:
11231118 // first 'my_struct' is selected by the bottom condition
11241119 // then 'my_field' is accessed on the result of this
1125- column_names.push_back (names[0 ]);
1120+ column_names.push_back (Identifier ( names[0 ]) );
11261121 column_names.push_back (Identifier (name));
11271122 } else if (ContainsColumnByName (name)) {
11281123 column_names.push_back (Identifier (name));
0 commit comments