`split_part` with position 0 errors on a NULL string only when the position is a literal
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend, databases, testing-qa
Línea de trabajo
Start with datafusion/functions/src/string/split_part.rs, especially the fast path and the array path identified in the issue, then review the expr.slt case around the reported test. Decide how the fast path should behave when every string is NULL, using the stated PostgreSQL strictness expectation and the prior review discussion as context. Update the regression test to reflect the chosen behavior and verify the literal and column position cases agree.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
split_part(s, delimiter, 0) on a row where s is NULL returns NULL when the position comes from a column, and errors with "field position must not be zero" when the position is a literal. The fast path for an array string with a scalar delimiter and position rejects position 0 before it looks at any row. The array path skips rows where any argument is NULL, so it errors only on a row whose three arguments are all non-NULL. The two paths disagree whenever no row has a non-NULL string, such as a batch whose strings are all NULL.
To Reproduce
-- Literal delimiter and position: the fast path
SELECT split_part(s, '.', 0) AS r FROM (VALUES (NULL::text)) AS t(s);
-- Execution error: field position must not be zero
-- The same row with the position from a column: the array path
SELECT split_part(s, '.', p) AS r FROM (VALUES (NULL::text, 0)) AS t(s, p);
-- NULL
-- Only literals
SELECT split_part(NULL::text, '.', 0) AS r;
-- NULL
Expected behavior
All three return NULL. PostgreSQL's split_part is strict: its pg_proc entry leaves proisstrict at its default of true, so a NULL argument returns NULL without calling the function.
expr.slt expects the first query's error ("Position 0 with column input errors even for empty/null inputs"), while the review of #21238 asked for the fast path to match the array path (discussion_r3030106101). Which behavior is intended? If it is NULL, the fast path could return all NULLs when the string array has no valid row before checking the position, and the expr.slt case would expect NULL.
Additional context
Property-based tests found this on main at 14b3edd9a3: calling split_part with an array string and scalar delimiter and position gave an error, and the same call with every argument as an array gave NULL. The reproduction runs on main at 14b3edd9a3. The fast path came with #21238.
- Lenguaje dominante
- Rust
- Estrellas
- 9.6k
- Forks
- 2.6k
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 345
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 apache/datafusion
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#27315 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/datafusion#27094 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlPosiblemente ocupada @jonasHanhan la tomó hace 9 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/datafusion#27059 ·
Los mantenedores suelen responder en 1 día
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsPosiblemente ocupada @joseph-isaacs la tomó hace 9 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#27050 ·
Los mantenedores suelen responder en 1 día
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsPosiblemente ocupada @geoHeil la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/datafusion#26999 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion
Issues similares
-
area:schema documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ElectronicWave/Elemental#252 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dekobon/big-code-analysis#1887 ·
Los mantenedores suelen responder en 1 día
-
Shell中文符号输入异常Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día