duckdb / duckdb/duckdb-python

Error when trying to parse multiple rows via Relational API `values`

未关闭
#79 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

reproduced
主要语言
Python
星标
186
派生
113
平均合并
13 小时 29 分钟
30 天内合并 PR
17

描述

What happens?

When trying to utilize the values() function for converting a native Python object into a relation, I am unable to create a relation with multiple rows and columns.

To Reproduce
import duckdb

conn = duckdb.connect()

# 1) Base `VALUES` query using straight SQL (correct/expected)
conn.execute("FROM (VALUES (1, 'a'), (2, 'b'))").df()

# 2) 1 row, multiple columns relation (correct/expected)
conn.values([1, 'a']).df()

# 3) 2 rows, multiple columns relation (multiple different attempts - same output below)
conn.values([1, 'a'], [2, 'b']).df()
conn.values([((1), ('a')), ((2), ('b'))]).df()
conn.values(([1, 'a']), ([2, 'b'])).df()
conn.values([[1, 'a'], [2, 'b']]).df()

# 4) 2 rows, multiple columns relation (works, but typed as lists)
conn.values(([1], ['a']), ([2], ['b'])).df()

# 5) Attempted to remove the lists 🤷🏼
conn.values((1, 'a'), (2, 'b'))

Outputs:

# 1)
   col0 col1
0      1      a
1      2      b

# 2)
   col0 col1
0      1      a

# 3)
     col0    col1
0  [1, a]  [2, b]

# 4)
    [1]  ['a']
0  [1]    [a]
1   [2]   [b]

# 5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
duckdb.duckdb.BinderException: Binder Error: Referenced column "a" not found in FROM clause!
OS:

OSX 15.6

DuckDB Package Version:

1.4.0

Python Version:

3.11

Full Name:

Joe Rimsky

Affiliation:

Gecko Robotics

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

I have tested with a stable release

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

Not applicable - the reproduction does not require a data set

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,运行提供的 Python 复现代码并调用 conn.values(),将其多行行为与 SQL VALUES 查询进行比较。跟踪 Relational API 的 values 入口点,并确定嵌套 native 对象的解释方式。完成标准是:多行多列生成与 SQL VALUES 具有相同结果形状的标量列,并覆盖报告的案例。

由索引模型根据 Issue 内容生成。

评估

技术栈
python, sql
领域
api, databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。