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

Support transform functions with AVG aggregation function #4557

Merged
merged 2 commits into from
Aug 24, 2019

Conversation

siddharthteotia
Copy link
Contributor

Support queries like:

SELECT AVG(SUB(col1, col2) FROM foo
SELECT AVG(SUB(DIV(col1, col2), DIV(col3, col4))) FROM foo

They were failing in AvgAggregationFunction as TransformBlockValSet() did not implement getValueType() method

Also added operand checks for transform functions for acceptable data types

Testing:

Added TransformQueriesTest to test both inner-segment and inter-segment, inter-server queries with custom data

@siddharthteotia
Copy link
Contributor Author

@Jackie-Jiang , the reason for creating a separate test file is because InnerSegment/InterSegment queries test extend BaseSingleValueQueriesTest and use the entire avro dataset to build test segments.

It is even difficult to predict if the queries are returning correct results since we don't know what data is there in avro files.

So I created a separate test that just extends BaseQueriesTest to get helper methods and created 2 segments with small data to do both inner and inter segment tests and verify correctness


@BeforeClass
public void setup() {
_schema = new Schema();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Schema.Builder to build the schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

private List<SegmentDataManager> _segmentDataManagers;

@BeforeClass
public void setup() {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) We usually use setUp()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

@AfterClass
public void destroy() {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) We usually use tearDown()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

try {
final List<GenericRow> rows = createDataSet(10);

final RecordReader recordReader = new GenericRowRecordReader(rows, _schema);
Copy link
Contributor

Choose a reason for hiding this comment

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

Resource leak, use try-with resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to try with resource but in this case we were not leaking resource as record reader.close() is a NO-OP

final List<GenericRow> segmentTwoRows = createDataSet(10);

final RecordReader recordReaderOne = new GenericRowRecordReader(segmentOneRows, _schema);
final RecordReader recordReaderTwo = new GenericRowRecordReader(segmentTwoRows, _schema);
Copy link
Contributor

Choose a reason for hiding this comment

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

Resource leak, use try-with resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to try with resource but in this case we were not leaking resource as record reader.close() is a NO-OP

}

private void createSegment(
Schema schema,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please reformat the file with the Pinot Style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

FileUtils.deleteQuietly(INDEX_DIR);
}

private void delete() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to destroySegments() for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@codecov-io
Copy link

codecov-io commented Aug 23, 2019

Codecov Report

Merging #4557 into master will increase coverage by 8.42%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4557      +/-   ##
============================================
+ Coverage     56.15%   64.57%   +8.42%     
  Complexity       20       20              
============================================
  Files          1064     1064              
  Lines         55318    55319       +1     
  Branches       8063     8063              
============================================
+ Hits          31062    35722    +4660     
+ Misses        21778    16967    -4811     
- Partials       2478     2630     +152
Impacted Files Coverage Δ Complexity Δ
...core/operator/docvalsets/TransformBlockValSet.java 18.75% <100%> (+18.75%) 0 <0> (ø) ⬇️
...nsport/netty/PooledNettyClientResourceManager.java 85.41% <0%> (-4.17%) 0% <0%> (ø)
...ator/transform/function/BaseTransformFunction.java 29.95% <0%> (+0.42%) 0% <0%> (ø) ⬇️
...regation/function/customobject/QuantileDigest.java 58.18% <0%> (+0.44%) 0% <0%> (ø) ⬇️
...ment/creator/impl/SegmentColumnarIndexCreator.java 77.24% <0%> (+0.59%) 0% <0%> (ø) ⬇️
...r/transform/function/ValueInTransformFunction.java 39.2% <0%> (+0.8%) 0% <0%> (ø) ⬇️
.../helix/core/realtime/SegmentCompletionManager.java 70.77% <0%> (+0.86%) 0% <0%> (ø) ⬇️
...e/io/writer/impl/MutableOffHeapByteArrayStore.java 86.45% <0%> (+1.04%) 0% <0%> (ø) ⬇️
.../pinot/core/segment/index/SegmentMetadataImpl.java 80.81% <0%> (+1.22%) 0% <0%> (ø) ⬇️
...rEqualitiesToInClauseFilterQueryTreeOptimizer.java 94.66% <0%> (+1.33%) 0% <0%> (ø) ⬇️
... and 285 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf9974c...4eae986. Read the comment docs.

@siddharthteotia
Copy link
Contributor Author

Addressed the comments

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

LGTM

@mcvsubbu mcvsubbu merged commit 7c7b6cc into apache:master Aug 24, 2019
chenboat pushed a commit to chenboat/incubator-pinot that referenced this pull request Nov 15, 2019
* Support transform functions with AVG aggregation function

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants