-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support in AggregationFuzzer to compare against reference DB for non deterministic functions on unsorted inputs #9009
Conversation
✅ Deploy Preview for meta-velox canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kgpai Looks great % some nits.
@@ -77,6 +77,20 @@ DEFINE_bool( | |||
|
|||
namespace facebook::velox::exec::test { | |||
|
|||
bool AggregationFuzzerBase::isSupportedType(const TypePtr& type) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance to add a comment for it?
referenceQueryRunner_->executeVector( | ||
sql.value(), input, plan->outputType()), | ||
ReferenceQueryErrorCode::kSuccess); | ||
} catch (std::exception& e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::exception&
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt look like we use it, I can just remove it .
sql.value(), input, plan->outputType()), | ||
ReferenceQueryErrorCode::kSuccess); | ||
} catch (std::exception& e) { | ||
// ++stats_.numReferenceQueryFailed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kgpai, thank you for adding this support! I left a few comments.
VELOX_CHECK( | ||
verifier->verify(resultOrError.result), | ||
"Aggregation results failed custom verification"); | ||
if (expectedResult && resultOrError.result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: resultOrError.result != nullptr is already checked at line 1031, so no need to check it again here.
if (resultOrError.result != nullptr) { | ||
if (!customVerification) { | ||
std::optional<MaterializedRowMultiset> expectedResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: simply auto expectedResult = referenceResult.first below would be easier?
"Velox and reference DB results don't match"); | ||
LOG(INFO) << "Verified results against reference DB"; | ||
} | ||
} else if (referenceQueryRunner_->supportsVeloxVectorResults()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check the verifier supports compare here too? And if not, we still call verify()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered only cases where compare is supported, but its still helpful to run against reference even where the verifier only supports verify, for e.g to ensure that the signatures are supported by Presto (if velox supports more signatures). I dont think we lose anything by having it run against Presto.
// Merge all the results into one. | ||
auto results = referenceResult.first.value(); | ||
auto totalCount = 0; | ||
for (const auto& result : results) { | ||
totalCount += result->size(); | ||
} | ||
auto copy = BaseVector::create<RowVector>( | ||
results[0]->type(), totalCount, pool_.get()); | ||
auto copyCount = 0; | ||
for (const auto& result : results) { | ||
copy->copy(result.get(), copyCount, 0, result->size()); | ||
copyCount += result->size(); | ||
} | ||
|
||
expected.result = copy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we extract this into a helper method?
@@ -77,6 +77,20 @@ DEFINE_bool( | |||
|
|||
namespace facebook::velox::exec::test { | |||
|
|||
bool AggregationFuzzerBase::isSupportedType(const TypePtr& type) const { | |||
if (type->isDate() || type->isIntervalDayTime() || type->isUnKnown()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to explain why these types are not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering whether I should make this a property of referenceQueryRunner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they supported in DuckQueryRunner? If so, we cannot make them a property of referenceQueryRunner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ddb doesnt support Timestamp (because of nanosecond precision), and these types arent supported in PQR; so I still feel at some level this should be properties of respective query runner. Let me know what you think.
LOG(INFO) << "Query not supported by the reference DB"; | ||
} | ||
|
||
return std::make_pair( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Move this into the else branch to be with the log statement together?
74e06d1
to
d702f45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@@ -77,6 +77,20 @@ DEFINE_bool( | |||
|
|||
namespace facebook::velox::exec::test { | |||
|
|||
bool AggregationFuzzerBase::isSupportedType(const TypePtr& type) const { | |||
if (type->isDate() || type->isIntervalDayTime() || type->isUnKnown()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they supported in DuckQueryRunner? If so, we cannot make them a property of referenceQueryRunner.
|
||
/// Returns false if the type or its children are unsupported. | ||
/// Currently returns false if type is Date,IntervalDayTime or Unknown. | ||
/// \param type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d702f45
to
f39362e
Compare
@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
f39362e
to
9dee0c6
Compare
@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…non deterministic functions on unsorted inputs (facebookincubator#9009) Summary: **Why** Currently for aggregate functions with custom verifiers, we do not verify plans against the reference db. This is because for these functions the reference db results differ and require us to use custom verifiers - typically the ResultVerifier::compare api. The compare api requires VeloxVectors and previously the results of the reference query runner were in materialized row format and thus couldnt be called. Recently support was added to return the reference db results as velox vectors (facebookincubator#8880). With this we can now validate functions which require custom verifiers. **What** We add support in the AggregationFuzzer to use the new 'executeVector' api if supported by the refrence query runner, and use that to validate non deterministic functions that require a custom verifier. **Results** Currently with this change we have increased the number of plans being verified against reference db from 40 % to 80+%. ``` Total masked aggregations: 78 (14.58%) Total global aggregations: 41 (7.66%) Total group-by aggregations: 392 (73.27%) Total distinct aggregations: 49 (9.16%) Total aggregations over distinct inputs: 40 (7.48%) Total window expressions: 53 (9.91%) Total functions tested: 38 Total iterations requiring sorted inputs: 43 (8.04%) Total iterations verified against reference DB: 448 (83.74%) Total functions not verified (verification skipped / not supported by reference DB / reference DB failed): 53 (9.91%) / 6 (1.12%) / 3 (0.56%) Total failed functions: 27 (5.05%) ``` Experimental runs : https://github.com/facebookincubator/velox/actions/runs/8199583642/job/22443872635 https://github.com/facebookincubator/velox/actions/runs/8199583642/job/22424917125 **Notes** Certain functions have been skiplisted for following reasons: 1. map_union_sum : This requires us to use the lates presto due to a bug on Presto end in version .284 not supporting reals. 2. approx_set: Signatures supported by Velox are more than supported by Presto 3. min_by, max_by: Requires custom verifiers (order by not supported by Presto) 4. any_value: alias for arbitrary but this alias isnt present in Presto. Pull Request resolved: facebookincubator#9009 Reviewed By: kagamiori Differential Revision: D54911135 Pulled By: kgpai fbshipit-source-id: e2fc1fc91a367eb1a3538aa87e755e31ae1018a6
Why
Currently for aggregate functions with custom verifiers, we do not verify plans against the reference db. This is because for these functions the reference db results differ and require us to use custom verifiers - typically the ResultVerifier::compare api. The compare api requires VeloxVectors and previously the results of the reference query runner were in materialized row format and thus couldnt be called. Recently support was added to return the reference db results as velox vectors (#8880). With this we can now validate functions which require custom verifiers.
What
We add support in the AggregationFuzzer to use the new 'executeVector' api if supported by the refrence query runner, and use that to validate non deterministic functions that require a custom verifier.
Results
Currently with this change we have increased the number of plans being verified against reference db from 40 % to 80+%.
Experimental runs :
https://github.com/facebookincubator/velox/actions/runs/8199583642/job/22443872635
https://github.com/facebookincubator/velox/actions/runs/8199583642/job/22424917125
Notes
Certain functions have been skiplisted for following reasons: