Github user weijietong commented on the issue: https://github.com/apache/drill/pull/889 @arina-ielchiieva your test case can not reproduce the error . You can search the dev email to find the origin error description with the keyword "Drill query planning error". Your query already satisfy the NestedLoopJoinPrule. My case is that I add another rule to change the Aggregate-->Aggregate-->Scan to Scan as the transformed Scan relnode already holding the count(distinct ) value. When this transformation occurs, the NestedLoopJoinPrule's checkPreconditions method will invoke JoinUtils.hasScalarSubqueryInput. Then it will fail, as the transformed relnode has no aggregate node which does not satisfy the current scalar rule. I think it's hard to reproduce this error without a specific rule like what I do. the precondition is: 1. a nested loop join 2. no (aggregate--> aggregate) count distinct relation nodes in the plan 3. the row number of one child of the nested loop join is 1 . I wonder if the enhanced code does not break the current unit test ,it will be ok.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---