Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

ValueError: need at least one array to concatenate When Returned Dataset is Emtpy

未關閉
#492 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python, sql
領域
api, database

研究方向

從 databricks/sql/client.py 中的 fetchall、fetchall_arrow 和 _convert_arrow_table 開始,沿著 traceback 中顯示的失敗轉換路徑進行追蹤。重現 SELECT ... WHERE 1=0 的情況,並驗證 fetchall 回傳空清單,而不是引發 ValueError。

由索引模型根據 Issue 內容生成。

描述

engineer-bot

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

databricks/databricks-sql-python 的其他 Issue

查看 databricks/databricks-sql-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。