ColumnExpression doesn't escape column name containing `.`

Open
#46 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, sql
Domain
backend, databases

Research direction

Run the supplied Python reproduction using duckdb.ColumnExpression and the column name b.a, then trace that entry point in the duckdb Python package. Compare its handling of names containing spaces with names containing dots. Done means selecting the dotted column succeeds without treating b as a table name.

Written by the indexing model from the issue text.

Description

What happens?

If a column name contains a '.' I can't select it with duckdb.ColumnExpression. Should ColumnExpression not do the escaping for us, so we can just pass the column name?

At least, that's what happens for column names that contains spaces

To Reproduce
import duckdb

rel = duckdb.sql("""select * from values (1, 2), (3, 4) df(a, "b.a")""")
rel.select(duckdb.ColumnExpression('b.a'))
---------------------------------------------------------------------------
BinderException                           Traceback (most recent call last)
Cell In[3], line 1
----> 1 rel.select(duckdb.ColumnExpression('b.a'))

BinderException: Binder Error: Referenced table "b" not found!
Candidate tables: "unnamed_relation_0ba05ea8514d33bd"
OS:

linux

DuckDB Package Version:

1.3.2

Python Version:

3.12

Full Name:

Marco Gorelli

Affiliation:

Quansight Labs

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a nightly build

Did you include all relevant data sets for reproducing the issue?

No - Other reason (please specify in the issue body)

Did you include all code required to reproduce the issue?
  • Yes, I have
Did you include all relevant configuration to reproduce the issue?
  • Yes, I have
Dominant language
Python
Stars
186
Forks
113
Avg merge
20h 58m
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-python

All issues in duckdb/duckdb-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.