[
https://issues.apache.org/jira/browse/CALCITE-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15813034#comment-15813034
]
Vladimir Sitnikov commented on CALCITE-1569:
--------------------------------------------
[[email protected]], can you please provide full debug source?
When I try to join on dates, Calcite creates {{.join}} call, thus it does not
generate that {{inp0_ == inp2_}} condition.
On the other hand, the following cases break in different ways (the tests to be
placed in {{org.apache.calcite.test.ReflectiveSchemaTest}}):
1)
{code:java}
CalciteAssert.that()
.withSchema("s", CATCHALL)
.query("select a.v from (select \"sqlDate\" v from \"s\".\"everyTypes\"
group by \"sqlDate\") a" +
", (select \"sqlDate\" v from \"s\".\"everyTypes\" group by
\"sqlDate\") b where a.v = b.v group by a.v")
.returnsUnordered("value=1", "value=3", "value=5");
{code}
Produces "V=1970-01-01\nV=null"
I do not think null row is valid here as "a.v = b.v" should not allow NULL
string.
2) greater or equal produces error:
{code:java}
CalciteAssert.that()
.withSchema("s", CATCHALL)
.query("select a.v from (select \"sqlDate\" v from
\"s\".\"everyTypes\" group by \"sqlDate\") a" +
", (select \"sqlDate\" v from \"s\".\"everyTypes\" group by
\"sqlDate\") b where a.v >= b.v group by a.v")
.returnsUnordered("value=1", "value=3", "value=5");
{code}
{noformat}
/* 112 */ public boolean moveNext() {
/* 113 */ while (inputEnumerator.moveNext()) {
/* 114 */ final Object[] current = (Object[])
inputEnumerator.current();
/* 115 */ if
(org.apache.calcite.runtime.SqlFunctions.internalToDate(current[1]) != null &&
org.apache.calcite.runtime.SqlFunctions.internalToDate(current[0]) != null &&
(Integer) current[1] >= (Integer) current[0]) {
/* 116 */ return true;
/* 117 */ }
/* 118 */ }
/* 119 */ return false;
/* 120 */ }
Caused by: org.codehaus.commons.compiler.CompileException: Line 115, Column 74:
No applicable constructor/method found for actual parameters
"java.lang.Object"; candidates are: "public static java.sql.Date
org.apache.calcite.runtime.SqlFunctions.internalToDate(int)", "public static
java.sql.Date
org.apache.calcite.runtime.SqlFunctions.internalToDate(java.lang.Integer)"{noformat}
> Date condition can generates Integer == Integer, which is always false
> ----------------------------------------------------------------------
>
> Key: CALCITE-1569
> URL: https://issues.apache.org/jira/browse/CALCITE-1569
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.10.0
> Reporter: liyang
> Assignee: Julian Hyde
>
> Run the below query on calcite 1.10.
> {code}
> select
> l.cal_dt
> , sum(left_join_gvm) as left_join_sum
> , sum(inner_join_gvm) as inner_join_sum
> from
> (
> select test_kylin_fact.cal_dt, sum(price) as left_join_gvm
> from test_kylin_fact
> group by test_kylin_fact.cal_dt
> ) l
> ,
> (
> select test_kylin_fact.cal_dt, sum(price) as inner_join_gvm
> from test_kylin_fact
> group by test_kylin_fact.cal_dt
> ) i
> where
> l.cal_dt = i.cal_dt -- this condition
> group by
> l.cal_dt
> {code}
> The where condition generates Baz code like below.
> {code}
> /* 284 */ final org.apache.calcite.linq4j.AbstractEnumerable child1 = new
> org.apache.calcite.linq4j.AbstractEnumerable(){
> /* 285 */ public org.apache.calcite.linq4j.Enumerator enumerator() {
> /* 286 */ return new org.apache.calcite.linq4j.Enumerator(){
> /* 287 */ public final org.apache.calcite.linq4j.Enumerator
> inputEnumerator = _inputEnumerable1.enumerator();
> /* 288 */ public void reset() {
> /* 289 */ inputEnumerator.reset();
> /* 290 */ }
> /* 291 */
> /* 292 */ public boolean moveNext() {
> /* 293 */ while (inputEnumerator.moveNext()) {
> /* 294 */ final Object[] current = (Object[])
> inputEnumerator.current();
> /* 295 */ final Integer inp0_ = (Integer) current[0];
> /* 296 */ final Integer inp2_ = (Integer) current[2];
> /* 297 */ if (inp0_ != null && inp2_ != null && inp0_ == inp2_)
> {
> /* 298 */ return true;
> /* 299 */ }
> /* 300 */ }
> /* 301 */ return false;
> /* 302 */ }
> /* 303 */
> /* 304 */ public void close() {
> /* 305 */ inputEnumerator.close();
> /* 306 */ }
> /* 307 */
> /* 308 */ public Object current() {
> /* 309 */ final Object[] current = (Object[])
> inputEnumerator.current();
> /* 310 */ return new Object[] {
> /* 311 */ current[0],
> /* 312 */ current[1],
> /* 313 */ current[3]};
> /* 314 */ }
> /* 315 */
> /* 316 */ };
> /* 317 */ }
> /* 318 */
> /* 319 */ };
> {code}
> The problem is {code} if (inp0_ != null && inp2_ != null && inp0_ == inp2_)
> {code} is always false, by using == to compare two Integers.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)