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

[Calcite 1758] push order and limit to druid #433

Closed
wants to merge 2 commits into from

Conversation

b-slim
Copy link
Contributor

@b-slim b-slim commented Apr 18, 2017

No description provided.

@b-slim
Copy link
Contributor Author

b-slim commented Apr 18, 2017

@jcamachor

.multiplyBy(getQueryTypeCostMultiplier());
.multiplyBy(getQueryTypeCostMultiplier())
// a plan with sort pushed to druid is better than doing sort outside of druid
.multiplyBy(Util.last(rels) instanceof Bindables.BindableSort ? 0.1 : 0.2);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use the superclass in case other rules do not generate a Sort with bindable convention, i.e., use instanceof Sort instead of BindableSort.

Further, if last operator is not a SortLimit, we should just leave cost as it is, i.e., multiply by 1 instead of 0.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}
if (originalFieldName.equals(druidTable.timestampFieldName)) {
finalGranularity = Granularity.ALL;
String extractColumnName = SqlValidatorUtil.uniquify(EXTRACT_COLUMN_NAME_PREFIX
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool!

@@ -590,32 +589,21 @@ private static boolean validSortLimit(Sort sort, DruidQuery query) {
int metricsRefs = 0;
for (RelFieldCollation col : sort.collation.getFieldCollations()) {
int idx = col.getFieldIndex();
//computes the number of metrics in the sort
if (idx >= topAgg.getGroupCount()) {
metricsRefs++;
Copy link
Contributor

Choose a reason for hiding this comment

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

metricsRefs is not used anymore (and it seems it is not needed). If it became useless, could we get rid of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

+ "EnumerableInterpreter\n"
+ " BindableSort(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[DESC], offset=[2], fetch=[3])\n"
+ " DruidQuery(table=[[foodmart, foodmart]], intervals=[[1900-01-09T00:00:00.000/2992-01-10T00:00:00.000]], projects=[[$39, $30]], groups=[{0, 1}], aggs=[[]])";
final String explain = "PLAN=EnumerableLimit(offset=[2], fetch=[3])\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we do not push the limit because of the offset? In that case, we could just push the fetch part and keep the offset/limit on top of the DruidQuery as it is right now, I think that would still be beneficial. Since this is not a blocker, we could tackle that in a follow-up. Could you create a JIRA case to keep track of the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i guess this can be tricky, since druid does not support offsets -> i need to alter the limit and return let say 5 instead of 3 and let calcite do the offset ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly, that is what I meant. But in any case, it can be part of a follow-up as this patch is almost ready; we can create the issue and tackle later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@b-slim
Copy link
Contributor Author

b-slim commented Apr 19, 2017

@jcamachor fixed all the comments thanks !

@asfgit asfgit closed this in cd13698 Apr 19, 2017
lucesape pushed a commit to repairnator/repairnator-experiments that referenced this pull request Apr 25, 2017
lucesape pushed a commit to repairnator/repairnator-experiments that referenced this pull request Apr 25, 2017
7mming7 pushed a commit to Kyligence/calcite that referenced this pull request Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants