You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2018/07/30 21:03:17 UTC
[3/5] calcite git commit: [CALCITE-2430] AssertionError:
RelDataTypeImpl.getFieldList when SQL Advisor inspects non-struct field
[CALCITE-2430] AssertionError: RelDataTypeImpl.getFieldList when SQL Advisor inspects non-struct field
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/1a94885a
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/1a94885a
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/1a94885a
Branch: refs/heads/master
Commit: 1a94885aa46216a1ab564afcf3e7968ecb54dbf9
Parents: a18a380
Author: Vladimir Sitnikov <si...@gmail.com>
Authored: Mon Jul 30 23:23:50 2018 +0300
Committer: Vladimir Sitnikov <si...@gmail.com>
Committed: Tue Jul 31 00:00:54 2018 +0300
----------------------------------------------------------------------
.../apache/calcite/sql/validate/SqlValidatorImpl.java | 12 +++++++-----
.../src/test/java/org/apache/calcite/test/JdbcTest.java | 8 ++++++++
2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/1a94885a/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 3bb0cd4..3ea6064 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
@@ -802,11 +802,13 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
}
if (ns != null) {
RelDataType rowType = ns.getRowType();
- for (RelDataTypeField field : rowType.getFieldList()) {
- hintList.add(
- new SqlMonikerImpl(
- field.getName(),
- SqlMonikerType.COLUMN));
+ if (rowType.isStruct()) {
+ for (RelDataTypeField field : rowType.getFieldList()) {
+ hintList.add(
+ new SqlMonikerImpl(
+ field.getName(),
+ SqlMonikerType.COLUMN));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/1a94885a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index 8261b8d..65572dc 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -421,6 +421,14 @@ public class JdbcTest {
"id=; names=null; type=MATCH"));
}
+ @Test public void testSqlAdvisorNonStructColumn()
+ throws SQLException, ClassNotFoundException {
+ adviseSql("select e.\"empid\".^ from \"hr\".\"emps\" e",
+ CalciteAssert.checkResultUnordered(
+ "id=*; names=[*]; type=KEYWORD",
+ "id=; names=null; type=MATCH"));
+ }
+
@Test public void testSqlAdvisorTableInSchema()
throws SQLException, ClassNotFoundException {
adviseSql("select * from \"hr\".^",