Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/36#discussion_r24708326
--- Diff:
phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java ---
@@ -1493,5 +1493,77 @@ public void testMultiCFProjection() throws Exception
{
assertTrue(scan.getFilter() instanceof FirstKeyOnlyFilter);
assertEquals(1, scan.getFamilyMap().size());
}
+
+ @Test
+ public void testNonDeterministicExpressionIndex() throws Exception {
+ String ddl = "CREATE TABLE t (k1 INTEGER PRIMARY KEY)";
+ Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ stmt.execute(ddl);
+ stmt.execute("CREATE INDEX i ON t (RAND())");
+ fail();
+ } catch (SQLException e) {
+
assertEquals(SQLExceptionCode.NON_DETERMINISTIC_EXPRESSION_NOT_ALLOWED_IN_INDEX.getErrorCode(),
e.getErrorCode());
+ }
+ finally {
+ stmt.close();
+ }
+ }
+
+ @Test
+ public void testStatelessExpressionIndex() throws Exception {
+ String ddl = "CREATE TABLE t (k1 INTEGER PRIMARY KEY)";
+ Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ stmt.execute(ddl);
+ stmt.execute("CREATE INDEX i ON t (SUM())");
+ fail();
+ } catch (SQLException e) {
+
assertEquals(SQLExceptionCode.STATELESS_EXPRESSION_NOT_ALLOWED_IN_INDEX.getErrorCode(),
e.getErrorCode());
--- End diff --
This should throw the AGGREGATION not allowed exception. An example of
stateless would be if a constant value was used. I guess this is an error
condition.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---