PHOENIX-3468 Double quote SYSTEM, USER,DATE keywords in IT tests(Rajeshbabu)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/895cb1df Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/895cb1df Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/895cb1df Branch: refs/heads/calcite Commit: 895cb1dfca01a9cfffe7d25eaa524f944cb53952 Parents: a675211 Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Authored: Fri Jan 20 18:39:39 2017 +0530 Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Committed: Fri Jan 20 18:39:39 2017 +0530 ---------------------------------------------------------------------- .../AlterMultiTenantTableWithViewsIT.java | 2 +- .../apache/phoenix/end2end/AlterTableIT.java | 16 ++--- .../phoenix/end2end/AlterTableWithViewsIT.java | 2 +- .../phoenix/end2end/ArithmeticQueryIT.java | 2 +- .../phoenix/end2end/ArrayFillFunctionIT.java | 28 ++++----- .../end2end/BaseTenantSpecificTablesIT.java | 4 +- .../phoenix/end2end/CoalesceFunctionIT.java | 60 +++++++++--------- .../org/apache/phoenix/end2end/DateTimeIT.java | 6 +- .../org/apache/phoenix/end2end/DeleteIT.java | 26 ++++---- .../phoenix/end2end/EvaluationOfORIT.java | 5 +- .../apache/phoenix/end2end/GroupByCaseIT.java | 10 +-- .../org/apache/phoenix/end2end/GroupByIT.java | 6 +- .../apache/phoenix/end2end/HashJoinMoreIT.java | 47 +++++++------- .../phoenix/end2end/SortMergeJoinMoreIT.java | 37 +++++------ .../org/apache/phoenix/end2end/SortOrderIT.java | 8 +-- .../end2end/TenantSpecificTablesDDLIT.java | 12 ++-- .../end2end/TenantSpecificTablesDMLIT.java | 66 ++++++++++---------- .../apache/phoenix/end2end/UpsertValuesIT.java | 20 +++--- .../phoenix/compile/JoinQueryCompilerTest.java | 6 +- .../phoenix/compile/QueryCompilerTest.java | 8 ++- 20 files changed, 178 insertions(+), 193 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java index adadca7..d6f3a7f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java @@ -656,7 +656,7 @@ public class AlterMultiTenantTableWithViewsIT extends ParallelStatsDisabledIT { } public static void assertTableDefinition(Connection conn, String tableName, PTableType tableType, String parentTableName, int sequenceNumber, int columnCount, int baseColumnCount, String... columnName) throws Exception { - PreparedStatement p = conn.prepareStatement("SELECT * FROM SYSTEM.CATALOG WHERE TABLE_NAME=? AND TABLE_TYPE=?"); + PreparedStatement p = conn.prepareStatement("SELECT * FROM \"SYSTEM\".\"CATALOG\" WHERE TABLE_NAME=? AND TABLE_TYPE=?"); p.setString(1, tableName); p.setString(2, tableType.getSerializedValue()); ResultSet rs = p.executeQuery(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java index f51c3cb..fee7316 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java @@ -996,7 +996,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertEquals("COL3",rs.getString(4)); assertFalse(rs.next()); - rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM SYSTEM.CATALOG\n" + rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM \"SYSTEM\".\"CATALOG\"\n" + "WHERE TENANT_ID IS NULL AND\n" + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ dataTableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL"); @@ -1004,7 +1004,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertEquals(4,rs.getInt(1)); assertFalse(rs.next()); - rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM SYSTEM.CATALOG\n" + rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM \"SYSTEM\".\"CATALOG\"\n" + "WHERE TENANT_ID IS NULL AND\n" + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ indexTableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL"); @@ -1051,7 +1051,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertEquals("COL4",rs.getString(4)); assertFalse(rs.next()); - rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM SYSTEM.CATALOG\n" + rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM \"SYSTEM\".\"CATALOG\"\n" + "WHERE TENANT_ID IS NULL AND\n" + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ dataTableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL"); @@ -1059,7 +1059,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertEquals(3,rs.getInt(1)); assertFalse(rs.next()); - rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM SYSTEM.CATALOG\n" + rs = conn1.createStatement().executeQuery("SELECT COLUMN_COUNT FROM \"SYSTEM\".\"CATALOG\"\n" + "WHERE TENANT_ID IS NULL AND\n" + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ indexTableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL"); @@ -1977,7 +1977,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + dataTableFullName + " (id SMALLINT PRIMARY KEY, name VARCHAR)"); - ResultSet rs = stmt.executeQuery("SELECT STORE_NULLS FROM SYSTEM.CATALOG " + + ResultSet rs = stmt.executeQuery("SELECT STORE_NULLS FROM \"SYSTEM\".\"CATALOG\" " + "WHERE table_name = '" + dataTableFullName + "' AND STORE_NULLS IS NOT NULL"); assertTrue(rs.next()); @@ -1987,7 +1987,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { stmt.execute("ALTER TABLE " + dataTableFullName + " SET STORE_NULLS = true"); - rs = stmt.executeQuery("SELECT STORE_NULLS FROM SYSTEM.CATALOG " + + rs = stmt.executeQuery("SELECT STORE_NULLS FROM \"SYSTEM\".\"CATALOG\" " + "WHERE table_name = '" + dataTableFullName + "' AND STORE_NULLS IS NOT NULL"); assertTrue(rs.next()); @@ -2102,7 +2102,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertTrue(t.isMultiTenant()); // check table metadata updated server side - ResultSet rs = conn.createStatement().executeQuery("SELECT DISABLE_WAL, MULTI_TENANT FROM SYSTEM.CATALOG " + ResultSet rs = conn.createStatement().executeQuery("SELECT DISABLE_WAL, MULTI_TENANT FROM \"SYSTEM\".\"CATALOG\"" + "WHERE table_name = '" + dataTableFullName + "' AND DISABLE_WAL IS NOT NULL AND MULTI_TENANT IS NOT NULL"); assertTrue(rs.next()); @@ -2162,7 +2162,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT { } private void assertIsRowTimestampSet(String schemaName, String tableName, String columnName) throws SQLException { - String sql = "SELECT IS_ROW_TIMESTAMP FROM SYSTEM.CATALOG WHERE " + String sql = "SELECT IS_ROW_TIMESTAMP FROM \"SYSTEM\".\"CATALOG\" WHERE " + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ tableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME = ?"; try(Connection conn = DriverManager.getConnection(getUrl())) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java index 52dae00..211145e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java @@ -585,7 +585,7 @@ public class AlterTableWithViewsIT extends ParallelStatsDisabledIT { public static String getSystemCatalogEntriesForTable(Connection conn, String tableName, String message) throws Exception { StringBuilder sb = new StringBuilder(message); sb.append("\n\n\n"); - ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM SYSTEM.CATALOG WHERE TABLE_NAME='"+ tableName +"'"); + ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM \"SYSTEM\".\"CATALOG\" WHERE TABLE_NAME='"+ tableName +"'"); ResultSetMetaData metaData = rs.getMetaData(); int rowNum = 0; while (rs.next()) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java index c297441..6126746 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java @@ -1050,7 +1050,7 @@ public class ArithmeticQueryIT extends ParallelStatsDisabledIT { conn.createStatement().execute(dml); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("SELECT 1.2E3 FROM SYSTEM.CATALOG LIMIT 1"); + ResultSet rs = conn.createStatement().executeQuery("SELECT 1.2E3 FROM \"SYSTEM\".\"CATALOG\" LIMIT 1"); assertTrue(rs.next()); assertTrue(rs.getObject(1) instanceof Double); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java index dfa0beb..5133e5d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java @@ -44,10 +44,10 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { tableName = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl()); String ddl = "CREATE TABLE " + tableName - + " (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,\"DATE\" DATE,time TIME,timestamp TIMESTAMP,varchar VARCHAR,integer INTEGER,double DOUBLE,bigint BIGINT,char CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; + + " (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,\"DATE\" DATE,\"time\" TIME,\"timestamp\" TIMESTAMP,\"varchar\" VARCHAR,\"integer\" INTEGER,\"double\" DOUBLE,\"bigint\" BIGINT,\"char\" CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + tableName - + "(region_name,length1,length2,\"DATE\",time,timestamp,varchar,integer,double,bigint,char,double1,char1,nullcheck,chars2,varchars2) VALUES('SF Bay Area'," + + "(region_name,length1,length2,\"DATE\",\"time\",\"timestamp\",\"varchar\",\"integer\",\"double\",\"bigint\",\"char\",double1,char1,nullcheck,chars2,varchars2) VALUES('SF Bay Area'," + "0," + "-3," + @@ -76,7 +76,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(varchar,5) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"varchar\",5) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); String[] strings = new String[]{"foo", "foo", "foo", "foo", "foo"}; @@ -93,7 +93,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(integer,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"integer\",4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34, 34, 34, 34}; @@ -111,7 +111,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(double,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"double\",4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{23.45, 23.45, 23.45, 23.45}; @@ -129,7 +129,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(bigint,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"bigint\",4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34567l, 34567l, 34567l, 34567l}; @@ -147,7 +147,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(char,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"char\",4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -164,7 +164,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(varchar,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"varchar\",4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -198,7 +198,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(time,3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"time\",3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Time(1432102334184l), new Time(1432102334184l), new Time(1432102334184l)}; @@ -215,7 +215,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(\"timestamp\",3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Timestamp(1432102334184l), new Timestamp(1432102334184l), new Timestamp(1432102334184l)}; @@ -232,7 +232,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,length2) FROM " + tableName + "SELECT ARRAY_FILL(\"timestamp\",length2) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -250,7 +250,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,length1) FROM " + tableName + "SELECT ARRAY_FILL(\"timestamp\",length1) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -513,7 +513,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT region_name FROM " + tableName + " WHERE varchar=ANY(ARRAY_FILL('foo',3))"); + "SELECT region_name FROM " + tableName + " WHERE \"varchar\"=ANY(ARRAY_FILL('foo',3))"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -555,7 +555,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName - + " WHERE ARRAY['foo','foo','foo','foo','foo']=ARRAY_FILL(varchar,5)"); + + " WHERE ARRAY['foo','foo','foo','foo','foo']=ARRAY_FILL(\"varchar\",5)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java index 0749a20..5e9208b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificTablesIT.java @@ -56,7 +56,7 @@ public abstract class BaseTenantSpecificTablesIT extends ParallelStatsEnabledIT PARENT_TABLE_NAME_NO_TENANT_TYPE_ID = "P_" + BaseTest.generateUniqueName(); TENANT_TABLE_NAME_NO_TENANT_TYPE_ID = "V_" + BaseTest.generateUniqueName(); PARENT_TABLE_DDL = "CREATE TABLE " + PARENT_TABLE_NAME + " ( \n" + - " user VARCHAR ,\n" + + " \"user\" VARCHAR ,\n" + " tenant_id VARCHAR NOT NULL,\n" + " tenant_type_id VARCHAR(3) NOT NULL, \n" + " id INTEGER NOT NULL\n" + @@ -65,7 +65,7 @@ public abstract class BaseTenantSpecificTablesIT extends ParallelStatsEnabledIT " tenant_col VARCHAR) AS SELECT *\n" + " FROM " + PARENT_TABLE_NAME + " WHERE tenant_type_id= '" + TENANT_TYPE_ID + "'"; PARENT_TABLE_DDL_NO_TENANT_TYPE_ID = "CREATE TABLE " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " ( \n" + - " user VARCHAR ,\n" + + " \"user\" VARCHAR ,\n" + " tenant_id VARCHAR NOT NULL,\n" + " id INTEGER NOT NULL,\n" + " CONSTRAINT pk PRIMARY KEY (tenant_id, id)) MULTI_TENANT=true, IMMUTABLE_ROWS=true"; http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/CoalesceFunctionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CoalesceFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CoalesceFunctionIT.java index 0666f77..828051f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CoalesceFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CoalesceFunctionIT.java @@ -69,16 +69,16 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " - + " COUNT BIGINT " + + " \"COUNT\" BIGINT " + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2, null)"); conn.commit(); ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(SUM(COUNT), CAST(0 AS BIGINT)) " //explicitly def long + + "COALESCE(SUM(\"COUNT\"), CAST(0 AS BIGINT)) " //explicitly def long + "FROM " + tableName + " GROUP BY ID"); @@ -93,16 +93,16 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " - + " COUNT BIGINT " + + " \"COUNT\" BIGINT " + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2, null)"); conn.commit(); ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(SUM(COUNT), 0) " // no long def + + "COALESCE(SUM(\"COUNT\"), 0) " // no long def + "FROM " + tableName + " GROUP BY ID"); @@ -117,16 +117,16 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " - + " COUNT BIGINT " + + " \"COUNT\" BIGINT " + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2, null)"); conn.commit(); ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(SUM(COUNT), SUM(ID)) " // second param as expression + + "COALESCE(SUM(\"COUNT\"), SUM(ID)) " // second param as expression + "FROM " + tableName + " GROUP BY ID"); @@ -142,16 +142,16 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " - + " COUNT BIGINT " //first parameter to coalesce + + " \"COUNT\" BIGINT " //first parameter to coalesce + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2, null)"); conn.commit(); ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(NTH_VALUE(COUNT, 100) WITHIN GROUP (ORDER BY COUNT DESC), 0) " //second param is int + + "COALESCE(NTH_VALUE(\"COUNT\", 100) WITHIN GROUP (ORDER BY \"COUNT\" DESC), 0) " //second param is int + "FROM " + tableName + " GROUP BY ID"); @@ -166,17 +166,17 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " - + " COUNT UNSIGNED_INT " //first parameter to coalesce + + " \"COUNT\" UNSIGNED_INT " //first parameter to coalesce + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + " (ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + " (ID, \"COUNT\") VALUES(2, null)"); conn.commit(); //second param to coalesce is signed int ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + " COALESCE(NTH_VALUE(COUNT, 100) WITHIN GROUP (ORDER BY COUNT DESC), 1) " + + " COALESCE(NTH_VALUE(\"COUNT\", 100) WITHIN GROUP (ORDER BY COUNT DESC), 1) " + " FROM " + tableName + " GROUP BY ID"); @@ -193,21 +193,21 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String ddl = "CREATE TABLE " + tableName + "(" + " ID BIGINT NOT NULL, " + " DATE TIMESTAMP NOT NULL, " - + " COUNT BIGINT " + + " \"COUNT\" BIGINT " + " CONSTRAINT pk PRIMARY KEY(ID, DATE))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, COUNT) VALUES(1, CURRENT_TIME(), 1)"); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, COUNT) VALUES(1, CURRENT_TIME(), 2)"); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, COUNT) VALUES(2, CURRENT_TIME(), 1)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, \"COUNT\") VALUES(1, CURRENT_TIME(), 1)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, \"COUNT\") VALUES(1, CURRENT_TIME(), 2)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, DATE, \"COUNT\") VALUES(2, CURRENT_TIME(), 1)"); conn.commit(); //second param to coalesce is signed int ResultSet rs = conn.createStatement().executeQuery( "SELECT " + " COALESCE(" - + " NTH_VALUE(COUNT, 2000)" // should evaluate null - + " WITHIN GROUP (ORDER BY COUNT DESC)," + + " NTH_VALUE(\"COUNT\", 2000)" // should evaluate null + + " WITHIN GROUP (ORDER BY \"COUNT\" DESC)," + " 0)" + "FROM " + tableName + " GROUP BY ID"); @@ -224,17 +224,17 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String ddl = "CREATE TABLE " + tableName + "(" + " ID UNSIGNED_INT NOT NULL, " - + " COUNT UNSIGNED_INT " + + " \"COUNT\" UNSIGNED_INT " + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2, null)"); conn.commit(); try { conn.createStatement().executeQuery( "SELECT " - + "COALESCE(MIN(COUNT), -1) " // invalid value for UNSIGNED_INT + + "COALESCE(MIN(\"COUNT\"), -1) " // invalid value for UNSIGNED_INT + "FROM " + tableName + " GROUP BY ID"); @@ -251,17 +251,17 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String ddl = "CREATE TABLE " + tableName + "(" + " ID INTEGER NOT NULL, " - + " COUNT UNSIGNED_INT " //first parameter to coalesce + + " \"COUNT\" UNSIGNED_INT " //first parameter to coalesce + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(-2, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(-2, null)"); conn.commit(); try { ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(MIN(COUNT), ID) " + + "COALESCE(MIN(\"COUNT\"), ID) " + "FROM " + tableName + " GROUP BY ID"); @@ -280,16 +280,16 @@ public class CoalesceFunctionIT extends ParallelStatsDisabledIT { String ddl = "CREATE TABLE " + tableName + "(" + " ID DOUBLE NOT NULL, " - + " COUNT INTEGER " //first parameter to coalesce + + " \"COUNT\" INTEGER " //first parameter to coalesce + " CONSTRAINT pk PRIMARY KEY(ID))"; conn.createStatement().execute(ddl); - conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, COUNT) VALUES(2.0, null)"); + conn.createStatement().execute("UPSERT INTO " + tableName + "(ID, \"COUNT\") VALUES(2.0, null)"); conn.commit(); ResultSet rs = conn.createStatement().executeQuery( "SELECT " - + "COALESCE(MIN(COUNT), ID) " + + "COALESCE(MIN(\"COUNT\"), ID) " + "FROM " + tableName + " GROUP BY ID"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java index 74cc068..ad45d5e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java @@ -395,7 +395,7 @@ public class DateTimeIT extends ParallelStatsDisabledIT { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(String - .format("SELECT %s FROM SYSTEM.CATALOG LIMIT 1", invocation)); + .format("SELECT %s FROM \"SYSTEM\".\"CATALOG\" LIMIT 1", invocation)); assertTrue(rs.next()); int returnValue = rs.getInt(1); assertFalse(rs.next()); @@ -815,7 +815,7 @@ public class DateTimeIT extends ParallelStatsDisabledIT { public void testLiteralDateTimestampComparison() throws Exception { ResultSet rs = conn.createStatement().executeQuery( - "select DATE '2016-05-10 00:00:00' > TIMESTAMP '2016-05-11 00:00:00'"); + "select \"DATE\" '2016-05-10 00:00:00' > \"TIMESTAMP\" '2016-05-11 00:00:00'"); assertTrue(rs.next()); assertEquals(false, rs.getBoolean(1)); @@ -826,7 +826,7 @@ public class DateTimeIT extends ParallelStatsDisabledIT { public void testLiteralDateTimestampComparison2() throws Exception { ResultSet rs = conn.createStatement().executeQuery( - "select TIMESTAMP '2016-05-10 00:00:00' > DATE '2016-05-11 00:00:00'"); + "select \"TIMESTAMP\" '2016-05-10 00:00:00' > \"DATE\" '2016-05-11 00:00:00'"); assertTrue(rs.next()); assertEquals(false, rs.getBoolean(1)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java index 9f514b3..09e1021 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java @@ -299,11 +299,11 @@ public class DeleteIT extends ParallelStatsDisabledIT { "HOST CHAR(2) NOT NULL," + "DOMAIN VARCHAR NOT NULL, " + "FEATURE VARCHAR NOT NULL, " + - "DATE DATE NOT NULL, \n" + + "\"DATE\" DATE NOT NULL, \n" + "USAGE.CORE BIGINT," + "USAGE.DB BIGINT," + "STATS.ACTIVE_VISITOR INTEGER " + - "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, DATE))" + (isSalted ? " SALT_BUCKETS=3" : ""); + "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, \"DATE\"))" + (isSalted ? " SALT_BUCKETS=3" : ""); stm.execute(s); String localIndexName = generateUniqueName(); String indexName = generateUniqueName(); @@ -315,7 +315,7 @@ public class DeleteIT extends ParallelStatsDisabledIT { stm.close(); PreparedStatement psInsert = con - .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, DATE, CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); + .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, \"DATE\", CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); psInsert.setString(1, "AA"); psInsert.setString(2, "BB"); psInsert.setString(3, "CC"); @@ -380,18 +380,18 @@ public class DeleteIT extends ParallelStatsDisabledIT { "HOST CHAR(2) NOT NULL," + "DOMAIN VARCHAR NOT NULL, " + "FEATURE VARCHAR NOT NULL, " + - "DATE DATE NOT NULL, \n" + + "\"DATE\" DATE NOT NULL, \n" + "USAGE.CORE BIGINT," + "USAGE.DB BIGINT," + "STATS.ACTIVE_VISITOR INTEGER " + - "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, DATE)) IMMUTABLE_ROWS=true"); - stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName1 + " ON " + tableName + " (DATE, FEATURE)"); - stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName2 + " ON " + tableName + " (DATE, FEATURE, USAGE.DB)"); + "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, \"DATE\")) IMMUTABLE_ROWS=true"); + stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName1 + " ON " + tableName + " (\"DATE\", FEATURE)"); + stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName2 + " ON " + tableName + " (\"DATE\", FEATURE, USAGE.DB)"); stm.close(); Date date = new Date(0); PreparedStatement psInsert = con - .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, DATE, CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); + .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, \"DATE\", CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); psInsert.setString(1, "AA"); psInsert.setString(2, "BB"); psInsert.setString(3, "CC"); @@ -405,7 +405,7 @@ public class DeleteIT extends ParallelStatsDisabledIT { con.commit(); } - psInsert = con.prepareStatement("DELETE FROM " + tableName + " WHERE (HOST, DOMAIN, FEATURE, DATE) = (?,?,?,?)"); + psInsert = con.prepareStatement("DELETE FROM " + tableName + " WHERE (HOST, DOMAIN, FEATURE, \"DATE\") = (?,?,?,?)"); psInsert.setString(1, "AA"); psInsert.setString(2, "BB"); psInsert.setString(3, "CC"); @@ -427,7 +427,7 @@ public class DeleteIT extends ParallelStatsDisabledIT { stm.execute("DROP INDEX " + indexName2 + " ON " + tableName); stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName1 + " ON " + tableName + " (USAGE.DB)"); - stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName2 + " ON " + tableName + " (USAGE.DB, DATE)"); + stm.execute("CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName2 + " ON " + tableName + " (USAGE.DB, \"DATE\")"); try{ psInsert = con.prepareStatement("DELETE FROM " + tableName + " WHERE USAGE.DB=2"); } catch(Exception e) { @@ -465,15 +465,15 @@ public class DeleteIT extends ParallelStatsDisabledIT { " HOST CHAR(2) NOT NULL," + "DOMAIN VARCHAR NOT NULL, " + "FEATURE VARCHAR NOT NULL, " + - "DATE DATE NOT NULL, \n" + + "\"DATE\" DATE NOT NULL, \n" + "USAGE.CORE BIGINT," + "USAGE.DB BIGINT," + "STATS.ACTIVE_VISITOR INTEGER " + - "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, DATE))"); + "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, \"DATE\"))"); stm.close(); PreparedStatement psInsert = con - .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, DATE, CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); + .prepareStatement("UPSERT INTO " + tableName + "(HOST, DOMAIN, FEATURE, \"DATE\", CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)"); psInsert.setString(1, "AA"); psInsert.setString(2, "BB"); psInsert.setString(3, "CC"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java index 1e450de..8edbaa6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java @@ -39,7 +39,7 @@ public class EvaluationOfORIT extends ParallelStatsDisabledIT{ public void testFalseOrFalse() throws SQLException { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); - ResultSet rs = conn.createStatement().executeQuery("SELECT (FALSE OR FALSE) AS B FROM SYSTEM.CATALOG LIMIT 1"); + ResultSet rs = conn.createStatement().executeQuery("SELECT (FALSE OR FALSE) AS B FROM \"SYSTEM\".\"CATALOG\" LIMIT 1"); assertTrue(rs.next()); assertFalse(rs.getBoolean(1)); conn.close(); @@ -53,8 +53,7 @@ public class EvaluationOfORIT extends ParallelStatsDisabledIT{ conn.setAutoCommit(false); String create = "CREATE TABLE " + tableName + " ( ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(50))"; - PreparedStatement createStmt = conn.prepareStatement(create); - createStmt.execute(); + conn.createStatement().execute(create); PreparedStatement stmt = conn.prepareStatement( "upsert into " + tableName + " VALUES (?, ?)"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java index 56a94b3..5ceb412 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java @@ -412,21 +412,21 @@ public class GroupByCaseIT extends ParallelStatsDisabledIT { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); - ResultSet rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); + ResultSet rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + "\"SYSTEM\".\"STATS\"" + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); assertTrue(rs.next()); assertEquals(0,rs.getInt(1)); initAvgGroupTable(conn, tableName, PhoenixDatabaseMetaData.GUIDE_POSTS_WIDTH + "=20 "); testAvgGroupByOrderPreserving(conn, tableName, 13); - rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); + rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + "\"SYSTEM\".\"STATS\"" + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); assertTrue(rs.next()); assertEquals(13,rs.getInt(1)); conn.setAutoCommit(true); - conn.createStatement().execute("DELETE FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME); - rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); + conn.createStatement().execute("DELETE FROM " + "\"SYSTEM\".\"STATS\""); + rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + "\"SYSTEM\".\"STATS\"" + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); assertTrue(rs.next()); assertEquals(0,rs.getInt(1)); TestUtil.doMajorCompaction(conn, tableName); - rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); + rs = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + "\"SYSTEM\".\"STATS\"" + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + " ='" + tableName + "'"); assertTrue(rs.next()); assertEquals(13,rs.getInt(1)); testAvgGroupByOrderPreserving(conn, tableName, 13); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index f0c781f..b9fa15b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -576,7 +576,7 @@ public class GroupByIT extends BaseQueryIT { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); Connection conn = DriverManager.getConnection(getUrl(), props); - String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; + String ddl = "create table test1(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))"; conn.createStatement().execute(ddl); conn.close(); @@ -596,7 +596,7 @@ public class GroupByIT extends BaseQueryIT { props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); conn = DriverManager.getConnection(getUrl(), props); ResultSet rs; - stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); + stmt = conn.prepareStatement("select \"time\"/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); rs = stmt.executeQuery(); assertTrue(rs.next()); assertEquals(143985345, rs.getInt(1)); @@ -612,7 +612,7 @@ public class GroupByIT extends BaseQueryIT { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); Connection conn = DriverManager.getConnection(getUrl(), props); - String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; + String ddl = "create table test1(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))"; conn.createStatement().execute(ddl); conn.close(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java index 52e8006..c76eb67 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java @@ -236,13 +236,8 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { + " colA2 VARCHAR " + "CONSTRAINT PK PRIMARY KEY" + "(pkA)" + ")"; String ddlB = "CREATE TABLE " + tableB + " (pkB INTEGER NOT NULL PRIMARY KEY, " + " colB INTEGER)"; - stmt = conn.prepareStatement(ddlA); - stmt.execute(); - stmt.close(); - - stmt = conn.prepareStatement(ddlB); - stmt.execute(); - stmt.close(); + conn.createStatement().execute(ddlA); + conn.createStatement().execute(ddlB); String upsertA = "UPSERT INTO " + tableA + " (pkA, colA1, colA2) VALUES(?, ?, ?)"; stmt = conn.prepareStatement(upsertA); @@ -498,15 +493,15 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { " TENANTID UNSIGNED_INT NOT NULL" + ",ID UNSIGNED_INT NOT NULL" + ",FOO UNSIGNED_INT NOT NULL" + - ",TIMESTAMP UNSIGNED_LONG NOT NULL" + + ",\"TIMESTAMP\" UNSIGNED_LONG NOT NULL" + ",CODES INTEGER ARRAY[] NOT NULL" + ",V UNSIGNED_LONG" + - " CONSTRAINT pk PRIMARY KEY (TENANTID, ID, FOO, TIMESTAMP, CODES))" + + " CONSTRAINT pk PRIMARY KEY (TENANTID, ID, FOO, \"TIMESTAMP\" , CODES))" + " DEFAULT_COLUMN_FAMILY ='E'," + " MULTI_TENANT=true"); PreparedStatement upsertStmt = conn.prepareStatement( "upsert into INVENTORY " - + "(tenantid, id, foo, timestamp, codes) " + + "(tenantid, id, foo, \"TIMESTAMP\" , codes) " + "values (?, ?, ?, ?, ?)"); upsertStmt.setInt(1, 15); upsertStmt.setInt(2, 5); @@ -672,16 +667,16 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { "CREATE TABLE IF NOT EXISTS EVENT_COUNT (\n" + " BUCKET VARCHAR,\n" + " TIMESTAMP_DATE TIMESTAMP,\n" + - " TIMESTAMP UNSIGNED_LONG NOT NULL,\n" + + " \"TIMESTAMP\" UNSIGNED_LONG NOT NULL,\n" + " LOCATION VARCHAR,\n" + " A VARCHAR,\n" + " B VARCHAR,\n" + " C VARCHAR,\n" + " D UNSIGNED_LONG,\n" + " E FLOAT\n" + - " CONSTRAINT pk PRIMARY KEY (BUCKET, TIMESTAMP DESC, LOCATION, A, B, C)\n" + + " CONSTRAINT pk PRIMARY KEY (BUCKET, \"TIMESTAMP\" DESC, LOCATION, A, B, C)\n" + ") SALT_BUCKETS=2, COMPRESSION='GZ', TTL=31622400"); - PreparedStatement stmt = conn.prepareStatement("UPSERT INTO EVENT_COUNT(BUCKET, TIMESTAMP, LOCATION, A, B, C) VALUES(?,?,?,?,?,?)"); + PreparedStatement stmt = conn.prepareStatement("UPSERT INTO EVENT_COUNT(BUCKET, \"TIMESTAMP\", LOCATION, A, B, C) VALUES(?,?,?,?,?,?)"); stmt.setString(1, "5SEC"); stmt.setString(3, "Tr/Bal"); stmt.setString(4, "A1"); @@ -733,7 +728,7 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { "CREATE TABLE IF NOT EXISTS " + t[i] + " (\n" + " BUCKET VARCHAR,\n" + " TIMESTAMP_DATE TIMESTAMP,\n" + - " TIMESTAMP UNSIGNED_LONG NOT NULL,\n" + + " \"TIMESTAMP\" UNSIGNED_LONG NOT NULL,\n" + " SRC_LOCATION VARCHAR,\n" + " DST_LOCATION VARCHAR,\n" + " B VARCHAR,\n" + @@ -742,9 +737,9 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { " G UNSIGNED_LONG,\n" + " H UNSIGNED_LONG,\n" + " I UNSIGNED_LONG\n" + - " CONSTRAINT pk PRIMARY KEY (BUCKET, TIMESTAMP" + (i == 0 ? " DESC" : "") + ", SRC_LOCATION, DST_LOCATION, B, C)\n" + + " CONSTRAINT pk PRIMARY KEY (BUCKET, \"TIMESTAMP\"" + (i == 0 ? " DESC" : "") + ", SRC_LOCATION, DST_LOCATION, B, C)\n" + ") SALT_BUCKETS=2, COMPRESSION='GZ', TTL=31622400"); - stmt = conn.prepareStatement("UPSERT INTO " + t[i] + "(BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION, B, C) VALUES(?,?,?,?,?,?)"); + stmt = conn.prepareStatement("UPSERT INTO " + t[i] + "(BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION, B, C) VALUES(?,?,?,?,?,?)"); stmt.setString(1, "5SEC"); stmt.setString(3, "Tr/Bal"); stmt.setString(4, "Tr/Bal"); @@ -772,25 +767,25 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { stmt.execute(); String q = - "SELECT C.BUCKET, C.TIMESTAMP FROM (\n" + - " SELECT E.BUCKET as BUCKET, L.BUCKET as LBUCKET, E.TIMESTAMP as TIMESTAMP, L.TIMESTAMP as LTIMESTAMP FROM\n" + - " (SELECT BUCKET, TIMESTAMP FROM EVENT_COUNT\n" + + "SELECT C.BUCKET, C.\"TIMESTAMP\" FROM (\n" + + " SELECT E.BUCKET as BUCKET, L.BUCKET as LBUCKET, E.\"TIMESTAMP\" as TIMESTAMP, L.\"TIMESTAMP\" as LTIMESTAMP FROM\n" + + " (SELECT BUCKET, \"TIMESTAMP\" FROM EVENT_COUNT\n" + " WHERE BUCKET = '5SEC' AND LOCATION = 'Tr/Bal'\n" + - " AND TIMESTAMP <= 1462993520000000000 AND TIMESTAMP > 1462993420000000000\n" + + " AND \"TIMESTAMP\" <= 1462993520000000000 AND \"TIMESTAMP\" > 1462993420000000000\n" + " ) E\n" + " JOIN\n" + - " (SELECT BUCKET, TIMESTAMP FROM "+ t[i] +"\n" + + " (SELECT BUCKET, \"TIMESTAMP\" FROM "+ t[i] +"\n" + " WHERE BUCKET = '5SEC' AND SRC_LOCATION = 'Tr/Bal' AND SRC_LOCATION = DST_LOCATION\n" + - " AND TIMESTAMP <= 1462993520000000000 AND TIMESTAMP > 1462993420000000000\n" + + " AND \"TIMESTAMP\" <= 1462993520000000000 AND \"TIMESTAMP\" > 1462993420000000000\n" + " ) L\n" + - " ON L.BUCKET = E.BUCKET AND L.TIMESTAMP = E.TIMESTAMP\n" + + " ON L.BUCKET = E.BUCKET AND L.\"TIMESTAMP\" = E.\"TIMESTAMP\"\n" + " ) C\n" + - " GROUP BY C.BUCKET, C.TIMESTAMP"; + " GROUP BY C.BUCKET, C.\"TIMESTAMP\""; String p = i == 0 ? "CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER EVENT_COUNT [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY\n" + - " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]\n" + + " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, \"E.TIMESTAMP\"]\n" + "CLIENT MERGE SORT\n" + " PARALLEL INNER-JOIN TABLE 0 (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + @@ -799,7 +794,7 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { : "CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER EVENT_COUNT [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY\n" + - " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]\n" + + " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, \"E.TIMESTAMP\"]\n" + "CLIENT MERGE SORT\n" + " PARALLEL INNER-JOIN TABLE 0 (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',1462993420000000001,'Tr/Bal'] - [1,'5SEC',1462993520000000000,'Tr/Bal']\n" + http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java index a08ba39..992e55f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java @@ -186,13 +186,8 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { + " colA2 VARCHAR " + "CONSTRAINT PK PRIMARY KEY" + "(pkA)" + ")"; String ddlB = "CREATE TABLE " + tableB + " (pkB INTEGER NOT NULL PRIMARY KEY, " + " colB INTEGER)"; - stmt = conn.prepareStatement(ddlA); - stmt.execute(); - stmt.close(); - - stmt = conn.prepareStatement(ddlB); - stmt.execute(); - stmt.close(); + conn.createStatement().execute(ddlA); + conn.createStatement().execute(ddlB); String upsertA = "UPSERT INTO " + tableA + " (pkA, colA1, colA2) VALUES(?, ?, ?)"; stmt = conn.prepareStatement(upsertA); @@ -313,16 +308,16 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { "CREATE TABLE IF NOT EXISTS " + eventCountTableName + " (\n" + " BUCKET VARCHAR,\n" + " TIMESTAMP_DATE TIMESTAMP,\n" + - " TIMESTAMP UNSIGNED_LONG NOT NULL,\n" + + " \"TIMESTAMP\" UNSIGNED_LONG NOT NULL,\n" + " LOCATION VARCHAR,\n" + " A VARCHAR,\n" + " B VARCHAR,\n" + " C VARCHAR,\n" + " D UNSIGNED_LONG,\n" + " E FLOAT\n" + - " CONSTRAINT pk PRIMARY KEY (BUCKET, TIMESTAMP DESC, LOCATION, A, B, C)\n" + + " CONSTRAINT pk PRIMARY KEY (BUCKET, \"TIMESTAMP\" DESC, LOCATION, A, B, C)\n" + ") SALT_BUCKETS=2, COMPRESSION='GZ', TTL=31622400"); - PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + eventCountTableName + "(BUCKET, TIMESTAMP, LOCATION, A, B, C) VALUES(?,?,?,?,?,?)"); + PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + eventCountTableName + "(BUCKET, \"TIMESTAMP\", LOCATION, A, B, C) VALUES(?,?,?,?,?,?)"); stmt.setString(1, "5SEC"); stmt.setString(3, "Tr/Bal"); stmt.setString(4, "A1"); @@ -374,7 +369,7 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { "CREATE TABLE IF NOT EXISTS " + t[i] + " (\n" + " BUCKET VARCHAR,\n" + " TIMESTAMP_DATE TIMESTAMP,\n" + - " TIMESTAMP UNSIGNED_LONG NOT NULL,\n" + + " \"TIMESTAMP\" UNSIGNED_LONG NOT NULL,\n" + " SRC_LOCATION VARCHAR,\n" + " DST_LOCATION VARCHAR,\n" + " B VARCHAR,\n" + @@ -383,9 +378,9 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { " G UNSIGNED_LONG,\n" + " H UNSIGNED_LONG,\n" + " I UNSIGNED_LONG\n" + - " CONSTRAINT pk PRIMARY KEY (BUCKET, TIMESTAMP" + (i == 0 ? " DESC" : "") + ", SRC_LOCATION, DST_LOCATION, B, C)\n" + + " CONSTRAINT pk PRIMARY KEY (BUCKET, \"TIMESTAMP\"" + (i == 0 ? " DESC" : "") + ", SRC_LOCATION, DST_LOCATION, B, C)\n" + ") SALT_BUCKETS=2, COMPRESSION='GZ', TTL=31622400"); - stmt = conn.prepareStatement("UPSERT INTO " + t[i] + "(BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION, B, C) VALUES(?,?,?,?,?,?)"); + stmt = conn.prepareStatement("UPSERT INTO " + t[i] + "(BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION, B, C) VALUES(?,?,?,?,?,?)"); stmt.setString(1, "5SEC"); stmt.setString(3, "Tr/Bal"); stmt.setString(4, "Tr/Bal"); @@ -421,10 +416,10 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { " GROUP BY BUCKET, TIMESTAMP, LOCATION\n" + " ) E\n" + " JOIN\n" + - " (SELECT BUCKET, TIMESTAMP FROM "+ t[i] +"\n" + + " (SELECT BUCKET, \"TIMESTAMP\" FROM "+ t[i] +"\n" + " WHERE BUCKET = '5SEC' AND SRC_LOCATION = 'Tr/Bal' AND SRC_LOCATION = DST_LOCATION\n" + - " AND TIMESTAMP <= 1462993520000000000 AND TIMESTAMP > 1462993420000000000\n" + - " GROUP BY BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION\n" + + " AND \"TIMESTAMP\" <= 1462993520000000000 AND \"TIMESTAMP\" > 1462993420000000000\n" + + " GROUP BY BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION\n" + " ) L\n" + " ON L.BUCKET = E.BUCKET AND L.TIMESTAMP = E.TIMESTAMP\n" + " ) C\n" + @@ -441,10 +436,10 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { "AND (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY AND SRC_LOCATION = DST_LOCATION\n" + - " SERVER DISTINCT PREFIX FILTER OVER [BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION]\n" + - " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION]\n" + + " SERVER DISTINCT PREFIX FILTER OVER [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + + " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + " CLIENT MERGE SORT\n" + - " CLIENT SORTED BY [BUCKET, TIMESTAMP]\n" + + " CLIENT SORTED BY [BUCKET, \"TIMESTAMP\"]\n" + "CLIENT SORTED BY [E.BUCKET, E.TIMESTAMP]\n" + "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]" : @@ -458,8 +453,8 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { "AND (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',1462993420000000001,'Tr/Bal'] - [1,'5SEC',1462993520000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY AND SRC_LOCATION = DST_LOCATION\n" + - " SERVER DISTINCT PREFIX FILTER OVER [BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION]\n" + - " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, TIMESTAMP, SRC_LOCATION, DST_LOCATION]\n" + + " SERVER DISTINCT PREFIX FILTER OVER [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + + " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + " CLIENT MERGE SORT\n" + "CLIENT SORTED BY [E.BUCKET, E.TIMESTAMP]\n" + "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]"; http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java index c810844..655dbb1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java @@ -370,7 +370,7 @@ public class SortOrderIT extends ParallelStatsDisabledIT { @Test public void queryDescDateWithExplicitOrderBy() throws Exception { String table = generateUniqueName(); - String ddl = "CREATE table " + table + " (c1 CHAR(1) NOT NULL, c2 CHAR(1) NOT NULL, d1 DATE NOT NULL, c3 CHAR(1) NOT NULL " + + String ddl = "CREATE table " + table + " (c1 CHAR(1) NOT NULL, c2 CHAR(1) NOT NULL, d1 \"DATE\" NOT NULL, c3 CHAR(1) NOT NULL " + "constraint pk primary key (c1, c2, d1 DESC, c3))"; Object[] row1 = {"1", "2", date(10, 11, 2001), "3"}; Object[] row2 = {"1", "2", date(10, 11, 2003), "3"}; @@ -408,7 +408,7 @@ public class SortOrderIT extends ParallelStatsDisabledIT { @Test public void lessThanLeadingDescCompositePK() throws Exception { String table = generateUniqueName(); - String ddl = "CREATE table " + table + " (id INTEGER NOT NULL, \"DATE\" DATE NOT NULL constraint pk primary key (id DESC, date))"; + String ddl = "CREATE table " + table + " (id INTEGER NOT NULL, \"DATE\" DATE NOT NULL constraint pk primary key (id DESC, \"DATE\"))"; Object[][] insertedRows = new Object[][]{{1, date(1, 1, 2012)}, {3, date(1, 1, 2013)}, {2, date(1, 1, 2011)}}; Object[][] expectedRows = new Object[][]{{1, date(1, 1, 2012)}}; runQueryTest(ddl, upsert("id", "date"), insertedRows, expectedRows, new WhereCondition("id", "<", "2"), @@ -418,10 +418,10 @@ public class SortOrderIT extends ParallelStatsDisabledIT { @Test public void lessThanTrailingDescCompositePK() throws Exception { String table = generateUniqueName(); - String ddl = "CREATE table " + table + " (id INTEGER NOT NULL, \"DATE\" DATE NOT NULL constraint pk primary key (id DESC, date))"; + String ddl = "CREATE table " + table + " (id INTEGER NOT NULL, \"DATE\" DATE NOT NULL constraint pk primary key (id DESC, \"DATE\"))"; Object[][] insertedRows = new Object[][]{{1, date(1, 1, 2002)}, {3, date(1, 1, 2003)}, {2, date(1, 1, 2001)}}; Object[][] expectedRows = new Object[][]{{2, date(1, 1, 2001)}}; - runQueryTest(ddl, upsert("id", "DATE"), insertedRows, expectedRows, new WhereCondition("DATE", "<", "TO_DATE('02-02-2001','mm-dd-yyyy')"), + runQueryTest(ddl, upsert("id", "\"DATE\""), insertedRows, expectedRows, new WhereCondition("\"DATE\"", "<", "TO_DATE('02-02-2001','mm-dd-yyyy')"), table); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java index b8f8177..e4479ac 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDDLIT.java @@ -152,7 +152,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { public void testCreationOfParentTableFailsOnTenantSpecificConnection() throws Exception { try { createTestTable(PHOENIX_JDBC_TENANT_SPECIFIC_URL, "CREATE TABLE " + generateUniqueName() + "( \n" + - " user VARCHAR ,\n" + + " \"user\" VARCHAR ,\n" + " id INTEGER not null primary key desc\n" + " ) "); fail(); @@ -178,7 +178,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { } String newDDL = "CREATE TABLE DIFFSCHEMA." + PARENT_TABLE_NAME + " ( \n" + - " user VARCHAR ,\n" + + " \"user\" VARCHAR ,\n" + " tenant_id VARCHAR(5) NOT NULL,\n" + " tenant_type_id VARCHAR(3) NOT NULL, \n" + " id INTEGER NOT NULL\n" + @@ -199,7 +199,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { @Test(expected=ColumnAlreadyExistsException.class) public void testTenantSpecificTableCannotOverrideParentCol() throws SQLException { createTestTable(PHOENIX_JDBC_TENANT_SPECIFIC_URL, "CREATE VIEW " + generateUniqueName() + " ( \n" + - " user INTEGER) AS SELECT *\n" + + " \"user\" INTEGER) AS SELECT *\n" + " FROM " + PARENT_TABLE_NAME); } @@ -285,7 +285,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { // try removing a non-PK col, which is allowed try { - conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column user"); + conn.createStatement().execute("alter table " + PARENT_TABLE_NAME + " drop column \"user\""); } catch (SQLException expected) { fail("We should be able to drop a non pk base table column"); @@ -525,7 +525,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { // make sure tenants see parent table's columns and their own rs = meta.getColumns(null, null, StringUtil.escapeLike(TENANT_TABLE_NAME), null); assertTrue(rs.next()); - assertColumnMetaData(rs, null, TENANT_TABLE_NAME, "user", 1); + assertColumnMetaData(rs, null, TENANT_TABLE_NAME, "\"user\"", 1); assertTrue(rs.next()); // (tenant_id column is not visible in tenant-specific connection) assertColumnMetaData(rs, null, TENANT_TABLE_NAME, "tenant_type_id", 2); @@ -538,7 +538,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { rs = meta.getColumns(null, null, StringUtil.escapeLike(TENANT_TABLE_NAME_NO_TENANT_TYPE_ID), null); assertTrue(rs.next()); - assertColumnMetaData(rs, null, TENANT_TABLE_NAME_NO_TENANT_TYPE_ID, "user", 1); + assertColumnMetaData(rs, null, TENANT_TABLE_NAME_NO_TENANT_TYPE_ID, "\"user\"", 1); assertTrue(rs.next()); // (tenant_id column is not visible in tenant-specific connection) assertColumnMetaData(rs, null, TENANT_TABLE_NAME_NO_TENANT_TYPE_ID, "id", 2); http://git-wip-us.apache.org/repos/asf/phoenix/blob/895cb1df/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java index 76625c0..55d38fd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificTablesDMLIT.java @@ -174,12 +174,12 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'abc', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); - ResultSet rs = conn.createStatement().executeQuery("select user from " + TENANT_TABLE_NAME); + ResultSet rs = conn.createStatement().executeQuery("select \"user\" from " + TENANT_TABLE_NAME); assertTrue("Expected 1 row in result set", rs.next()); assertEquals("Billy Gibbons", rs.getString(1)); assertFalse("Expected 1 row in result set", rs.next()); @@ -202,9 +202,9 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'abc', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); conn.setAutoCommit(true); @@ -231,14 +231,14 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'abc', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); Connection tsConn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); tsConn.setAutoCommit(true); - tsConn.createStatement().executeUpdate("create index idx1 on " + TENANT_TABLE_NAME + "(user)"); - int count = tsConn.createStatement().executeUpdate("delete from " + TENANT_TABLE_NAME + " where user='Billy Gibbons'"); + tsConn.createStatement().executeUpdate("create index idx1 on " + TENANT_TABLE_NAME + "(\"user\")"); + int count = tsConn.createStatement().executeUpdate("delete from " + TENANT_TABLE_NAME + " where \"user\"='Billy Gibbons'"); assertEquals("Expected 1 row have been deleted", 1, count); ResultSet rs = tsConn.createStatement().executeQuery("select * from " + TENANT_TABLE_NAME); assertFalse("Expected no rows in result set", rs.next()); @@ -261,9 +261,9 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('AC/DC', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('" + TENANT_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('" + TENANT_ID + "', 2, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('AC/DC', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 2, 'Billy Gibbons')"); Connection tsConn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); tsConn.setAutoCommit(true); @@ -289,9 +289,9 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'abc', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); analyzeTable(tsConn, PARENT_TABLE_NAME); tsConn.createStatement().execute("delete from " + TENANT_TABLE_NAME); @@ -315,9 +315,9 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('AC/DC', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('" + TENANT_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, user) values ('" + TENANT_ID + "', 2, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('AC/DC', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 2, 'Billy Gibbons')"); tsConn.createStatement().execute("drop view " + TENANT_TABLE_NAME_NO_TENANT_TYPE_ID); @@ -340,12 +340,12 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'aaa', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 2, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'aaa', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 2, 'Billy Gibbons')"); analyzeTable(tsConn, TENANT_TABLE_NAME); - int count = tsConn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + "(id, user) select id+100, user from " + TENANT_TABLE_NAME); + int count = tsConn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + "(id, \"user\") select id+100, \"user\" from " + TENANT_TABLE_NAME); tsConn.commit(); assertEquals("Expected 1 row to have been inserted", 1, count); @@ -371,14 +371,14 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { conn.setAutoCommit(true); conn.createStatement().executeUpdate("delete from " + PARENT_TABLE_NAME); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('AC/DC', 'aaa', 1, 'Bon Scott')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, user) values ('" + TENANT_ID + "', 'def', 2, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'aaa', 1, 'Bon Scott')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 2, 'Billy Gibbons')"); analyzeTable(tsConn, TENANT_TABLE_NAME); tsConn.setAutoCommit(true); - int count = tsConn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + "(id, user)" - + "select id+100, user from " + anotherTableName + " where id=2"); + int count = tsConn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + "(id, \"user\")" + + "select id+100, \"user\" from " + anotherTableName + " where id=2"); assertEquals("Expected 1 row to have been inserted", 1, count); ResultSet rs = tsConn.createStatement().executeQuery("select count(*) from " + TENANT_TABLE_NAME); rs.next(); @@ -395,7 +395,7 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); try { - int count = conn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + " (id, user) values (1, 'Bon Scott')"); + int count = conn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + " (id, \"user\") values (1, 'Bon Scott')"); conn.commit(); assertEquals("Expected 1 row to have been inserted", 1, count); ResultSet rs = conn.createStatement().executeQuery("select count(*) from " + TENANT_TABLE_NAME); @@ -414,10 +414,10 @@ public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { try { ResultSet rs = conn.createStatement().executeQuery("select * from " + PARENT_TABLE_NAME); assertFalse(rs.next()); - conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_type_id, id, user) values ('" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); + conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_type_id, id, \"user\") values ('" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); conn.commit(); analyzeTable(conn, PARENT_TABLE_NAME); - rs = conn.createStatement().executeQuery("select user from " + PARENT_TABLE_NAME); + rs = conn.createStatement().executeQuery("select \"user\" from " + PARENT_TABLE_NAME); assertTrue(rs.next()); assertEquals(rs.getString(1),"Billy Gibbons"); assertFalse(rs.next());