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

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

                Author: ASF GitHub Bot
            Created on: 15/Jan/19 18:54
            Start Date: 15/Jan/19 18:54
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on pull request #7504: [BEAM-6427] 
INTERSECT ALL is not compatible with SQL standard.
URL: https://github.com/apache/beam/pull/7504#discussion_r248019302
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamSetOperatorsTransforms.java
 ##########
 @@ -80,8 +80,23 @@ public void processElement(ProcessContext ctx) {
         case INTERSECT:
           if (leftRows.iterator().hasNext() && rightRows.iterator().hasNext()) 
{
             if (all) {
-              for (Row leftRow : leftRows) {
-                ctx.output(leftRow);
+              Iterator<Row> iter = leftRows.iterator();
+              int leftCount = 0;
+              int rightCount = 0;
+              while (iter.hasNext()) {
+                iter.next();
+                leftCount++;
+              }
+              iter = rightRows.iterator();
+              while (iter.hasNext()) {
+                iter.next();
+                rightCount++;
+              }
+
+              // output MIN(m, n)
+              iter = (leftCount <= rightCount) ? leftRows.iterator() : 
rightRows.iterator();
+              while (iter.hasNext()) {
 
 Review comment:
   If we cannot avoid shuffle, passing around value or counts will sometime not 
really impact performance. It really depends. I remember one problem faced by 
shuffle is too many small files. Because by the nature of shuffle, there will 
might be m * n connections where m is the number of mappers, n is the number of 
keys/small files on each mapper.  Some optimization on shuffle that might be 
done is compact files into larger files, or pipeline might enable external 
shuffle service. 
   
   Basically I think one solution is not always be optimal all the time. 
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 185385)
    Time Spent: 2h 20m  (was: 2h 10m)

> INTERSECT ALL is not compatible with SQL standard
> -------------------------------------------------
>
>                 Key: BEAM-6427
>                 URL: https://issues.apache.org/jira/browse/BEAM-6427
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>             Fix For: Not applicable
>
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> say Row R appears m times on one side and n times on another side. 
> Beam's  INTERSECT ALL is implemented to return MAX(m, n).
> And SQL1999 standard says INTERSECT ALL should return MIN(m, n).



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

Reply via email to