Skip to content

[Python] Column names with spaces failing to work as identifiers #8214

@ned2

Description

@ned2

What happens?

When using the Python Relational API and a column name has a space, referencing it as an identifier tends to result in things breaking. Below is an example of this happening when using indexing syntax ( eg relation['col']).

I'm pretty sure I've seen it happen in another context; which I'll add when I come across it again.

To Reproduce

Given this context:

with open("test.csv", "w") as f:
    f.write('boop,"hello world",hello_world\n')
    f.write('boop1,"quack quack",quack_quack\n')

rel = duckdb.read_csv("test.csv", header=True)

This works fine:

rel["hello_world"]

But this throws an error:

rel["hello world"]
AttributeError: This relation does not contain a column by the name of 'hello world'

OS:

Ubuntu 23.04

DuckDB Version:

0.8.2.dev1559

DuckDB Client:

Python

Full Name:

Ned Letcher

Affiliation:

Thoughtworks

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions