GROUP with duplicate (equal) BY expressions fails with AssertionError (v6 -> master regression)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Start with LogicsModule.mapLGProp and the GroupProperty reverse-interface mapping, then inspect AddGroupProperty.getGroupKeys, OrderGroupProperty.getGroupKeys, and mapSelectTop. Reproduce the minimal lsf GROUP SUM case and verify startup succeeds with duplicate BY expressions, including the SUM/MAX and CONCAT/LAST paths described in the issue.
Written by the indexing model from the issue text.
Description
Problem
A GROUP property with duplicate (textually equal) BY expressions crashes the logics startup with an AssertionError (or an NPE if -ea is disabled). The same logics starts fine on v6, so this is a v6 -> master regression.
Minimal repro:
CLASS Order;
price = DATA NUMERIC[10,2] (Order);
quantity = DATA NUMERIC[10,2] (Order);
quantityOut(NUMERIC[10,2] p, NUMERIC[10,2] c) = GROUP SUM quantity(Order o) BY price(o), price(o);
java.lang.AssertionError
at lsfusion.base.col.implementations.abs.AMap.toRevExclMap(...)
at lsfusion.server.logics.LogicsModule.mapLGProp(...)
at lsfusion.server.logics.LogicsModule.addSGProp(...)
Real-world case: a report property grouping by a price expression that is (legitimately) passed twice — once as the price output and once as the cost output:
quantityOut(Article a, Sort s, NUMERIC[7,2] p, NUMERIC[16,5] c) <-
[GROUP SUM Sale.quantity(Sale.ShipmentDetail l) IF ... BY article(Sale.sku(l)), sort(Sale.sku(l)), Sale.price(l), Sale.price(l)](a, s, p, c);
Cause
Since b082332c2c (#1489) equal BY expressions produce equal (hashEquals) PropertyInterfaceImplements. The group property still creates a distinct interface per BY position (GroupProperty.Interface equality is identity-based), but its interface -> key mapping is no longer injective, so every toRevExclMap() over that mapping now fails its bijection assertion:
LogicsModule.mapLGProp— at construction of the resultingLP(the startup crash above);AddGroupProperty.getGroupKeys— the value-pushing optimization on the SUM/MAX calc path;OrderGroupPropertyconstructor (mapSelectTop,getMapRevInterfaces()is called unconditionally, even with an emptySELECT TOP) andOrderGroupProperty.getGroupKeys— the CONCAT/LAST paths.
On v6 the equal BY expressions were distinct objects, so all these reverse maps stayed bijective by accident.
Semantically the duplicate keys are valid and were supported on v6: GROUP BY price, price ≡ GROUP BY price, with both outer interfaces reading (and being equated to) the same group column.
Fix
Make the group machinery tolerant to duplicate (equal, and therefore interchangeable) group keys instead of requiring bijection:
LogicsModule.mapLGPropmatches the interfaces to the implement list positionally when duplicates are present (the plain bijective path is kept otherwise);GroupProperty.getMergeMapRevInterfaces()— a merge-based (non-exclusive) reverse ofgetMapInterfaces, used byAddGroupProperty.getGroupKeys,OrderGroupProperty.getGroupKeysandmapSelectTop. Any of the equal interfaces works there: equal keys read equal group exprs, and both outer equality conditions are still applied byGroupExpr.createthroughjoinImplement.
- Dominant language
- Java
- Stars
- 214
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsfusion/platform
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in lsfusion/platform
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100