calcite git commit: [CALCITE-2162] Exception when accessing sub-field of sub-field of composite Array element (Shuyi Chen) [Forced Update!]

2018-02-05 Thread jhyde
Repository: calcite
Updated Branches:
  refs/heads/master 5547781ed -> e25e74977 (forced update)


[CALCITE-2162] Exception when accessing sub-field of sub-field of composite 
Array element (Shuyi Chen)

Solve problem by changing stripDot method to be recursive.

Close apache/calcite#620


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

Branch: refs/heads/master
Commit: e25e74977f4205ab085e8c2472a323df437511f5
Parents: 5c2164d
Author: Shuyi Chen 
Authored: Thu Feb 1 14:50:57 2018 -0800
Committer: Julian Hyde 
Committed: Mon Feb 5 10:36:08 2018 -0800

--
 .../apache/calcite/sql/validate/SqlValidatorImpl.java|  2 +-
 .../java/org/apache/calcite/test/MockCatalogReader.java  | 10 +-
 .../org/apache/calcite/test/SqlToRelConverterTest.java   |  2 +-
 .../java/org/apache/calcite/test/SqlValidatorTest.java   | 11 ---
 .../org/apache/calcite/test/SqlToRelConverterTest.xml|  4 ++--
 5 files changed, 21 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/calcite/blob/e25e7497/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
--
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index a8574f2..9c2170e 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -3292,7 +3292,7 @@ public class SqlValidatorImpl implements 
SqlValidatorWithHints {
 
   private SqlNode stripDot(SqlNode node) {
 if (node != null && node.getKind() == SqlKind.DOT) {
-  return ((SqlCall) node).operand(0);
+  return stripDot(((SqlCall) node).operand(0));
 }
 return node;
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/e25e7497/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
--
diff --git a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java 
b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
index cd42747..23c6b94 100644
--- a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
+++ b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
@@ -1666,16 +1666,24 @@ public class MockCatalogReader extends 
CalciteCatalogReader {
 .build())
 .kind(StructKind.PEEK_FIELDS_NO_EXPAND)
 .build();
+final RelDataType abRecordType =
+typeFactory.builder()
+.add("A", varchar10Type)
+.add("B", varchar10Type)
+.build();
 final RelDataType skillRecordType =
 typeFactory.builder()
 .add("TYPE", varchar10Type)
 .add("DESC", varchar20Type)
+.add("OTHERS", abRecordType)
 .build();
 final RelDataType empRecordType =
 typeFactory.builder()
 .add("EMPNO", intType)
 .add("ENAME", varchar10Type)
-.add("SKILLS", typeFactory.createArrayType(skillRecordType, -1))
+.add("DETAIL",
+typeFactory.builder().add("SKILLS",
+typeFactory.createArrayType(skillRecordType, -1)).build())
 .build();
 final RelDataType empListType =
 typeFactory.createArrayType(empRecordType, -1);

http://git-wip-us.apache.org/repos/asf/calcite/blob/e25e7497/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
--
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index 9648ded..95a506b 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -1103,7 +1103,7 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
   }
 
   @Test public void testArrayOfRecord() {
-sql("select employees[1].skills[2+3].desc from dept_nested").ok();
+sql("select employees[1].detail.skills[2+3].desc from dept_nested").ok();
   }
 
   @Test public void testUnnestArray() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/e25e7497/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
--
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 

calcite git commit: [CALCITE-2162] Exception when accessing sub-field of sub-field of composite Array element (Shuyi Chen)

2018-02-04 Thread jhyde
Repository: calcite
Updated Branches:
  refs/heads/master 5c2164da9 -> 5547781ed


[CALCITE-2162] Exception when accessing sub-field of sub-field of composite 
Array element (Shuyi Chen)

Solve problem by changing stripDot method to be recursive.

Close apache/calcite#620

Change-Id: I950546b7d5c0bf24c8ef5eaa97a416377468c36c


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

Branch: refs/heads/master
Commit: 5547781ede561133ce3440a0ee1c4de690f45863
Parents: 5c2164d
Author: Shuyi Chen 
Authored: Thu Feb 1 14:50:57 2018 -0800
Committer: Julian Hyde 
Committed: Sat Feb 3 17:08:57 2018 -0800

--
 .../apache/calcite/sql/validate/SqlValidatorImpl.java|  2 +-
 .../java/org/apache/calcite/test/MockCatalogReader.java  | 10 +-
 .../org/apache/calcite/test/SqlToRelConverterTest.java   |  2 +-
 .../java/org/apache/calcite/test/SqlValidatorTest.java   | 11 ---
 .../org/apache/calcite/test/SqlToRelConverterTest.xml|  4 ++--
 5 files changed, 21 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/calcite/blob/5547781e/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
--
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index a8574f2..9c2170e 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -3292,7 +3292,7 @@ public class SqlValidatorImpl implements 
SqlValidatorWithHints {
 
   private SqlNode stripDot(SqlNode node) {
 if (node != null && node.getKind() == SqlKind.DOT) {
-  return ((SqlCall) node).operand(0);
+  return stripDot(((SqlCall) node).operand(0));
 }
 return node;
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/5547781e/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
--
diff --git a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java 
b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
index cd42747..23c6b94 100644
--- a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
+++ b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
@@ -1666,16 +1666,24 @@ public class MockCatalogReader extends 
CalciteCatalogReader {
 .build())
 .kind(StructKind.PEEK_FIELDS_NO_EXPAND)
 .build();
+final RelDataType abRecordType =
+typeFactory.builder()
+.add("A", varchar10Type)
+.add("B", varchar10Type)
+.build();
 final RelDataType skillRecordType =
 typeFactory.builder()
 .add("TYPE", varchar10Type)
 .add("DESC", varchar20Type)
+.add("OTHERS", abRecordType)
 .build();
 final RelDataType empRecordType =
 typeFactory.builder()
 .add("EMPNO", intType)
 .add("ENAME", varchar10Type)
-.add("SKILLS", typeFactory.createArrayType(skillRecordType, -1))
+.add("DETAIL",
+typeFactory.builder().add("SKILLS",
+typeFactory.createArrayType(skillRecordType, -1)).build())
 .build();
 final RelDataType empListType =
 typeFactory.createArrayType(empRecordType, -1);

http://git-wip-us.apache.org/repos/asf/calcite/blob/5547781e/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
--
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index 9648ded..95a506b 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -1103,7 +1103,7 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
   }
 
   @Test public void testArrayOfRecord() {
-sql("select employees[1].skills[2+3].desc from dept_nested").ok();
+sql("select employees[1].detail.skills[2+3].desc from dept_nested").ok();
   }
 
   @Test public void testUnnestArray() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/5547781e/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
--
diff --git