Skip to content

Commit

Permalink
[CALCITE-3148] Validator throws IndexOutOfBoundsException for SqlInse…
Browse files Browse the repository at this point in the history
…rt when source and sink have non-equal fields number
  • Loading branch information
danny0405 committed Jun 28, 2019
1 parent 1cc7c35 commit 6375e24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4070,7 +4070,7 @@ protected RelDataType validateSelectList(
selectItem,
select,
targetRowType.isStruct()
&& targetRowType.getFieldCount() >= i
&& targetRowType.getFieldCount() > i
? targetRowType.getFieldList().get(i).getType()
: unknownType,
expandedSelectItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9132,6 +9132,15 @@ private static int prec(SqlOperator op) {
+ "values (1, 'Karl')");
}

@Test public void testInsertWithNonEqualSourceSinkFieldsNum() {
tester.checkQueryFails("insert into ^dept^ select sid, ename, deptno "
+ "from "
+ "(select sum(empno) as sid, ename, deptno, sal "
+ "from emp group by ename, deptno, sal)",
"Number of INSERT target columns \\(2\\) "
+ "does not equal number of source items \\(3\\)");
}

@Test public void testInsertSubset() {
final SqlTester pragmaticTester =
tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003);
Expand Down

0 comments on commit 6375e24

Please sign in to comment.