arrow: ArrowResult helpers and coerce_arrow_table/coerce_arrow_batches fail on non-'table' return_format payloads
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Start with sqlspec/utils/arrow_helpers.py, especially coerce_arrow_table() and coerce_arrow_batches(), then inspect ArrowResult._as_table() in sqlspec/core/result/_base.py. Reproduce with a RecordBatch, a list of batches, and a RecordBatchReader; check existing Arrow helper tests for coverage. Done when all documented return formats coerce correctly, including empty batches, and repeated result property access works after reader materialization.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
ArrowResult helper methods and coerce_arrow_table / coerce_arrow_batches fail when select_to_arrow() returns any return_format other than "table" ("batch", "batches", or "reader").
Details
-
ArrowResult._as_table()rejects"batch","batches", and"reader"payloads (sqlspec/core/result/_base.py:1385-1389):ArrowResult.get_data()(sqlspec/core/result/_base.py:1149-1163) andarrow_table_to_return_format()(sqlspec/utils/arrow_helpers.py:812-838) document all four return shapes:pyarrow.Table,pyarrow.RecordBatch,list[pyarrow.RecordBatch], andpyarrow.RecordBatchReader.- However,
ArrowResult._as_table()delegates directly toensure_arrow_table(self.data)(sqlspec/utils/arrow_helpers.py:776-784), which raisesTypeErrorfor anything other thanpyarrow.Table. - Calling
len(res),iter(res),res.column_names,res.num_rows,res.num_columns,res.to_dict(),res.to_pandas(), orres.to_polars()raisesTypeError: Expected an Arrow Table, but got RecordBatch / list / RecordBatchReader.
-
coerce_arrow_table()andcoerce_arrow_batches()fail onlist[pyarrow.RecordBatch]andArrowResult(data=list[pyarrow.RecordBatch])(sqlspec/utils/arrow_helpers.py:694-753):- Passing a
list[pa.RecordBatch](the exact payload returned byselect_to_arrow(..., return_format="batches")) falls through toif isinstance(source, Iterable): return pa.Table.from_pylist(list(source))(arrow_helpers.py:716-719), raisingAttributeError: 'pyarrow.lib.RecordBatch' object has no attribute 'keys'. - Passing
ArrowResult(data=[batch])tocoerce_arrow_table()raisesTypeError: ArrowResult did not return a pyarrow.Table instance(arrow_helpers.py:698-704), and passing it tocoerce_arrow_batches()raises the sameAttributeError.
- Passing a
Reproduction (sqlspec==0.74.2)
import pyarrow as pa
from sqlspec.core import SQL, create_arrow_result
from sqlspec.utils.arrow_helpers import coerce_arrow_batches, coerce_arrow_table
batch = pa.record_batch({"amount": [1.0, 2.0]})
for payload in (
batch,
[batch],
pa.RecordBatchReader.from_batches(batch.schema, [batch]),
):
res = create_arrow_result(SQL("SELECT 1"), payload)
len(res) # TypeError: Expected an Arrow Table, but got RecordBatch / list / RecordBatchReader
coerce_arrow_table([batch])
# AttributeError: 'pyarrow.lib.RecordBatch' object has no attribute 'keys'
coerce_arrow_table(create_arrow_result(SQL("SELECT 1"), [batch]))
# TypeError: ArrowResult did not return a pyarrow.Table instance
coerce_arrow_batches(create_arrow_result(SQL("SELECT 1"), [batch]))
# AttributeError: 'pyarrow.lib.RecordBatch' object has no attribute 'keys'
Expected Behavior
coerce_arrow_table()andcoerce_arrow_batches()should recognize sequences/iterables ofpyarrow.RecordBatch(converting viapa.Table.from_batches(...)or yielding batches directly, handling empty lists cleanly).ArrowResult._as_table()should coercepyarrow.RecordBatch,list[pyarrow.RecordBatch], andpyarrow.RecordBatchReaderpayloads (caching the materialized table when consuming a reader/iterator so repeated property access works consistently across all documentedArrowReturnFormatmodes).
- Lenguaje dominante
- Python
- Estrellas
- 110
- Forks
- 11
- Merge medio
- 19 h 9 min
- PR fusionados (30 d)
- 37
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de litestar-org/sqlspec
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
litestar-org/sqlspec#946 ·
Los mantenedores suelen responder en 1 día
-
builder: order_by("col", "asc") silently treats the direction as a columnPosiblemente ocupada @cofin la tomó hace 1 día. Abiertoenhancement
litestar-org/sqlspec#944 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
builder: explain why boolean projections are rejected in sql.select() string columnsPosiblemente ocupada @cofin la tomó hace 1 día. Abiertoenhancement
litestar-org/sqlspec#943 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
feat(litestar): support Litestar v3 compatibility and DI changesPosiblemente ocupada @cofin la tomó hace 14 días. Abiertoenhancement
litestar-org/sqlspec#926 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
litestar-org/sqlspec#509 ·
Los mantenedores suelen responder en 1 día
Todos los issues de litestar-org/sqlspec
Issues similares
-
area:cli area:docs Platform vdr
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA-NeMo/Gym#7192 ·
Los mantenedores suelen responder en 2 días
-
Bug: CaseInsensitiveDict (event.headers) returns True for both == and != against the same mappingAbiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws-powertools/powertools-lambda-python#8948 ·
Los mantenedores suelen responder en 1 día
-
SofyaBotAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
ai-robots-txt/ai.robots.txt#324 ·
-
[Resource]: DashbarAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
hesreallyhim/awesome-claude-code#3821 · 1 comentario ·
-
bug good first issue help wanted level 1 wocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
GianlucaBave/murmury#169 ·
Los mantenedores suelen responder en 1 día