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

Cost Estimator implementation (DRAFT) #6

Merged
merged 10 commits into from
Jul 15, 2021
Merged

Cost Estimator implementation (DRAFT) #6

merged 10 commits into from
Jul 15, 2021

Conversation

chernokoz
Copy link
Collaborator

На ModifiedCalciteQueryPlanner можно не смотреть - это копия кода Никиты из его PR.

Итоговая цель - вызывая getCumulativeCost с разными провайдерами, получить разную стоимость.

@@ -0,0 +1,71 @@
package com.flamestream.optimizer.sql.agents;

import com.flamestream.optimizer.testutils.TestPipelineOptions;
Copy link
Member

Choose a reason for hiding this comment

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

Забыл добавить.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ага, добавил сейчас

}

public static BeamRelNode getSecondQueryPlan() {
return getNEXMarkQueryPlan(QUERY_2);
Copy link
Member

Choose a reason for hiding this comment

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

VolcanoPlanner все равно оптимизует этот план из ожидаемого ((Person x Bid) x Auction) в (Bid x (Person x Auction)). Если выкинуть правила JoinAssociateRule и JoinPushThroughJoinRule, то получаются ожидаемые планы и разные стоимости.

Copy link
Member

Choose a reason for hiding this comment

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

Также помогает уменьшить количество уникальных Person.id/Auction.seller с тысячи до десяти.

@chernokoz chernokoz requested a review from faucct June 21, 2021 15:41
@chernokoz
Copy link
Collaborator Author

Добавил SqlQueryInspector и SqlQueryInspectorTest


if (left instanceof BeamIOSourceRel) {
// left is a non-recursive subquery
map.put(left, fieldsList.get(firstRexInput.getIndex()).getName());
Copy link
Member

Choose a reason for hiding this comment

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

Такой подход перестанет работать сразу же, как только beam вставит между таблицей и джойном проекцию. Надёжнее будет завести в inspectSubquery отдельный параметр с множеством интересных колонок у node: ImmutableBitSet interestingColumns.

@chernokoz
Copy link
Collaborator Author

Да, ImmutableBitSet тут самое то, мне все нравится!

.setRowSchema(auctionsWithReceiveTime)
.setRowSchema(auctionsWithReceiveTime);

Schema peoplesWithReceiveTime = Schema.builder()
Copy link
Collaborator

Choose a reason for hiding this comment

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

peoples это "народы", в рамках лингвистического занудства предлагаю просто people

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Поправил)


import java.util.HashMap;

public class SqlQueryInspector {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Давайте писать javadoc'и к классам, а то тут и не догадаешься, что делает этот замечательный класс.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Добавил

for (Map.Entry<TupleTag<?>, PValue> input : withTags.expand().entrySet()) {
PCollection<?> pCollection = (PCollection<?>) input.getValue();
BeamPCollectionTable<?> table;
table = new BeamPCollectionTable(pCollection);
Copy link
Collaborator

Choose a reason for hiding this comment

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

а если сделать BeamPCollectionTable<>(...), то IDEA перестанет выдавать warning :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Да, пофиксил, уже котлин засел плотно в голову видимо)

@chernokoz chernokoz merged commit 2f2a6cb into main Jul 15, 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
Development

Successfully merging this pull request may close these issues.

4 participants