The following code block now successfully runs. A couple of failure modes are indicated when a "bad" column type is used in an invalid way. In some cases Calcite will notice the issue, and other times, it will pass the query to the engine where it might fail.
from deephaven.experimental import sql
from deephaven import empty_table
a = {}
t1 = empty_table(4).view(["I=ii"])
t2 = t1.update("A = a")
# equivalent to t1_all = t1
t1_all = sql.evaluate('SELECT * FROM t1')
# equivalent to t2_all = t2
t2_all = sql.evaluate('SELECT * FROM t2')
# org.apache.calcite.sql.validate.SqlValidatorException: Cannot apply '+' to arguments of type '<JAVATYPE(CLASS IO.DEEPHAVEN.SQL.TYPEADAPTER$SQLTODOCUSTOMTYPE)> + <INTEGER>'. Supported form(s): '<NUMERIC> + <NUMERIC>'
# '<DATETIME_INTERVAL> + <DATETIME_INTERVAL>'
# '<DATETIME> + <DATETIME_INTERVAL>'
# '<DATETIME_INTERVAL> + <DATETIME>'
# at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
# at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
# at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
# at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:507)
# at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:601)
# ... 53 more
#t2_bad_op = sql.evaluate('SELECT A + 1 FROM t2')
# Requirement failed: required Comparable.class.isAssignableFrom(sortColumns[ii].getType()) || sortColumns[ii].getType().isPrimitive(), instead sortColumnNames[ii] == "A", sortColumns[ii].getType() == class org.jpy.PyDictWrapper.
# at io.deephaven.base.verify.Require.fail(Require.java:108)
# at io.deephaven.base.verify.Require.requirement(Require.java:169)
# at io.deephaven.base.verify.Require.requirement(Require.java:175)
# at io.deephaven.engine.table.impl.SortOperation.<init>(SortOperation.java:69)
#t2_engine_sort = sql.evaluate('SELECT A FROM t2 ORDER BY A')
The following code block now successfully runs. A couple of failure modes are indicated when a "bad" column type is used in an invalid way. In some cases Calcite will notice the issue, and other times, it will pass the query to the engine where it might fail.
Fixes #5443