NullPointerException compiling a GROUP that reaches one query through joins built under different statistics

Abierto
#1,973 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java, sql

Línea de trabajo

Start by tracing GroupExpr.getInnerJoin and how group joins are matched and compiled into subqueries; the issue identifies GroupSelect.getSQLQuery and CompiledQuery$InnerSelect$QuerySelect.getSQLQuery in the failure path. Reproduce the empty select with group joins built under different statistics, then confirm those joins compile to one subquery and the query succeeds.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Description

In one compiled query the same GROUP can come through two group joins that differ only in the joins GroupExpr.getInnerJoin builds from the current statistics. This happens, for example, when changes in the session alter the statistics between the moments two instances of the same GROUP expression get their join. One of them is an inner join of the query and the expression goes through the other. They are not matched, so the select made for the inner join gets no expressions, compiles to an empty select with untyped keys and fails:

active (Item i, Store s, DATE d) = GROUP LAST Rule r ORDER group(r), r
    WHERE dateFrom(group(r)) <= d AND in(group(r), s) AND in(r, i);
active (Batch b, Shop sh, DATE d) = active(item(b), store(sh), d);
price (Batch b, Shop sh) += value(active(b, sh, currentDate())) IF active(b, sh, currentDate());
// in a session where dateFrom(Group) was changed (no APPLY), EXPORT of a form filtered by price:
// java.lang.NullPointerException: Cannot invoke "lsfusion.server.data.type.Type.getCast(String, SQLSyntax, TypeEnvironment)" because "value" is null
//   at CompiledQuery$InnerSelect$QuerySelect.getSQLQuery <- getEmptySelect <- pushWhere <- GroupSelect.getSQLQuery, in Property.readChangeTable

Seen on 6.3 with a real database. Whether it fails depends on the change made in the session and differs from one server restart to another. The same stack is reported in #1958.

Reason

A query that reads correct data fails with an internal error, depending on the statistics, which the developer neither controls nor sees.

Fix

Group joins that differ only in the statistics-built joins compile to one subquery.

Lenguaje dominante
Java
Estrellas
214
Forks
46
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lsfusion/platform

Todos los issues de lsfusion/platform

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.