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

[timeseries] Fix Time Series Query Correctness Issue #14251

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ankitsultana
Copy link
Contributor

@ankitsultana ankitsultana commented Oct 18, 2024

While testing the time series engine in our cluster we found an undercount issue. This is likely because the AggregationOperator was not pulling all the docs matched by the filter.

This PR fixes that by calling nextBlock in a loop.

Test Plan: Updated the existing UT so that it was able to detect this bug. To do this, the following was done:

  • I updated the existing Avro file to one which has 30k rows. The existing one had 10k rows, which is not enough because DocIdSetOperator returns 10k rows per project/transform operator call.
  • Updated the test so that it queries the entire range, and runs a sum(orderAmount) over the entire data, with a single time bucket. The corresponding result was verified with CH.

CH Query for loading and testing the new sample data:

> CREATE TABLE fakeEatsTable (cityName String, restaurantUUID String, orderAmount Int32, orderItemCount Int32, orderCreatedTimestamp Int64) ENGINE = MergeTree PRIMARY KEY restaurantUUID;
...
> INSERT INTO fakeEatsTable FROM INFILE '/path/to/sampleEatsData.avro' FORMAT Avro;
...
> INSERT INTO fakeEatsTable FROM INFILE '/path/to/sampleEatsData.avro' FORMAT Avro;
...
> INSERT INTO fakeEatsTable FROM INFILE '/path/to/sampleEatsData.avro' FORMAT Avro;
...
> select 2 * sum(orderAmount) from fakeEatsTable;

SELECT 2 * sum(orderAmount)
FROM fakeEatsTable

Query id: d7f957cc-9a43-4b5b-9880-4fba411b8e9b

┌─multiply(2, sum(orderAmount))─┐
│                      29885544 │
└───────────────────────────────┘

1 row in set. Elapsed: 0.007 sec.

image

@ankitsultana ankitsultana added the timeseries-engine Tracking tag for generic time-series engine work label Oct 18, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 15 lines in your changes missing coverage. Please review.

Project coverage is 63.76%. Comparing base (59551e4) to head (4f704d3).
Report is 1204 commits behind head on master.

Files with missing lines Patch % Lines
...ator/timeseries/TimeSeriesAggregationOperator.java 44.44% 12 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14251      +/-   ##
============================================
+ Coverage     61.75%   63.76%   +2.00%     
- Complexity      207     1536    +1329     
============================================
  Files          2436     2626     +190     
  Lines        133233   144658   +11425     
  Branches      20636    22139    +1503     
============================================
+ Hits          82274    92234    +9960     
- Misses        44911    45621     +710     
- Partials       6048     6803     +755     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.70% <44.44%> (+1.99%) ⬆️
java-21 63.64% <44.44%> (+2.02%) ⬆️
skip-bytebuffers-false 63.72% <44.44%> (+1.97%) ⬆️
skip-bytebuffers-true 63.62% <44.44%> (+35.89%) ⬆️
temurin 63.76% <44.44%> (+2.00%) ⬆️
unittests 63.75% <44.44%> (+2.00%) ⬆️
unittests1 55.44% <44.44%> (+8.55%) ⬆️
unittests2 34.30% <0.00%> (+6.57%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
int[] timeValueIndexes = getTimeValueIndex(timeValues, _storedTimeUnit);
Object[][] tagValues = new Object[_groupByExpressions.size()][];
ValueBlock valueBlock;
Map<Long, BaseTimeSeriesBuilder> seriesBuilderMap = new HashMap<>(1024);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we increase the limit of 1k series Builder Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the initial capacity and the map may grow beyond this based on the default lf (0.75 by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix timeseries-engine Tracking tag for generic time-series engine work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants