Skip to content

Conversation

@viirya
Copy link
Member

@viirya viirya commented Dec 29, 2021

Which issue does this PR close?

Closes #1479.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

input,
group_expr: _,
aggr_expr,
schema: _,
Copy link
Member

Choose a reason for hiding this comment

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

i guess you can use .. to ignore these fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

yea. i will use it.

}

/// Rewrite sort on aggregate expressions to sort on the column of aggregate output
#[inline]
Copy link
Member

Choose a reason for hiding this comment

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

why would this need to be inlined? or can't the compiler infer that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I saw there is #[inline] for normalize_cols above. rewrite_sort_cols_by_aggs's looks similar (i.e., into_iter().map().collect()), so I added it too here. Should I remove it?

Copy link
Member

@xudong963 xudong963 Dec 31, 2021

Choose a reason for hiding this comment

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

In Rust, a unit of (separate) compilation is a crate. If a function f is defined in a crate A, then all calls to f from within A can be inlined, as the compiler has full access to f. If, however, f is called from some downstream crate B, such calls can’t be inlined. B has access only to the signature of f, not its body.

So I think both of them don't need #[inline], let the compiler do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, removed.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

This looks great. Thank you @viirya 🏅

I also played around with it locally and it worked like a charm 👍 .

I had some stylistic suggestions but I also think this PR could be merged as is as well.

];
assert_batches_eq!(expected, &actual);

let sql = "SELECT MIN(c12) FROM aggregate_test_100 ORDER BY MIN(c12) + 0.1";
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@viirya
Copy link
Member Author

viirya commented Dec 31, 2021

Thank you @alamb . Committed the suggestions.

@alamb alamb merged commit 7607ace into apache:master Jan 1, 2022
@alamb
Copy link
Contributor

alamb commented Jan 1, 2022

Thanks again @viirya !

@viirya
Copy link
Member Author

viirya commented Jan 1, 2022

Thank you @alamb @jimexist @xudong963 !

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.

ORDER BY min(x) results in error Plan("No field named 'foo.x'. Valid fields are 'MIN(foo.x)'.")

4 participants