ValueError: need at least one array to concatenate When Returned Dataset is Emtpy
还没有人认领这个 Issue。
评估
调研方向
从 databricks/sql/client.py 中的 fetchall、fetchall_arrow 和 _convert_arrow_table 开始,沿着 traceback 中显示的失败转换路径进行跟踪。复现 SELECT ... WHERE 1=0 的情况,并验证 fetchall 返回空列表,而不是引发 ValueError。
由索引模型根据 Issue 内容生成。
描述
I notice when a query returns empty dataset, the fetchall function fails with ValueError: need at least one array to concatenate. The expected behavior is to return an empty list.
python 3.8
databricks-sql-connector==3.7.1
pyarrow==17.0.0
sql_query = f"""
SELECT Column FROM table
WHERE 1=0"""
host = os.getenv("DATABRICKS_HOST")
http_path = os.getenv("DATABRICKS_HTTP_PATH")
connection = sql.connect(
server_hostname=host,
http_path=http_path)
with conn.cursor() as cursor:
cursor.execute(sql_query)
rows = cursor.fetchall()
File "c:\Users\acai\.venv\lib\site-packages\databricks\sql\client.py", line 1066, in fetchall
return self.active_result_set.fetchall()
File "c:\Users\acai\.venv\lib\site-packages\databricks\sql\client.py", line 1431, in fetchall
return self._convert_arrow_table(self.fetchall_arrow())
File "c:\Users\acai\.venv\lib\site-packages\databricks\sql\client.py", line 1302, in _convert_arrow_table
df = table_renamed.to_pandas(
File "pyarrow\\array.pxi", line 885, in pyarrow.lib._PandasConvertible.to_pandas
File "pyarrow\\table.pxi", line 5002, in pyarrow.lib.Table._to_pandas
File "c:\Users\acai\.venv\lib\site-packages\pyarrow\pandas_compat.py", line 800, in table_to_dataframe
blocks = [
File "c:\Users\acai\O.venv\lib\site-packages\pyarrow\pandas_compat.py", line 801, in <listcomp>
_reconstruct_block(item, column_names, ext_columns_dtypes)
File "c:\Users\acai\.venv\lib\site-packages\pyarrow\pandas_compat.py", line 743, in _reconstruct_block
arr = pandas_dtype.__from_arrow__(arr)
File "c:\Users\acai\.venv\lib\site-packages\pandas\core\arrays\integer.py", line 121, in __from_arrow__
return IntegerArray._concat_same_type(results)
File "c:\Users\acai\\.venv\lib\site-packages\pandas\core\arrays\masked.py", line 271, in _concat_same_type
data = np.concatenate([x._data for x in to_concat])
File "<__array_function__ internals>", line 200, in concatenate
ValueError: need at least one array to concatenate
- 主要语言
- Python
- 星标
- 233
- 派生
- 152
- 平均合并
- 21 小时 5 分钟
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
databricks/databricks-sql-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 84/100
查看 databricks/databricks-sql-python 的全部 Issue
相似的 Issue
-
fix: inaccuracy ⚠️
难度 2/5 1-3 小时 新手友好度 72/100
uabrc/uabrc.github.io#1255 · 1 条评论 ·
-
docs
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 84/100
ethereum-optimism/factory#64 ·
-
难度 2/5 1-3 小时 新手友好度 90/100
duckdb/duckdb-python#627 ·
-
难度 2/5 1-3 小时 新手友好度 68/100