Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4a4137f
trying to resolve literals.
codebird May 10, 2019
30a26aa
Merge branch 'master' into issue#41413
codebird May 10, 2019
efb879b
more fixing.
codebird May 11, 2019
7393a3d
fixing the case where a Literal or function is selected but with an a…
codebird May 13, 2019
36087a5
solving 34583 in a rather hacky way
codebird May 14, 2019
710451b
fixing tests.
codebird May 15, 2019
4909761
Merge branch 'master' into issue#41413
codebird May 16, 2019
6702e05
fixing integ tests.
codebird May 17, 2019
b4542cc
Merge branch 'master' into issue#41413
codebird Jun 5, 2019
9cea6c6
Merge branch 'master' into issue#41413
codebird Nov 3, 2019
be4f767
merging and fixing conflicts.
codebird Nov 3, 2019
985f3a5
Merge branch 'master' into issue#41413
codebird Feb 5, 2020
eb95d94
Merging master and updating code after #49570 was merged
codebird Feb 5, 2020
676fd87
Merge remote-tracking branch 'origin/issue#41413' into issue#41413
codebird Feb 5, 2020
863e687
fixing selecting literal with grouping.
codebird Feb 7, 2020
a32a2df
changing based on from @matriv
codebird Feb 7, 2020
cf2f4b0
adding tests, integrity tests, and fixed code after 1 integrity test …
codebird Feb 8, 2020
c6efce8
removing un-needed if.
codebird Feb 9, 2020
374636e
Merge branch 'master' into issue#41413
codebird Feb 9, 2020
d1d640b
merging master, and changes based on @matriv review.
codebird Feb 10, 2020
79e0256
changes based on @matriv review.
codebird Feb 12, 2020
20bdbb6
getting rid of LiteralId, and adding space between if and (
codebird Feb 12, 2020
f40a30f
style fixes.
codebird Feb 13, 2020
92b11bb
Merge branch 'master' into issue#41413
codebird Feb 13, 2020
90de3e5
styling.
codebird Feb 13, 2020
488350a
adding integration test.
codebird Feb 14, 2020
12cb20c
update based on @matriv recommendation.
codebird Feb 14, 2020
196d30b
reverting formatting changes.
codebird Feb 14, 2020
a13cf7e
reverting formatting changes.
codebird Feb 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,6 @@ else if (plan instanceof Aggregate) {
List<Expression> newGroupings = new ArrayList<>();
AttributeMap<Expression> resolved = Expressions.aliases(a.aggregates());

final Holder<Boolean> updateResolved = new Holder<Boolean>(Boolean.FALSE);
a.aggregates().forEach(e -> e.forEachUp(f -> {
if (f instanceof Function == false && f.foldable() == false) {
updateResolved.set(Boolean.TRUE);
}
}));
if (updateResolved.get()) {
var allFields = plan.inputSet().stream().map(NamedExpression.class::cast)
.collect(toList());
allFields.addAll(a.aggregates());
resolved = Expressions.asAttributeMap(allFields);
}
boolean changed = false;
for (Expression grouping : groupings) {
if (grouping instanceof UnresolvedAttribute) {
Expand Down Expand Up @@ -632,8 +620,7 @@ protected LogicalPlan rule(LogicalPlan plan) {
maybeResolved.add(or.resolved() ? or : tryResolveExpression(or, child));
}

Stream<Order> referencesStream = maybeResolved.stream()
.filter(Expression::resolved);
Stream<Order> referencesStream = maybeResolved.stream().filter(Expression::resolved);

// if there are any references in the output
// try and resolve them to the source in order to compare the source expressions
Expand Down Expand Up @@ -706,8 +693,7 @@ protected LogicalPlan rule(LogicalPlan plan) {
Expression maybeResolved = tryResolveExpression(f.condition(), f.child());

AttributeSet resolvedRefs = new AttributeSet(maybeResolved.references().stream()
.filter(Expression::resolved)
.collect(toList()));
.filter(Expression::resolved).collect(toList()));

AttributeSet missing = resolvedRefs.subtract(f.child().outputSet());

Expand All @@ -719,8 +705,9 @@ protected LogicalPlan rule(LogicalPlan plan) {
// resolution failed and the failed expressions might contain resolution information so copy it over
if (!failedAttrs.isEmpty()) {
// transform the orders with the failed information
Expression transformed = f.condition().transformUp(ua -> resolveMetadataToMessage(ua, failedAttrs, "filter"),
UnresolvedAttribute.class);
Expression
transformed =
f.condition().transformUp(ua -> resolveMetadataToMessage(ua, failedAttrs, "filter"), UnresolvedAttribute.class);

return f.condition().equals(transformed) ? f : new Filter(f.source(), f.child(), transformed);
}
Expand All @@ -733,6 +720,19 @@ protected LogicalPlan rule(LogicalPlan plan) {
}
}

// Try to resolve aggregates and groupings based on the child plan
if (plan instanceof Aggregate) {
Aggregate a = (Aggregate) plan;
LogicalPlan child = a.child();
List<Expression> newGroupings = new ArrayList<>(a.groupings().size());
a.groupings().forEach(e -> newGroupings.add(tryResolveExpression(e, child)));
List<NamedExpression> newAggregates = new ArrayList<>(a.aggregates().size());
a.aggregates().forEach(e -> newAggregates.add(tryResolveExpression(e, child)));
if (newAggregates.equals(a.aggregates()) == false || newGroupings.equals(a.groupings()) == false) {
return new Aggregate(a.source(), child, newGroupings, newAggregates);
}
}

return plan;
}

Expand Down