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

Aperta
#1,973 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, sql
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
214
Fork
46
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lsfusion/platform

Tutte le issue di lsfusion/platform

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.