You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/05/21 22:04:51 UTC

[1/2] incubator-calcite git commit: [CALCITE-688] splitCondition does not behave correctly when one side of the condition references columns from different inputs

Repository: incubator-calcite
Updated Branches:
  refs/heads/branch-1.3 744c53776 -> 4307b8053 (forced update)


[CALCITE-688] splitCondition does not behave correctly when one side of the condition references columns from different inputs

Close apache/incubator-calcite#78


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/53b4b096
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/53b4b096
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/53b4b096

Branch: refs/heads/branch-1.3
Commit: 53b4b09606de5fe14f49e65a6d5b4346ec930a62
Parents: 9475b2d
Author: Jesus Camacho Rodriguez <jc...@hortonworks.com>
Authored: Fri May 8 14:54:33 2015 +0200
Committer: Julian Hyde <jh...@apache.org>
Committed: Mon May 18 11:58:11 2015 -0700

----------------------------------------------------------------------
 .../org/apache/calcite/plan/RelOptUtil.java     | 31 ++++++++----------
 core/src/test/resources/sql/join.oq             | 34 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/53b4b096/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index 6090dd2..8289524 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -959,21 +959,20 @@ public abstract class RelOptUtil {
     final RexBuilder rexBuilder = cluster.getRexBuilder();
     final RelDataTypeFactory typeFactory = cluster.getTypeFactory();
 
-    int[] firstFieldInputs = new int[inputs.size()];
+    final ImmutableBitSet[] inputsRange = new ImmutableBitSet[inputs.size()];
     int totalFieldCount = 0;
     for (int i = 0; i < inputs.size(); i++) {
-      firstFieldInputs[i] = totalFieldCount + sysFieldCount;
-      totalFieldCount += sysFieldCount
-              + inputs.get(i).getRowType().getFieldCount();
+      final int firstField = totalFieldCount + sysFieldCount;
+      totalFieldCount = firstField + inputs.get(i).getRowType().getFieldCount();
+      inputsRange[i] = ImmutableBitSet.range(firstField, totalFieldCount);
     }
 
     // adjustment array
     int[] adjustments = new int[totalFieldCount];
     for (int i = 0; i < inputs.size(); i++) {
-      int limit = i == inputs.size() - 1
-              ? totalFieldCount : firstFieldInputs[i + 1];
-      for (int j = firstFieldInputs[i]; j < limit; j++) {
-        adjustments[j] = -firstFieldInputs[i];
+      final int adjustment = inputsRange[i].nextSetBit(0);
+      for (int j = adjustment; j < inputsRange[i].length(); j++) {
+        adjustments[j] = -adjustment;
       }
     }
 
@@ -1022,11 +1021,8 @@ public abstract class RelOptUtil {
 
         boolean foundBothInputs = false;
         for (int i = 0; i < inputs.size() && !foundBothInputs; i++) {
-          final int lowerLimit = firstFieldInputs[i];
-          final int upperLimit = i == inputs.size() - 1
-                  ? totalFieldCount : firstFieldInputs[i + 1];
-          if (projRefs0.nextSetBit(lowerLimit) < upperLimit
-                  && projRefs0.nextSetBit(lowerLimit) != -1) {
+          if (projRefs0.intersects(inputsRange[i])
+                  && projRefs0.union(inputsRange[i]).equals(inputsRange[i])) {
             if (leftKey == null) {
               leftKey = op0;
               leftInput = i;
@@ -1038,8 +1034,8 @@ public abstract class RelOptUtil {
               reverse = true;
               foundBothInputs = true;
             }
-          } else if (projRefs1.nextSetBit(lowerLimit) < upperLimit
-                  && projRefs1.nextSetBit(lowerLimit) != -1) {
+          } else if (projRefs1.intersects(inputsRange[i])
+                  && projRefs1.union(inputsRange[i]).equals(inputsRange[i])) {
             if (leftKey == null) {
               leftKey = op1;
               leftInput = i;
@@ -1116,9 +1112,8 @@ public abstract class RelOptUtil {
 
         boolean foundInput = false;
         for (int i = 0; i < inputs.size() && !foundInput; i++) {
-          final int lowerLimit = firstFieldInputs[i];
-          final int upperLimit = i == inputs.size() - 1
-                  ? totalFieldCount : firstFieldInputs[i + 1];
+          final int lowerLimit = inputsRange[i].nextSetBit(0);
+          final int upperLimit = inputsRange[i].length();
           if (projRefs.nextSetBit(lowerLimit) < upperLimit) {
             leftInput = i;
             leftFields = inputs.get(leftInput).getRowType().getFieldList();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/53b4b096/core/src/test/resources/sql/join.oq
----------------------------------------------------------------------
diff --git a/core/src/test/resources/sql/join.oq b/core/src/test/resources/sql/join.oq
index a840f19..c98effd 100644
--- a/core/src/test/resources/sql/join.oq
+++ b/core/src/test/resources/sql/join.oq
@@ -174,4 +174,38 @@ group by cube(emp.deptno, dept.deptno);
 
 !ok
 
+# [CALCITE-688] splitCondition does not behave correctly
+# when one side of the condition references columns from
+# different inputs
+select distinct emp1.deptno, emp3.ename
+from "scott".emp emp1 join "scott".emp emp2 on (emp1.deptno = emp2.deptno)
+join "scott".emp emp3 on (emp1.deptno + emp2.deptno = emp3.deptno + 10);
++--------+--------+
+| DEPTNO | ENAME  |
++--------+--------+
+|     10 | CLARK  |
+|     10 | KING   |
+|     10 | MILLER |
+|     20 | ALLEN  |
+|     20 | BLAKE  |
+|     20 | JAMES  |
+|     20 | MARTIN |
+|     20 | TURNER |
+|     20 | WARD   |
++--------+--------+
+(9 rows)
+
+!ok
+
+EnumerableCalc(expr#0..1=[{inputs}], DEPTNO0=[$t1], ENAME=[$t0])
+  EnumerableAggregate(group=[{1, 16}])
+    EnumerableJoin(condition=[=($8, $25)], joinType=[inner])
+      EnumerableCalc(expr#0..7=[{inputs}], expr#8=[10], expr#9=[+($t7, $t8)], proj#0..7=[{exprs}], $f8=[$t9])
+        EnumerableTableScan(table=[[scott, EMP]])
+      EnumerableCalc(expr#0..15=[{inputs}], expr#16=[+($t7, $t15)], expr#17=[CAST($t16):INTEGER], proj#0..15=[{exprs}], $f16=[$t17])
+        EnumerableJoin(condition=[=($7, $15)], joinType=[inner])
+          EnumerableTableScan(table=[[scott, EMP]])
+          EnumerableTableScan(table=[[scott, EMP]])
+!plan
+
 # End join.oq


[2/2] incubator-calcite git commit: Update history and version number

Posted by jh...@apache.org.
Update history and version number


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/4307b805
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/4307b805
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/4307b805

Branch: refs/heads/branch-1.3
Commit: 4307b8053b77c2d67ad7de2a613f7af1df2379dc
Parents: 53b4b09
Author: Julian Hyde <jh...@apache.org>
Authored: Thu May 21 12:41:50 2015 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu May 21 13:01:56 2015 -0700

----------------------------------------------------------------------
 README         |   2 +-
 README.md      |   2 +-
 doc/history.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/howto.md   |   5 ++-
 4 files changed, 117 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4307b805/README
----------------------------------------------------------------------
diff --git a/README b/README
index 37e52b4..e06064c 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Calcite release 1.2.0 (incubating)
+Apache Calcite release 1.3.0 (incubating)
 
 This is a source or binary distribution of Apache Calcite.
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4307b805/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index be6d841..877bc8f 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ with the following Maven coordinates:
 <dependency>
   <groupId>org.apache.calcite</groupId>
   <artifactId>calcite-core</artifactId>
-  <version>1.2.0-incubating</version>
+  <version>1.3.0-incubating</version>
 </dependency>
 ```
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4307b805/doc/history.md
----------------------------------------------------------------------
diff --git a/doc/history.md b/doc/history.md
index b4ee1cb..abb8372 100644
--- a/doc/history.md
+++ b/doc/history.md
@@ -19,6 +19,118 @@ limitations under the License.
 For a full list of releases, see
 <a href="https://github.com/apache/incubator-calcite/releases">github</a>.
 
+## <a href="https://github.com/apache/incubator-calcite/releases/tag/calcite-1.3.0-incubating">1.3.0-incubating</a> / 2015-05-21
+
+Mainly bug-fixes, but this release adds support for
+<a href="https://issues.apache.org/jira/browse/CALCITE-505">modifiable views</a>
+and
+<a href="https://issues.apache.org/jira/browse/CALCITE-704">filtered aggregate functions</a>
+and various improvements to Avatica.
+
+New features
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-505">CALCITE-505</a>]
+  Support modifiable view
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-704">CALCITE-704</a>]
+  `FILTER` clause for aggregate functions
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-522">CALCITE-522</a>]
+  In remote JDBC driver, transmit static database properties as a map
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-661">CALCITE-661</a>]
+  Remote fetch in Calcite JDBC driver
+* Support Date, Time, Timestamp parameters
+
+API changes
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-722">CALCITE-722</a>]
+  Rename markdown files to lower-case
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-697">CALCITE-697</a>]
+  Obsolete class `RelOptQuery`
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-693">CALCITE-693</a>]
+  Allow clients to control creation of `RelOptCluster`
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-691">CALCITE-691</a>]
+  Allow projects to supply alternate SQL parser
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-675">CALCITE-675</a>]
+  Enable `AggregateProjectMergeRule` in standard rule set
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-679">CALCITE-679</a>]
+  Factory method for `SemiJoin`
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-674">CALCITE-674</a>]
+  Add a `SWAP_OUTER` static instance to `JoinCommuteRule` (Maryann Xue)
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-735">CALCITE-735</a>]
+  `Primitive.DOUBLE.min` should be large and negative
+
+Bug-fixes and internal changes
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-688">CALCITE-688</a>]
+  `splitCondition` does not behave correctly when one side of the condition
+  references columns from different inputs
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-259">CALCITE-259</a>]
+  Using sub-queries in `CASE` statement against JDBC tables generates invalid
+  Oracle SQL (Yeong Wei)
+* In sample code in README.md, rename optiq to calcite (Ethan)
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-720">CALCITE-720</a>]
+  `VolcanoPlanner.ambitious` comment doc is inconsistent (Santiago M. Mola)
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-729">CALCITE-729</a>]
+  `IndexOutOfBoundsException` in `ROLLUP` query on JDBC data source
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-733">CALCITE-733</a>]
+  Multiple distinct-`COUNT` query gives wrong results
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-730">CALCITE-730</a>]
+  `ClassCastException` in table from `CloneSchema`
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-728">CALCITE-728</a>]
+  Test suite hangs on Windows
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-723">CALCITE-723</a>]
+  Document lattices
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-515">CALCITE-515</a>]
+  Add Apache headers to markdown files
+* Upgrade quidem
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-716">CALCITE-716</a>]
+  Scalar sub-query and aggregate function in `SELECT` or `HAVING` clause gives
+  `AssertionError`
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-694">CALCITE-694</a>]
+  Scan `HAVING` clause for sub-queries and `IN`-lists (Hsuan-Yi Chu)
+* Upgrade hydromatic-resource-maven-plugin
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-710">CALCITE-710</a>]
+  Identical conditions in the `WHERE` clause cause `AssertionError` (Sean
+  Hsuan-Yi Chu)
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-695">CALCITE-695</a>]
+  Do not add `SINGLE_VALUE` aggregate function to a sub-query that will never
+  return more than one row (Hsuan-Yi Chu)
+* Add tests for scalar sub-queries, including test cases for
+  [<a href="https://issues.apache.org/jira/browse/CALCITE-709">CALCITE-709</a>]
+  Errors with `LIMIT` inside scalar sub-query
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-702">CALCITE-702</a>]
+  Add validator test for monotonic expressions
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-699">CALCITE-699</a>]
+  In Avatica, synchronize access to Calendar
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-700">CALCITE-700</a>]
+  Pass time zone into tests
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-698">CALCITE-698</a>]
+  For `GROUP BY ()`, `areColumnsUnique()` should return true for any key
+* Disable tests that fail under JDK 1.7 due to
+  [<a href="https://issues.apache.org/jira/browse/CALCITE-687">CALCITE-687</a>]
+* Add "getting started" to HOWTO
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-692">CALCITE-692</a>]
+  Add back sqlline as a dependency
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-677">CALCITE-677</a>]
+  `RemoteDriverTest.testTypeHandling` fails east of Greenwich
+* Disable test for
+  [<a href="https://issues.apache.org/jira/browse/CALCITE-687">CALCITE-687</a>]
+  Make `RemoteDriverTest.testStatementLifecycle` thread-safe
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-686">CALCITE-686</a>]
+  `SqlNode.unparse` produces invalid SQL
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-507">CALCITE-507</a>]
+  Update HOWTO.md with running integration tests
+* Add H2 integration test
+* Add PostgreSQL integration test
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-590">CALCITE-590</a>]
+  Update MongoDB test suite to calcite-test-dataset
+* Add `CalciteAssert.assertArrayEqual` for more user-friendly asserts
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-585">CALCITE-585</a>]
+  Avatica JDBC methods should throw `SQLFeatureNotSupportedException` (Ng Jiunn
+  Jye)
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-671">CALCITE-671</a>]
+  `ByteString` does not deserialize properly as a `FetchRequest` parameter value
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-676">CALCITE-676</a>]
+  `AssertionError` in `GROUPING SETS` query
+* [<a href="https://issues.apache.org/jira/browse/CALCITE-678">CALCITE-678</a>]
+  `SemiJoinRule` mixes up fields when `Aggregate.groupSet` is not field #0
+
 ## <a href="https://github.com/apache/incubator-calcite/releases/tag/calcite-1.2.0-incubating">1.2.0-incubating</a> / 2015-04-07
 
 A short release, less than a month after 1.1.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4307b805/doc/howto.md
----------------------------------------------------------------------
diff --git a/doc/howto.md b/doc/howto.md
index 60a4cae..16b722a 100644
--- a/doc/howto.md
+++ b/doc/howto.md
@@ -29,8 +29,8 @@ Unpack the source distribution `.tar.gz` or `.zip` file,
 then build using maven:
 
 ```bash
-$ tar xvfz calcite-1.2.0-incubating-source.tar.gz
-$ cd calcite-1.2.0-incubating
+$ tar xvfz calcite-1.3.0-incubating-source.tar.gz
+$ cd calcite-1.3.0-incubating
 $ mvn install
 ```
 
@@ -417,6 +417,7 @@ Create a release branch named after the release, e.g. `branch-1.1`, and push it
 ```bash
 $ git checkout -b branch-X.Y
 $ git push -u origin branch-X.Y
+```
 
 We will use the branch for the entire the release process. Meanwhile,
 we do not allow commits to the master branch. After the release is