Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse aggregates in column order #1432

Merged
merged 3 commits into from
May 29, 2021
Merged

Parse aggregates in column order #1432

merged 3 commits into from
May 29, 2021

Conversation

sc1f
Copy link
Contributor

@sc1f sc1f commented May 27, 2021

This PR fixes a bug where column names that could be parsed as numbers (like the expression 1234) did not respond correctly to column ordering and would be the first column in a pivoted view:

Screen Shot 2021-05-27 at 3 03 32 PM 2

This was due to the way that aggregates were parsed in the C++, which happened in three separate iterations:

  1. Iterate through the columns array, and generate default aggregates for all columns not in the aggregate map
  2. Iterate through the aggregate map (using the order generated by Object.keys()), and apply specified aggregates for all aggregate columns in the columns array
  3. Generate aggregates for hidden sort columns.

I'm not sure exactly why I wrote the parsing logic the way that I did (in 2019, IIRC), but the issue it causes is simple: by ignore the column order when parsing the aggregates map, it assumes that the aggregates map can be iterated in the same order as columns.

However, in Javascript, in an object with a string key that is parsable as an integer (like "1234"), when iterating through the object using Object.keys(), the integer-parsable key is automatically moved to the front of the iteration order, and multiple integer-parsable keys are ordered in ascending order. More details here.

An example of this behavior is as follows:

Screen Shot 2021-05-27 at 10 32 28 PM

This behavior does not seem to happen when the keys are parsable as floats ("4.5" and "5.55555", for example, remain in insertion order). Thus, the assumption that the aggregates map is ordered properly is broken, and so goes the column order. The fix is to rewrite the aggregate parsing logic to use the column order while iterating, and access the aggregates map through the column order instead of the order given by Object.keys().

I also removed the unimplemented and and or filters for boolean columns from the UI - though boolean columns are less common, selecting those would have caused an abort().

@sc1f sc1f added this to the 0.9.0 milestone May 27, 2021
@sc1f sc1f added bug Concrete, reproducible bugs C++ labels May 27, 2021
Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the PR!

@texodus texodus merged commit 99d9601 into master May 29, 2021
@texodus texodus deleted the ui-fixes branch May 29, 2021 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Concrete, reproducible bugs C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants