You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullPointerException compiling a GROUP that reaches one query through joins built under different statistics #1973
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.
Activity