Bug 62248 - REPORTBUILDER: multiple groupings on same field broken
Summary: REPORTBUILDER: multiple groupings on same field broken
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
4.1.0.0.alpha0+ Master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyInteresting, easyHack, skillCpp
Depends on:
Blocks: Database-Reports-Builder
  Show dependency treegraph
 
Reported: 2013-03-12 17:28 UTC by Lionel Elie Mamane
Modified: 2021-05-20 14:01 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Shows, how multiple groupings should work (by interval) and what happens with the same group (16.19 KB, application/vnd.sun.xml.base)
2013-08-17 08:49 UTC, Robert Großkopf
Details
Shows where to change the grouping - wont be saved right. (69.34 KB, application/pdf)
2021-05-15 06:26 UTC, Robert Großkopf
Details
screenshot showing how to execute a report without saving it (18.17 KB, image/png)
2021-05-18 06:35 UTC, Lionel Elie Mamane
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lionel Elie Mamane 2013-03-12 17:28:14 UTC
In a reportbuilder report, when grouping on the same field multiple times (with different interval/prefix characters setting), the two groupings interact and in the end it does not work right; both grouping levels behave like one of them.

That's because the report function created by Report Builder for each of the groupings share the same name (!). Have to make that name unique in some way (and possibly switch to a better way of storing that information, the current system is horrible).

Note to people trying to reproduce that: Groupings on interval/prefix characters did not work at all until commit on branch master (4.1.0.0.alpha0+):


commit 4178806bb010129f3b13b62825476666fe48ddcd
Author:     Lionel Elie Mamane <lionel@mamane.lu>
AuthorDate: Tue Mar 12 17:57:57 2013 +0100
Commit:     Lionel Elie Mamane <lionel@mamane.lu>
CommitDate: Tue Mar 12 18:16:45 2013 +0100

    reportbuilder: make "Group on" not-"Each Value" actually work
    
    Change-Id: Id5d73f9aac48ebfb6987e5bf0df37e62f1817bdc


So don't bother trying with anything older than that.
Comment 1 Lionel Elie Mamane 2013-03-12 17:39:06 UTC
Code pointers:

File reportdesign/source/filter/xml/xmlExport.cxx
function ORptExport::exportGroupsExpressionAsFunction
That's where the name is chosen. Need to make it unique somehow.

Please choose a naming scheme that is predictable and stable. I mean:
 - the user that happens to know LibreOffice's implementation details knows
   what the function name is just from the grouping information
 - stable: does not change as long as the grouping information does not change

Take care that in file reportdesign/source/filter/xml/xmlGroup.cxx
function OXMLGroup::OXMLGroup
parses back what ORptExport::exportGroupsExpressionAsFunction
creates. You need to keep that in sync *but* take care of
backwards compatibility! That code needs to be able to parse
old files, that is what *old* versions of ORptExport::exportGroupsExpressionAsFunction
were creating, as well as new files.

Rather than piling up fragility in this parsing, you might want to actually take the occasion to clean up this mess by actually storing the values chosen by the user in the UI directly (in new attributes of the <group> node). See the introduction of sort-expression in commit 4178806bb010129f3b13b62825476666fe48ddcd to see what I mean. For backwards compatibility, if the new clean way is not present, fall back to parsing the group-expression attribute.
Comment 2 Alex Thurgood 2013-04-24 16:47:42 UTC
This situation, i.e. where I attempt to define, e.g. an accumulation function on the same field in both the Group Footer and Detail sections of the report,  appears to cause a mutex lock / race condition on Mac OSX, requiring a force kill of the office for all versions I have tested so far :

3.5.7 - beachball requiring force kill
3.6.5.2 - direct SIGABRT
4.0.2.2 - beachball requiring force kill
Version 4.1.0.0.alpha0+ (Build ID: 44019e1c9a6b2072c70de121d15ad477e38cacb)



