[
https://issues.apache.org/jira/browse/CALCITE-1863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16071762#comment-16071762
]
Damjan Jovanovic commented on CALCITE-1863:
-------------------------------------------
Thank you.
I did finally put something together which fixes my issue and still passes all
the unit tests, but I am not sure how it works or what it's really doing:
{code}
diff --git
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
index 10e969f..90f4332 100644
---
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
+++
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
@@ -725,6 +725,9 @@ public static Expression translateLiteral(
Type desiredType = null;
if (storageTypes != null) {
desiredType = storageTypes.get(i);
+ if (!isNullable(rex) && Primitive.isBox(desiredType)) {
+ desiredType = Primitive.unbox(desiredType);
+ }
}
final Expression translate = translate(rex, desiredType);
list.add(translate);
{code}
> Timestamp "<>" operator compares box references instead of values
> -----------------------------------------------------------------
>
> Key: CALCITE-1863
> URL: https://issues.apache.org/jira/browse/CALCITE-1863
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.12.0, 1.13.0
> Reporter: Damjan Jovanovic
> Assignee: Julian Hyde
>
> In MySQL:
> USE db;
> CREATE TABLE test(id INTEGER NOT NULL PRIMARY KEY, dt datetime NOT NULL);
> INSERT INTO test values (1, '2017-06-29 09:00:00');
> Then connect to it twice, and full outer join on the primary key where the
> timestamp is different:
> {code}
> Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
> CalciteConnection calciteConnection =
> connection.unwrap(CalciteConnection.class);
> SchemaPlus rootSchema = calciteConnection.getRootSchema();
> JdbcSchema a = JdbcSchema.create(calciteConnection.getRootSchema(),
> "A", aDataSource, null, "db");
> rootSchema.add("A", a);
> JdbcSchema b = JdbcSchema.create(calciteConnection.getRootSchema(),
> "B", bDataSource, null, "db");
> rootSchema.add("B", b);
> PreparedStatement st = connection.prepareStatement(
> "SELECT * FROM A.test AS a FULL OUTER JOIN B.test AS b " +
> "ON a.id=b.id " +
> "WHERE a.dt <> b.dt");
> ResultSet results = st.executeQuery();
> {code}
> results now contains that row joined to itself, since the "dt" in WHERE
> tested as not equal to itself.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)