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

Offen
#492 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
python, sql
Bereich
api, database

Rechercherichtung

Beginne in databricks/sql/client.py bei fetchall, fetchall_arrow und _convert_arrow_table und folge dem im Traceback gezeigten fehlschlagenden Konvertierungspfad. Reproduziere den Fall SELECT ... WHERE 1=0 und verifiziere, dass fetchall eine leere Liste zurückgibt, statt ValueError auszulösen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Python
Sterne
233
Forks
152
Ø Merge
21 Std. 5 Min.
Gemergte PRs (30 T.)
10

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus databricks/databricks-sql-python

Alle Issues in databricks/databricks-sql-python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.