to_dataset keeps the last row per dim tuple instead of raising on duplicates
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
- 58/100
Línea de trabajo
Start at to_dataset in the result class and read its docstring's Raises section, which promises a ValueError on duplicate dim tuples. Run the repro in the issue (3 time steps, lat/lon grid, SELECT without time) to confirm 12 rows collapse to 4. Done when that case raises ValueError naming the duplicate dims, and a test covers it. The issue leaves open whether the check should always run or only when dims were inferred, so confirm that with maintainers first.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When a query projects a dimension away, the rows that dimension separated collapse onto the same dim tuple. to_dataset builds a grid from them anyway, keeping whichever row comes last, and returns it without a warning. The docstring says it raises instead:
Raises:
ValueError: ``dims`` cannot be inferred, names a missing
column, or the result has duplicate dim tuples;
Repro on 0.3.3 and 0.4.0rc1:
import numpy as np
import pandas as pd
import xarray as xr
from xarray_sql import XarrayContext
temp = np.arange(12.0).reshape(3, 2, 2)
ds = xr.Dataset(
{"temperature": (["time", "lat", "lon"], temp)},
coords={
"time": pd.date_range("2020-01-01", periods=3),
"lat": [10.0, 20.0],
"lon": [100.0, 110.0],
},
)
ctx = XarrayContext()
ctx.from_dataset("temperature", ds, chunks={"time": 3, "lat": 2, "lon": 2})
result = ctx.sql("SELECT lat, lon, temperature FROM temperature")
print(len(result.to_pandas())) # 12 rows, 4 unique (lat, lon)
print(result.to_dataset(dims=["lat", "lon"])["temperature"].values)
12
[[ 8. 9.]
[10. 11.]]
That is temp[-1], the last time step. Two thirds of the input is gone and nothing says so. Inferring the dims (dims=None) gives the same result.
The value is also arbitrary rather than merely lossy: it depends on the order rows happen to arrive in, so the same query can return different numbers across partitionings.
Raising the documented ValueError seems right to me, since the alternative is picking an aggregation the caller did not ask for. Detecting it costs a scan, so making it conditional (or checking only when dims was inferred) may be worth it.
I hit this from Lumen, where a projecting SQL transform drops a dim before the source grids the result. Happy to send a PR if you want it fixed this way.
- Lenguaje dominante
- Python
- Estrellas
- 142
- Forks
- 19
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 9
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 xqlsystems/xarray-sql
-
documentation
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
xqlsystems/xarray-sql#268 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
xqlsystems/xarray-sql#267 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
xqlsystems/xarray-sql#243 ·
Los mantenedores suelen responder en 1 día
-
publish.yml: the TestPyPI verification step is unreachable (and installs the wrong package name)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
xqlsystems/xarray-sql#242 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
xqlsystems/xarray-sql#237 ·
Los mantenedores suelen responder en 1 día
Todos los issues de xqlsystems/xarray-sql
Issues similares
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoopAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
doronz88/pymobiledevice3#2051 ·
Los mantenedores suelen responder en 1 día
-
Remove DatacircleAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
collabnix/awesome-mcp-lists#230 ·
Los mantenedores suelen responder en 9 días
-
Groc schedules with out of range values pass config validation and fail later when the scheduler is builtPosiblemente ocupada @auraseb la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
autowarefoundation/autoware_carla_scenario#342 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ianktoo/project-monitor#14 ·