beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-4449) Use Calc instead of Project and Filter separately
Date Mon, 17 Sep 2018 22:03:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-4449?focusedWorklogId=145084&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-145084
]

ASF GitHub Bot logged work on BEAM-4449:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Sep/18 22:02
            Start Date: 17/Sep/18 22:02
    Worklog Time Spent: 10m 
      Work Description: akedin commented on a change in pull request #6382: [BEAM-4449] Finish
splitting Aggregate and Project
URL: https://github.com/apache/beam/pull/6382#discussion_r218241789
 
 

 ##########
 File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamAggregationRule.java
 ##########
 @@ -54,29 +61,133 @@ public void onMatch(RelOptRuleCall call) {
 
   private static RelNode updateWindow(RelOptRuleCall call, Aggregate aggregate, Project project)
{
     ImmutableBitSet groupByFields = aggregate.getGroupSet();
-    List<RexNode> projectMapping = project.getProjects();
+    ArrayList<RexNode> projects = new ArrayList(project.getProjects());
 
-    Optional<AggregateWindowField> windowField = Optional.empty();
+    WindowFn windowFn = null;
+    int windowFieldIndex = -1;
 
     for (int groupFieldIndex : groupByFields.asList()) {
-      RexNode projNode = projectMapping.get(groupFieldIndex);
+      RexNode projNode = projects.get(groupFieldIndex);
       if (!(projNode instanceof RexCall)) {
         continue;
       }
 
-      windowField = AggregateWindowFactory.getWindowFieldAt((RexCall) projNode, groupFieldIndex);
+      RexCall rexCall = (RexCall) projNode;
+      WindowFn fn = createWindowFn(rexCall.getOperands(), rexCall.op.kind);
+      if (fn != null) {
+        windowFn = fn;
+        windowFieldIndex = groupFieldIndex;
+        projects.set(groupFieldIndex, rexCall.getOperands().get(0));
+      }
     }
 
+    final Project newProject =
+        project.copy(project.getTraitSet(), project.getInput(), projects, project.getRowType());
+
     return new BeamAggregationRel(
         aggregate.getCluster(),
         aggregate.getTraitSet().replace(BeamLogicalConvention.INSTANCE),
-        convert(
-            aggregate.getInput(),
-            aggregate.getInput().getTraitSet().replace(BeamLogicalConvention.INSTANCE)),
+        convert(newProject, newProject.getTraitSet().replace(BeamLogicalConvention.INSTANCE)),
         aggregate.indicator,
         aggregate.getGroupSet(),
         aggregate.getGroupSets(),
         aggregate.getAggCallList(),
-        windowField);
+        windowFn,
+        windowFieldIndex);
+  }
+
+  /**
 
 Review comment:
   Is it possible to extract the windowing logic into a separate RelNode?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 145084)
    Time Spent: 7.5h  (was: 7h 20m)

> Use Calc instead of Project and Filter separately
> -------------------------------------------------
>
>                 Key: BEAM-4449
>                 URL: https://issues.apache.org/jira/browse/BEAM-4449
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Kenneth Knowles
>            Assignee: Kenneth Knowles
>            Priority: Major
>             Fix For: 2.5.0
>
>          Time Spent: 7.5h
>  Remaining Estimate: 0h
>
> Calcite has a combined Calc operator that is amenable to more optimization, and also
means less code to manage as we adjust how the operators/expressions are implemented.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message