-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SQL ArrayType / CustomType failure mode (#5445)
* Fix SQL ArrayType / CustomType failure mode 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 tim es, it will pass the query to the engine where it might fail. ```python 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') ``` Fixes #5443 * spotless * Add tests
- Loading branch information
1 parent
ed7d643
commit 9928db0
Showing
9 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
digraph { | ||
"op_0" ["label"="ticketTable(scan/custom)"] | ||
"op_1" ["label"="view(__p_0_0=Foo,__p_0_1=Bar)"] | ||
"op_2" ["label"="view(Foo=__p_0_0,Bar=__p_0_1)"] | ||
"op_1" -> "op_0" | ||
"op_2" -> "op_1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
digraph { | ||
"op_0" ["label"="ticketTable(scan/custom)"] | ||
"op_1" ["label"="view(__p_0_0=Foo,__p_0_1=Bar)"] | ||
"op_2" ["label"="where(!isNull(__p_0_1))"] | ||
"op_3" ["label"="view(Foo=__p_0_0,Bar=__p_0_1)"] | ||
"op_1" -> "op_0" | ||
"op_2" -> "op_1" | ||
"op_3" -> "op_2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
digraph { | ||
"op_0" ["label"="ticketTable(scan/custom)"] | ||
"op_1" ["label"="view(__p_1_0=Foo,__p_1_1=Bar)"] | ||
"op_2" ["label"="view(Foo=__p_1_0,Bar=__p_1_1)"] | ||
"op_3" ["label"="sort([ASCENDING(Bar)])"] | ||
"op_1" -> "op_0" | ||
"op_2" -> "op_1" | ||
"op_3" -> "op_2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT | ||
* | ||
FROM | ||
custom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
* | ||
FROM | ||
custom | ||
WHERE | ||
Bar is not NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
* | ||
FROM | ||
custom | ||
ORDER BY | ||
Bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT | ||
Bar + 1 | ||
FROM | ||
custom |