Return-Path: X-Original-To: apmail-drill-issues-archive@minotaur.apache.org Delivered-To: apmail-drill-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2BA517D6A for ; Thu, 3 Mar 2016 06:35:18 +0000 (UTC) Received: (qmail 85177 invoked by uid 500); 3 Mar 2016 06:35:18 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 85131 invoked by uid 500); 3 Mar 2016 06:35:18 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 85116 invoked by uid 99); 3 Mar 2016 06:35:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 06:35:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 5141D2C0453 for ; Thu, 3 Mar 2016 06:35:18 +0000 (UTC) Date: Thu, 3 Mar 2016 06:35:18 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-4465) Refactor Parsing and Planning to canonicalize planning and parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DRILL-4465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15177329#comment-15177329 ] ASF GitHub Bot commented on DRILL-4465: --------------------------------------- Github user jacques-n commented on a diff in the pull request: https://github.com/apache/drill/pull/401#discussion_r54840955 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java --- @@ -273,12 +282,90 @@ public RelNode visit(RelNode other) { } + /** + * Transform RelNode to a new RelNode without changing any traits. Also will log the outcome. + * + * @param plannerType + * The type of Planner to use. + * @param phase + * The transformation phase we're running. + * @param input + * The origianl RelNode + * @return The transformed relnode. + */ + private RelNode transform(PlannerType plannerType, PlannerPhase phase, RelNode input) { + return transform(plannerType, phase, input, input.getTraitSet()); + } + + /** + * Transform RelNode to a new RelNode, targeting the provided set of traits. Also will log the outcome. + * + * @param plannerType + * The type of Planner to use. + * @param phase + * The transformation phase we're running. + * @param input + * The origianl RelNode + * @param targetTraits + * The traits we are targeting for output. + * @return The transformed relnode. + */ + protected RelNode transform(PlannerType plannerType, PlannerPhase phase, RelNode input, RelTraitSet targetTraits) { + final Stopwatch watch = Stopwatch.createStarted(); + final RuleSet rules = config.getRules(phase); + final RelTraitSet toTraits = targetTraits.simplify(); + + final RelNode output; + switch (plannerType) { + case HEP_BOTTOM_UP: + case HEP: { + final HepProgramBuilder hepPgmBldr = new HepProgramBuilder(); + if (plannerType == PlannerType.HEP_BOTTOM_UP) { + hepPgmBldr.addMatchOrder(HepMatchOrder.BOTTOM_UP); + } + for (RelOptRule rule : rules) { + hepPgmBldr.addRuleInstance(rule); + } + + final HepPlanner planner = new HepPlanner(hepPgmBldr.build(), context.getPlannerSettings()); + + final List list = Lists.newArrayList(); + list.add(DrillDefaultRelMetadataProvider.INSTANCE); + planner.registerMetadataProviders(list); + final RelMetadataProvider cachingMetaDataProvider = new CachingRelMetadataProvider( + ChainedRelMetadataProvider.of(list), planner); + + // Modify RelMetaProvider for every RelNode in the SQL operator Rel tree. + input.accept(new MetaDataProviderModifier(cachingMetaDataProvider)); + planner.setRoot(input); + if (!input.getTraitSet().equals(targetTraits)) { + planner.changeTraits(input, toTraits); + } + output = planner.findBestExp(); + break; + } + case VOLCANO: + default: { + // as weird as it seems, the cluster's only planner is the volcano planner. + final RelOptPlanner planner = input.getCluster().getPlanner(); --- End diff -- Since we control the construction of the cluster, this isn't currently possible. However, since cluster is created in DrillSQLParser and used here, that could change in future. Will add check. > Refactor Parsing and Planning to canonicalize planning and parsing > ------------------------------------------------------------------ > > Key: DRILL-4465 > URL: https://issues.apache.org/jira/browse/DRILL-4465 > Project: Apache Drill > Issue Type: Sub-task > Components: Query Planning & Optimization > Reporter: Jacques Nadeau > Assignee: Jinfeng Ni > Fix For: 1.6.0 > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)