Alex
Comment 3 Robert Großkopf 2013-08-17 08:49:49 UTC
Created attachment 84162 [details]
Shows, how multiple groupings should work (by interval) and what happens with the same group
Comment 4 Björn Michaelsen 2013-10-04 18:46:13 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 5 Alex Thurgood 2015-01-03 17:39:56 UTC Comment hidden (no-value)
Comment 6 Robinson Tryon (qubit) 2015-12-14 05:03:42 UTC Comment hidden (obsolete)
Comment 7 Robinson Tryon (qubit) 2016-02-18 14:51:26 UTC Comment hidden (obsolete)
Comment 8 Matt K 2021-05-14 06:20:58 UTC
Unable to see the problem -- the attachment shows reports in Base, but trying to open the Bug62248 report shows an error stating:

"The document "Bug62248" could not be opened. Column not found: INT_INT_count_Number in statement [SELECT * FROM "Bill" ORDER BY "Number", "INT_INT_count_Number", "Number"]"

Can you please upload a new document, and please provide instructions on how to exactly see the problem?  I see intervals in the group settings the same field field but am not sure how to see what the grouping level is supposed to show.
Comment 9 Lionel Elie Mamane 2021-05-14 08:34:58 UTC
It looks like the report is corrupted on saving or loading :-(

edit the report "Bug62248"
menu view / Sorting and Grouping
second line, column "Field/Expression", INT_INT_count_Number" to "Number"
with that second line selected, change properties:
 Group On: Interval
 Group Interval: 5
close "sorting and grouping" dialog
in toolbar, click "execute report" button
compare the result with "Bug62248_should_be". They are different. They should be the same.
Comment 10 Matt K 2021-05-14 21:42:53 UTC
I tried editing the report but got an error stating:
"An error occurred while creating the report." after executing the report.  Do you know how to fix it, and should the output of the report exactly match the "should_be" report, or just some part of it?
Comment 11 Robert Großkopf 2021-05-15 06:26:20 UTC
Created attachment 172017 [details]
Shows where to change the grouping - wont be saved right.

The added screenshot will show where to change the grouping and where to set the interval the right way.
You could execute the report while editing the report. If you save the report it will show the same behavior as the report in the database I created. The second groupname will be changed and the report couldn't be executed.
Comment 12 Robert Großkopf 2021-05-15 06:32:05 UTC
(In reply to Matt K from comment #10)
> should the output of the report exactly match
> the "should_be" report, or just some part of it?

It has to exactly the same. 
Interval Number 10: 10 Numbers should appear after this group header.
Interval Number 5: 5 Numbers should appear after this group header.
Each Value Number: After changing the value of the number this group header should appear for the next value.
Comment 13 Matt K 2021-05-17 20:35:02 UTC
I tried editing and saving the report but still get an error stating:

"Column not found: INT_INT_count_Number in statement [SELECT * FROM "Bill" ORDER BY "Number", "INT_INT_count_Number", "Number"]"

Is there anything else I need to change in the report to get it to work?
Comment 14 Lionel Elie Mamane 2021-05-18 06:35:21 UTC
Created attachment 172108 [details]
screenshot showing how to execute a report without saving it

(In reply to Matt K from comment #13)
> I tried editing and saving the report but still get an error stating:
> 
> "Column not found: INT_INT_count_Number in statement [SELECT * FROM "Bill"
> ORDER BY "Number", "INT_INT_count_Number", "Number"]"
> 
> Is there anything else I need to change in the report to get it to work?

Don't save the report. Run it from its modification window. See this screenshot (red arrow).
Comment 15 Lionel Elie Mamane 2021-05-18 06:37:13 UTC
(or menu Tools / Execute report)
Comment 16 Matt K 2021-05-19 22:03:02 UTC
I did what the screenshot showed and still got an error.  What version are you running on?
Comment 17 Robert Großkopf 2021-05-20 14:01:52 UTC
(In reply to Matt K from comment #16)
> I did what the screenshot showed and still got an error.  What version are
> you running on?

Yo have to open the report and change the second group. Then execute the report. Every time you save the report close it and reopen it the code will be wrong code.

Its the same behavior with every LO-installation here. LO 7.1.3.2 at this moment for OpenSUSE 15.2 64bit rpm Linux.