You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/09/17 07:07:00 UTC
[2/6] phoenix git commit: PHOENIX-3290 Move and/or combine as many
NeedsOwnCluster tests to bring down test run time
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
deleted file mode 100644
index c365934..0000000
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.end2end;
-
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.apache.phoenix.util.TestUtil.closeStmtAndConn;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.math.BigDecimal;
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import org.apache.phoenix.expression.function.CeilFunction;
-import org.apache.phoenix.expression.function.FloorFunction;
-import org.apache.phoenix.expression.function.RoundFunction;
-import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.util.DateUtil;
-import org.apache.phoenix.util.PhoenixRuntime;
-import org.apache.phoenix.util.PropertiesUtil;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.primitives.Doubles;
-import com.google.common.primitives.Floats;
-
-/**
- *
- * End to end tests for {@link RoundFunction}, {@link FloorFunction}, {@link CeilFunction}
- *
- *
- * @since 3.0.0
- */
-
-
-public class RoundFloorCeilFunctionsEnd2EndIT extends BaseHBaseManagedTimeTableReuseIT {
-
- private static final String TABLE_NAME = generateRandomString();
- private static long millisPart = 660;
- private static int nanosPart = 500100;
- private static BigDecimal decimalUpserted = BigDecimal.valueOf(1.264);
- private static double doubleUpserted = 1.264d;
- private static double unsignedDoubleUpserted = 1.264d;
- private static float floatUpserted = 1.264f;
- private static float unsignedFloatUpserted = 1.264f;
-
- @Before
- public void initTable() throws Exception {
- String testString = "abc";
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = DriverManager.getConnection(getUrl());
- String ddl = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
- + " (s VARCHAR NOT NULL PRIMARY KEY, dt DATE, t TIME, ts TIMESTAMP, dec DECIMAL, doub DOUBLE, undoub UNSIGNED_DOUBLE, fl FLOAT, unfl UNSIGNED_FLOAT)";
- conn.createStatement().execute(ddl);
-
- Date dateUpserted = DateUtil.parseDate("2012-01-01 14:25:28");
- dateUpserted = new Date(dateUpserted.getTime() + millisPart); // this makes the dateUpserted equivalent to 2012-01-01 14:25:28.660
- long millis = dateUpserted.getTime();
-
- Time timeUpserted = new Time(millis);
- Timestamp tsUpserted = DateUtil.getTimestamp(millis, nanosPart);
-
- stmt = conn.prepareStatement(
- "UPSERT INTO " + TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
- stmt.setString(1, testString);
- stmt.setDate(2, dateUpserted);
- stmt.setTime(3, timeUpserted);
- stmt.setTimestamp(4, tsUpserted);
- stmt.setBigDecimal(5, decimalUpserted);
- stmt.setDouble(6, doubleUpserted);
- stmt.setDouble(7, unsignedDoubleUpserted);
- stmt.setFloat(8, floatUpserted);
- stmt.setFloat(9, unsignedFloatUpserted);
- stmt.executeUpdate();
- conn.commit();
- } finally {
- closeStmtAndConn(stmt, conn);
- }
- }
-
- @Test
- public void testRoundingUpDate() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(dt, 'day'), ROUND(dt, 'hour', 1), ROUND(dt, 'minute', 1), ROUND(dt, 'second', 1), "
- + " ROUND(dt,'week'), ROUND(dt,'month') , ROUND(dt,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Date expectedDate = DateUtil.parseDate("2012-01-02 00:00:00");
- assertEquals(expectedDate, rs.getDate(1));
- expectedDate = DateUtil.parseDate("2012-01-01 14:00:00");
- assertEquals(expectedDate, rs.getDate(2));
- expectedDate = DateUtil.parseDate("2012-01-01 14:25:00");
- assertEquals(expectedDate, rs.getDate(3));
- expectedDate = DateUtil.parseDate("2012-01-01 14:25:29");
- assertEquals(expectedDate, rs.getDate(4));
- expectedDate = DateUtil.parseDate("2012-01-02 00:00:00");
- assertEquals(expectedDate, rs.getDate(5));
- expectedDate = DateUtil.parseDate("2012-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(6));
- expectedDate = DateUtil.parseDate("2012-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(7));
- }
-
- @Test
- public void testRoundingUpDateInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE ROUND(dt, 'day') = to_date('2012-01-02 00:00:00')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testFloorDate() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(dt, 'day', 1), FLOOR(dt, 'hour', 1), FLOOR(dt, 'minute', 1), FLOOR(dt, 'second', 1),"
- + " FLOOR(dt,'week'), FLOOR(dt,'month'), FLOOR(dt,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Date expectedDate = DateUtil.parseDate("2012-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(1));
- expectedDate = DateUtil.parseDate("2012-01-01 14:00:00");
- assertEquals(expectedDate, rs.getDate(2));
- expectedDate = DateUtil.parseDate("2012-01-01 14:25:00");
- assertEquals(expectedDate, rs.getDate(3));
- expectedDate = DateUtil.parseDate("2012-01-01 14:25:28");
- assertEquals(expectedDate, rs.getDate(4));
- expectedDate = DateUtil.parseDate("2011-12-26 00:00:00");
- assertEquals(expectedDate, rs.getDate(5));
- expectedDate = DateUtil.parseDate("2012-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(6));
- expectedDate = DateUtil.parseDate("2012-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(7));
- }
-
- @Test
- public void testFloorDateInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE FLOOR(dt, 'hour') = to_date('2012-01-01 14:00:00')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testCeilDate() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(dt, 'day', 1), CEIL(dt, 'hour', 1), CEIL(dt, 'minute', 1), CEIL(dt, 'second', 1), "
- + " CEIL(dt,'week') , CEIL(dt,'month') , CEIL(dt,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- //Date upserted is 2012-01-01 14:25:28.660. So we will end up bumping up in every case.
- Date expectedDate = DateUtil.parseDate("2012-01-02 00:00:00");
- assertEquals(expectedDate, rs.getDate(1));
- expectedDate = DateUtil.parseDate("2012-01-01 15:00:00");
- assertEquals(expectedDate, rs.getDate(2));
- expectedDate = DateUtil.parseDate("2012-01-01 14:26:00");
- assertEquals(expectedDate, rs.getDate(3));
- expectedDate = DateUtil.parseDate("2012-01-01 14:25:29");
- assertEquals(expectedDate, rs.getDate(4));
- expectedDate = DateUtil.parseDate("2012-01-02 00:00:00");
- System.out.println(String.format(" the expected time is [%s] and the actual time is [%s]",expectedDate.getTime(),rs.getDate(5).getTime()));
- assertEquals(expectedDate, rs.getDate(5));
- expectedDate = DateUtil.parseDate("2012-02-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(6));
- expectedDate = DateUtil.parseDate("2013-01-01 00:00:00");
- assertEquals(expectedDate, rs.getDate(7));
- }
-
- @Test
- public void testCeilDateInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE CEIL(dt, 'second') = to_date('2012-01-01 14:25:29')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testRoundingUpTimestamp() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(ts, 'day'), ROUND(ts, 'hour', 1), ROUND(ts, 'minute', 1), ROUND(ts, 'second', 1), ROUND(ts, 'millisecond', 1) FROM "
- + TABLE_NAME);
- assertTrue(rs.next());
- Timestamp expectedTimestamp;
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(1));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(2));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(3));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:29").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(4));
-
- // Rounding of "2012-01-01 14:25:28.660" + nanosPart will end up bumping up the millisecond part of date.
- // That is, it should be evaluated as "2012-01-01 14:25:28.661".
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:28").getTime() + millisPart + 1);
- assertEquals(expectedTimestamp, rs.getTimestamp(5));
- }
-
- @Test
- public void testRoundingUpTimestampInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE ROUND(ts, 'second') = to_date('2012-01-01 14:25:29')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testFloorTimestamp() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(ts, 'day'), FLOOR(ts, 'hour', 1), FLOOR(ts, 'minute', 1), FLOOR(ts, 'second', 1), "
- + " FLOOR(ts, 'millisecond', 1) , FLOOR(ts,'week') , FLOOR(ts,'month') FROM "
- + TABLE_NAME);
- assertTrue(rs.next());
- Timestamp expectedTimestamp;
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(1));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(2));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(3));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:28").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(4));
-
- // FLOOR of "2012-01-01 14:25:28.660" + nanosPart will end up removing the nanos part.
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:28").getTime() + millisPart);
- assertEquals(expectedTimestamp, rs.getTimestamp(5));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2011-12-26 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(6));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(7));
- }
-
- @Test
- public void testFloorTimestampInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE FLOOR(ts, 'second') = to_date('2012-01-01 14:25:28')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testWeekFloorTimestampInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE FLOOR(ts, 'week') = to_date('2011-12-26 00:00:00')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testCeilTimestamp() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(ts, 'day'), CEIL(ts, 'hour', 1), CEIL(ts, 'minute', 1), CEIL(ts, 'second', 1), CEIL(ts, 'millisecond', 1),"
- + " CEIL(ts,'week'), CEIL(ts,'month') , CEIL(ts,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Timestamp expectedTimestamp;
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(1));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 15:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(2));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:26:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(3));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:29").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(4));
-
- // CEIL of "2012-01-01 14:25:28.660" + nanosPart will end up bumping up the millisecond part of date.
- // That is, it should be evaluated as "2012-01-01 14:25:28.661".
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-01 14:25:28").getTime() + millisPart + 1);
- assertEquals(expectedTimestamp, rs.getTimestamp(5));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(6));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2012-02-01 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(7));
- expectedTimestamp = new Timestamp(DateUtil.parseDate("2013-01-01 00:00:00").getTime());
- assertEquals(expectedTimestamp, rs.getTimestamp(8));
- }
-
- @Test
- public void testCeilTimestampInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + TABLE_NAME
- + " WHERE CEIL(ts, 'second') = to_date('2012-01-01 14:25:29')");
- assertTrue(rs.next());
- }
-
- @Test
- public void testRoundingUpTime() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(t, 'day', 1), ROUND(t, 'hour', 1), ROUND(t, 'minute', 1), ROUND(t, 'second', 1),"
- + " ROUND(t,'week') , ROUND(t,'month') , ROUND(t,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Time expectedTime = new Time(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(1));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(2));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:25:00").getTime());
- assertEquals(expectedTime, rs.getTime(3));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:25:29").getTime());
- assertEquals(expectedTime, rs.getTime(4));
- expectedTime = new Time(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(5));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(6));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(7));
- }
-
- @Test
- public void testFloorTime() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(t, 'day', 1), FLOOR(t, 'hour', 1), FLOOR(t, 'minute', 1), FLOOR(t, 'second', 1), "
- + " FLOOR(t, 'week'), FLOOR(t, 'month'), FLOOR(t, 'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Time expectedTime = new Time(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(1));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(2));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:25:00").getTime());
- assertEquals(expectedTime, rs.getTime(3));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:25:28").getTime());
- assertEquals(expectedTime, rs.getTime(4));
- expectedTime = new Time(DateUtil.parseDate("2011-12-26 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(5));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(6));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(7));
- }
-
- @Test
- public void testCeilTime() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(t, 'day', 1), CEIL(t, 'hour', 1), CEIL(t, 'minute', 1), CEIL(t, 'second', 1),"
- + " CEIL(t,'week') , CEIL(t,'month') , CEIL(t,'year') FROM " + TABLE_NAME);
- assertTrue(rs.next());
- Time expectedTime = new Time(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(1));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 15:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(2));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:26:00").getTime());
- assertEquals(expectedTime, rs.getTime(3));
- expectedTime = new Time(DateUtil.parseDate("2012-01-01 14:25:29").getTime());
- assertEquals(expectedTime, rs.getTime(4));
- expectedTime = new Time(DateUtil.parseDate("2012-01-02 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(5));
- expectedTime = new Time(DateUtil.parseDate("2012-02-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(6));
- expectedTime = new Time(DateUtil.parseDate("2013-01-01 00:00:00").getTime());
- assertEquals(expectedTime, rs.getTime(7));
- }
-
- @Test
- public void testRoundingUpDecimal() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(dec), ROUND(dec, 1), ROUND(dec, 2), ROUND(dec, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- BigDecimal expectedBd = BigDecimal.valueOf(1);
- assertEquals(expectedBd, rs.getBigDecimal(1));
- expectedBd = BigDecimal.valueOf(1.3);
- assertEquals(expectedBd, rs.getBigDecimal(2));
- expectedBd = BigDecimal.valueOf(1.26);
- assertEquals(expectedBd, rs.getBigDecimal(3));
- expectedBd = BigDecimal.valueOf(1.264);
- assertEquals(expectedBd, rs.getBigDecimal(4));
- }
-
- @Test
- public void testRoundingUpDecimalInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE ROUND(dec, 2) = 1.26");
- assertTrue(rs.next());
- }
-
- @Test
- public void testFloorDecimal() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT FLOOR(dec), FLOOR(dec, 1), FLOOR(dec, 2), FLOOR(dec, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- BigDecimal expectedBd = BigDecimal.valueOf(1);
- assertEquals(expectedBd, rs.getBigDecimal(1));
- expectedBd = BigDecimal.valueOf(1.2);
- assertEquals(expectedBd, rs.getBigDecimal(2));
- expectedBd = BigDecimal.valueOf(1.26);
- assertEquals(expectedBd, rs.getBigDecimal(3));
- expectedBd = BigDecimal.valueOf(1.264);
- assertEquals(expectedBd, rs.getBigDecimal(4));
- }
-
- @Test
- public void testFloorDecimalInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE FLOOR(dec, 2) = 1.26");
- assertTrue(rs.next());
- }
-
- @Test
- public void testCeilDecimal() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT CEIL(dec), CEIL(dec, 1), CEIL(dec, 2), CEIL(dec, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- BigDecimal expectedBd = BigDecimal.valueOf(2);
- assertEquals(expectedBd, rs.getBigDecimal(1));
- expectedBd = BigDecimal.valueOf(1.3);
- assertEquals(expectedBd, rs.getBigDecimal(2));
- expectedBd = BigDecimal.valueOf(1.27);
- assertEquals(expectedBd, rs.getBigDecimal(3));
- expectedBd = BigDecimal.valueOf(1.264);
- assertEquals(expectedBd, rs.getBigDecimal(4));
- }
-
- @Test
- public void testCeilDecimalInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE CEIL(dec, 2) = 1.27");
- assertTrue(rs.next());
- }
- @Test
- public void testRoundingUpDouble() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(doub), ROUND(doub, 1), ROUND(doub, 2), ROUND(doub, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Doubles.compare(1, rs.getDouble(1)));
- assertEquals(0, Doubles.compare(1.3, rs.getDouble(2)));
- assertEquals(0, Doubles.compare(1.26, rs.getDouble(3)));
- assertEquals(0, Doubles.compare(1.264, rs.getDouble(4)));
- }
-
- @Test
- public void testRoundingUpDoubleInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE ROUND(dec, 2) = 1.26");
- assertTrue(rs.next());
- }
-
- @Test
- public void testCeilDouble() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT CEIL(doub), CEIL(doub, 1), CEIL(doub, 2), CEIL(doub, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Doubles.compare(2, rs.getDouble(1)));
- assertEquals(0, Doubles.compare(1.3, rs.getDouble(2)));
- assertEquals(0, Doubles.compare(1.27, rs.getDouble(3)));
- assertEquals(0, Doubles.compare(1.264, rs.getDouble(4)));
- }
-
- @Test
- public void testCeilDoubleInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE CEIL(doub, 2) = 1.27");
- assertTrue(rs.next());
- }
-
- @Test
- public void testFloorDouble() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT FLOOR(doub), FLOOR(doub, 1), FLOOR(doub, 2), FLOOR(doub, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Doubles.compare(1, rs.getDouble(1)));
- assertEquals(0, Doubles.compare(1.2, rs.getDouble(2)));
- assertEquals(0, Doubles.compare(1.26, rs.getDouble(3)));
- assertEquals(0, Doubles.compare(1.264, rs.getDouble(4)));
- }
-
- @Test
- public void testFloorDoubleInWhere() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT * FROM " + TABLE_NAME + " WHERE FLOOR(doub, 2) = 1.26");
- assertTrue(rs.next());
- }
-
- @Test
- public void testRoundFloat() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(fl), ROUND(fl, 1), ROUND(fl, 2), ROUND(fl, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Floats.compare(1, rs.getFloat(1)));
- assertEquals(0, Floats.compare(1.3f, rs.getFloat(2)));
- assertEquals(0, Floats.compare(1.26f, rs.getFloat(3)));
- assertEquals(0, Floats.compare(1.264f, rs.getFloat(4)));
- }
-
- @Test
- public void testRoundUnsignedFloat() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(unfl), ROUND(unfl, 1), ROUND(unfl, 2), ROUND(unfl, 3) FROM " + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Floats.compare(1, rs.getFloat(1)));
- assertEquals(0, Floats.compare(1.3f, rs.getFloat(2)));
- assertEquals(0, Floats.compare(1.26f, rs.getFloat(3)));
- assertEquals(0, Floats.compare(1.264f, rs.getFloat(4)));
- }
-
- @Test
- public void testRoundUnsignedDouble() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT ROUND(undoub), ROUND(undoub, 1), ROUND(undoub, 2), ROUND(undoub, 3) FROM "
- + TABLE_NAME);
- assertTrue(rs.next());
- assertEquals(0, Floats.compare(1, rs.getFloat(1)));
- assertEquals(0, Floats.compare(1.3f, rs.getFloat(2)));
- assertEquals(0, Floats.compare(1.26f, rs.getFloat(3)));
- assertEquals(0, Floats.compare(1.264f, rs.getFloat(4)));
- }
-
- @Test
- public void testTimestampAggregateFunctions() throws Exception {
- String dateString = "2015-03-08 09:09:11.665";
- Properties props = new Properties();
- props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1");
- Connection conn = DriverManager.getConnection(getUrl(), props);
- try {
- conn.prepareStatement(
- "create table TIME_AGG_TABLE("
- + "ID unsigned_int NOT NULL, "
- + "THE_DATE TIMESTAMP, "
- + "constraint PK primary key (ID))").execute();
- PreparedStatement stmt = conn.prepareStatement("upsert into "
- + "TIME_AGG_TABLE(" + " ID, " + " THE_DATE)"
- + "VALUES (?, ?)");
- stmt.setInt(1, 1);
- stmt.setTimestamp(2, DateUtil.parseTimestamp(dateString));
- stmt.execute();
- conn.commit();
-
- ResultSet rs = conn.prepareStatement(
- "SELECT THE_DATE ,TRUNC(THE_DATE,'DAY') AS day_from_dt "
- + ",TRUNC(THE_DATE,'HOUR') AS hour_from_dt "
- + ",TRUNC(THE_DATE,'MINUTE') AS min_from_dt "
- + ",TRUNC(THE_DATE,'SECOND') AS sec_from_dt "
- + ",TRUNC(THE_DATE,'MILLISECOND') AS mil_from_dt "
- + "FROM TIME_AGG_TABLE").executeQuery();
- assertTrue(rs.next());
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("THE_DATE"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 00:00:00.0"),
- rs.getTimestamp("day_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:00:00.0"),
- rs.getTimestamp("hour_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:00.0"),
- rs.getTimestamp("min_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.0"),
- rs.getTimestamp("sec_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("mil_from_dt"));
- rs.close();
-
- rs = conn.prepareStatement(
- "SELECT THE_DATE ,ROUND(THE_DATE,'DAY') AS day_from_dt "
- + ",ROUND(THE_DATE,'HOUR') AS hour_from_dt "
- + ",ROUND(THE_DATE,'MINUTE') AS min_from_dt "
- + ",ROUND(THE_DATE,'SECOND') AS sec_from_dt "
- + ",ROUND(THE_DATE,'MILLISECOND') AS mil_from_dt "
- + "FROM TIME_AGG_TABLE").executeQuery();
- assertTrue(rs.next());
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("THE_DATE"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 00:00:00.0"),
- rs.getTimestamp("day_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:00:00.0"),
- rs.getTimestamp("hour_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:00.0"),
- rs.getTimestamp("min_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:12.0"),
- rs.getTimestamp("sec_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("mil_from_dt"));
- rs.close();
-
- rs = conn.prepareStatement(
- "SELECT THE_DATE ,FLOOR(THE_DATE,'DAY') AS day_from_dt "
- + ",FLOOR(THE_DATE,'HOUR') AS hour_from_dt "
- + ",FLOOR(THE_DATE,'MINUTE') AS min_from_dt "
- + ",FLOOR(THE_DATE,'SECOND') AS sec_from_dt "
- + ",FLOOR(THE_DATE,'MILLISECOND') AS mil_from_dt "
- + "FROM TIME_AGG_TABLE").executeQuery();
- assertTrue(rs.next());
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("THE_DATE"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 00:00:00.0"),
- rs.getTimestamp("day_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:00:00.0"),
- rs.getTimestamp("hour_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:00.0"),
- rs.getTimestamp("min_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.0"),
- rs.getTimestamp("sec_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("mil_from_dt"));
- rs.close();
-
- rs = conn.prepareStatement(
- "SELECT THE_DATE ,CEIL(THE_DATE,'DAY') AS day_from_dt "
- + ",CEIL(THE_DATE,'HOUR') AS hour_from_dt "
- + ",CEIL(THE_DATE,'MINUTE') AS min_from_dt "
- + ",CEIL(THE_DATE,'SECOND') AS sec_from_dt "
- + ",CEIL(THE_DATE,'MILLISECOND') AS mil_from_dt "
- + "FROM TIME_AGG_TABLE").executeQuery();
- assertTrue(rs.next());
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("THE_DATE"));
- assertEquals(DateUtil.parseTimestamp("2015-03-09 00:00:00.0"),
- rs.getTimestamp("day_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 10:00:00.0"),
- rs.getTimestamp("hour_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:10:00.0"),
- rs.getTimestamp("min_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:12.0"),
- rs.getTimestamp("sec_from_dt"));
- assertEquals(DateUtil.parseTimestamp("2015-03-08 09:09:11.665"),
- rs.getTimestamp("mil_from_dt"));
- rs.close();
- } finally {
- conn.close();
- }
- }
-
- @Test
- public void testRoundOffFunction() throws SQLException {
- long ts = nextTimestamp();
- 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 round_test(k bigint primary key)";
- conn.createStatement().execute(ddl);
- conn.close();
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
- conn = DriverManager.getConnection(getUrl(), props);
- PreparedStatement stmt = conn.prepareStatement("upsert into round_test values(1380603308885)");
- stmt.execute();
- conn.commit();
- conn.close();
-
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
- conn = DriverManager.getConnection(getUrl(), props);
- ResultSet rs;
- stmt = conn.prepareStatement("select round(k/1000000,0) from round_test");
- rs = stmt.executeQuery();
- assertTrue(rs.next());
- assertEquals(1380603, rs.getLong(1));
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
- conn = DriverManager.getConnection(getUrl(), props);
- stmt = conn.prepareStatement("select round(k/1000000,0) x from round_test group by x");
- rs = stmt.executeQuery();
- assertTrue(rs.next());
- assertEquals(1380603, rs.getLong(1));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
index aa6fa06..e5cd578 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
@@ -41,7 +41,6 @@ public class TransactionalViewIT extends BaseOwnClusterHBaseManagedTimeIT {
public static void doSetup() throws Exception {
Map<String,String> props = Maps.newHashMapWithExpectedSize(3);
props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Integer.toString(20));
- props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024));
props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
}
@@ -107,8 +106,8 @@ public class TransactionalViewIT extends BaseOwnClusterHBaseManagedTimeIT {
}
assertEquals(4, count);
- Thread.sleep(DEFAULT_TXN_TIMEOUT_SECONDS*1000+20000);
- assertEquals("There should be one invalid transaction", 1, txManager.getInvalidSize());
+ // Thread.sleep(DEFAULT_TXN_TIMEOUT_SECONDS*1000+20000);
+ // assertEquals("There should be one invalid transaction", 1, txManager.getInvalidSize());
// verify stats can see the rows from the invalid transaction
analyzeTable(conn2, "v", true);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java
index 57ba858..c6a7bf0 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java
@@ -30,49 +30,41 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.Collections;
-import java.util.Map;
import java.util.Properties;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.QueryUtil;
-import org.apache.phoenix.util.ReadOnlyProps;
-import org.junit.BeforeClass;
import org.junit.Test;
-public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
-
- @BeforeClass
- public static void doSetup() throws Exception {
- Map<String, String> props = Collections.emptyMap();
- setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
- }
+public class UnionAllIT extends BaseHBaseManagedTimeTableReuseIT {
@Test
public void testUnionAllSelects() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar(10) not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string char(20) not null, col1 bigint" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
@@ -82,7 +74,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "select * from test_table union all select * from b_table union all select * from test_table";
+ ddl = "select * from " + tableName1 + " union all select * from " + tableName2 + " union all select * from " + tableName1;
ResultSet rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -104,17 +96,19 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testAggregate() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string char(5) not null, col1 tinyint" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
@@ -127,11 +121,11 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
@@ -141,7 +135,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String aggregate = "select count(*) from test_table union all select count(*) from b_table union all select count(*) from test_table";
+ String aggregate = "select count(*) from " + tableName1 + " union all select count(*) from " + tableName2 + " union all select count(*) from " + tableName1;
ResultSet rs = conn.createStatement().executeQuery(aggregate);
assertTrue(rs.next());
assertEquals(3,rs.getInt(1));
@@ -157,28 +151,30 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testGroupBy() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
@@ -188,7 +184,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String aggregate = "select count(*), col1 from test_table group by col1 union all select count(*), col1 from b_table group by col1";
+ String aggregate = "select count(*), col1 from " + tableName1 + " group by col1 union all select count(*), col1 from " + tableName2 + " group by col1";
ResultSet rs = conn.createStatement().executeQuery(aggregate);
assertTrue(rs.next());
assertEquals(1,rs.getInt(1));
@@ -204,17 +200,19 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testOrderByLimit() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table1 " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table1 VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
@@ -224,11 +222,11 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table1 " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table1 VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
@@ -244,7 +242,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String aggregate = "select count(*), col1 from b_table1 group by col1 union all select count(*), col1 from test_table1 group by col1 order by col1";
+ String aggregate = "select count(*), col1 from " + tableName2 + " group by col1 union all select count(*), col1 from " + tableName1 + " group by col1 order by col1";
ResultSet rs = conn.createStatement().executeQuery(aggregate);
assertTrue(rs.next());
assertEquals(2,rs.getInt(1));
@@ -254,7 +252,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals(3,rs.getInt(1));
assertFalse(rs.next());
- String limit = "select count(*), col1 x from test_table1 group by col1 union all select count(*), col1 x from b_table1 group by col1 order by x limit 2";
+ String limit = "select count(*), col1 x from " + tableName1 + " group by col1 union all select count(*), col1 x from " + tableName2 + " group by col1 order by x limit 2";
rs = conn.createStatement().executeQuery(limit);
assertTrue(rs.next());
assertEquals(2,rs.getInt(1));
@@ -262,7 +260,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals(1,rs.getInt(1));
assertFalse(rs.next());
- String limitOnly = "select * from test_table1 union all select * from b_table1 limit 2";
+ String limitOnly = "select * from " + tableName1 + " union all select * from " + tableName2 + " limit 2";
rs = conn.createStatement().executeQuery(limitOnly);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -278,22 +276,24 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testSelectDiff() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- ddl = "select a_string, col1, col1 from test_table union all select * from b_table union all select a_string, col1 from test_table";
+ ddl = "select a_string, col1, col1 from " + tableName1 + " union all select * from " + tableName2 + " union all select a_string, col1 from " + tableName1;
conn.createStatement().executeQuery(ddl);
fail();
} catch (SQLException e) {
@@ -305,38 +305,40 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testJoinInUnionAll() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 20);
stmt.execute();
conn.commit();
- ddl = "select x.a_string, y.col1 from test_table x, b_table y where x.a_string=y.a_string union all " +
- "select t.a_string, s.col1 from test_table s, b_table t where s.a_string=t.a_string";
+ ddl = "select x.a_string, y.col1 from " + tableName1 + " x, " + tableName2 + " y where x.a_string=y.a_string union all " +
+ "select t.a_string, s.col1 from " + tableName1 + " s, " + tableName2 + " t where s.a_string=t.a_string";
ResultSet rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -346,8 +348,8 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals(10,rs.getInt(2));
assertFalse(rs.next());
- ddl = "select x.a_string, y.col1 from test_table x join b_table y on x.a_string=y.a_string union all " +
- "select t.a_string, s.col1 from test_table s inner join b_table t on s.a_string=t.a_string";
+ ddl = "select x.a_string, y.col1 from " + tableName1 + " x join " + tableName2 + " y on x.a_string=y.a_string union all " +
+ "select t.a_string, s.col1 from " + tableName1 + " s inner join " + tableName2 + " t on s.a_string=t.a_string";
rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -357,9 +359,9 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals(10,rs.getInt(2));
assertFalse(rs.next());
- ddl = "select x.a_string, y.col1 from test_table x left join b_table y on x.a_string=y.a_string union all " +
- "select t.a_string, s.col1 from test_table s inner join b_table t on s.a_string=t.a_string union all " +
- "select y.a_string, x.col1 from b_table x right join test_table y on x.a_string=y.a_string";
+ ddl = "select x.a_string, y.col1 from " + tableName1 + " x left join " + tableName2 + " y on x.a_string=y.a_string union all " +
+ "select t.a_string, s.col1 from " + tableName1 + " s inner join " + tableName2 + " t on s.a_string=t.a_string union all " +
+ "select y.a_string, x.col1 from " + tableName2 + " x right join " + tableName1 + " y on x.a_string=y.a_string";
rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -378,37 +380,39 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testDerivedTable() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 20);
stmt.execute();
conn.commit();
- ddl = "select * from (select x.a_string, y.col1 from test_table x, b_table y where x.a_string=y.a_string) union all " +
- "select * from (select t.a_string, s.col1 from test_table s, b_table t where s.a_string=t.a_string)";
+ ddl = "select * from (select x.a_string, y.col1 from " + tableName1 + " x, " + tableName2 + " y where x.a_string=y.a_string) union all " +
+ "select * from (select t.a_string, s.col1 from " + tableName1 + " s, " + tableName2 + " t where s.a_string=t.a_string)";
ResultSet rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -424,17 +428,19 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testUnionAllInDerivedTable() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
@@ -444,12 +450,12 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col2 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 30);
@@ -460,7 +466,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
conn.commit();
String query = "select a_string from " +
- "(select a_string, col1 from test_table union all select a_string, col2 from b_table order by a_string)";
+ "(select a_string, col1 from " + tableName1 + " union all select a_string, col2 from " + tableName2 + " order by a_string)";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("a", rs.getString(1));
@@ -473,7 +479,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertFalse(rs.next());
query = "select c from " +
- "(select a_string, col1 c from test_table union all select a_string, col2 c from b_table order by c)";
+ "(select a_string, col1 c from " + tableName1 + " union all select a_string, col2 c from " + tableName2 + " order by c)";
rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals(10, rs.getInt(1));
@@ -491,17 +497,19 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testUnionAllInSubquery() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
@@ -511,12 +519,12 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 30);
@@ -527,10 +535,10 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
conn.commit();
String[] queries = new String[2];
- queries[0] = "select a_string, col1 from test_table where a_string in " +
- "(select a_string aa from b_table where a_string != 'a' union all select a_string bb from b_table)";
- queries[1] = "select a_string, col1 from test_table where a_string in (select a_string from " +
- "(select a_string from b_table where a_string != 'a' union all select a_string from b_table))";
+ queries[0] = "select a_string, col1 from " + tableName1 + " where a_string in " +
+ "(select a_string aa from " + tableName2 + " where a_string != 'a' union all select a_string bb from " + tableName2 + ")";
+ queries[1] = "select a_string, col1 from " + tableName1 + " where a_string in (select a_string from " +
+ "(select a_string from " + tableName2 + " where a_string != 'a' union all select a_string from " + tableName2 + "))";
for (String query : queries) {
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
@@ -545,34 +553,36 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testUnionAllWithBindParam() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
stmt.execute();
conn.commit();
- ddl = "select a_string, col1 from b_table where col1=? union all select a_string, col1 from test_table where col1=? ";
+ ddl = "select a_string, col1 from " + tableName2 + " where col1=? union all select a_string, col1 from " + tableName1 + " where col1=? ";
stmt = conn.prepareStatement(ddl);
stmt.setInt(1, 20);
stmt.setInt(2, 10);
@@ -591,43 +601,45 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testExplainUnionAll() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- ddl = "explain select a_string, col1 from test_table union all select a_string, col1 from b_table order by col1 limit 1";
+ ddl = "explain select a_string, col1 from " + tableName1 + " union all select a_string, col1 from " + tableName2 + " order by col1 limit 1";
ResultSet rs = conn.createStatement().executeQuery(ddl);
assertEquals(
"UNION ALL OVER 2 QUERIES\n" +
- " CLIENT PARALLEL 1-WAY FULL SCAN OVER TEST_TABLE\n" +
+ " CLIENT PARALLEL 1-WAY FULL SCAN OVER " + tableName1 + "\n" +
" SERVER TOP 1 ROW SORTED BY [COL1]\n" +
" CLIENT MERGE SORT\n" +
- " CLIENT PARALLEL 1-WAY FULL SCAN OVER B_TABLE\n" +
+ " CLIENT PARALLEL 1-WAY FULL SCAN OVER " + tableName2 + "\n" +
" SERVER TOP 1 ROW SORTED BY [COL1]\n" +
" CLIENT MERGE SORT\n" +
"CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
String limitPlan =
"UNION ALL OVER 2 QUERIES\n" +
- " CLIENT SERIAL 1-WAY FULL SCAN OVER TEST_TABLE\n" +
+ " CLIENT SERIAL 1-WAY FULL SCAN OVER " + tableName1 + "\n" +
" SERVER 2 ROW LIMIT\n" +
" CLIENT 2 ROW LIMIT\n" +
- " CLIENT SERIAL 1-WAY FULL SCAN OVER B_TABLE\n" +
+ " CLIENT SERIAL 1-WAY FULL SCAN OVER " + tableName2 + "\n" +
" SERVER 2 ROW LIMIT\n" +
" CLIENT 2 ROW LIMIT\n" +
"CLIENT 2 ROW LIMIT";
- ddl = "explain select a_string, col1 from test_table union all select a_string, col1 from b_table";
+ ddl = "explain select a_string, col1 from " + tableName1 + " union all select a_string, col1 from " + tableName2;
rs = conn.createStatement().executeQuery(ddl + " limit 2");
assertEquals(limitPlan, QueryUtil.getExplainPlan(rs));
Statement stmt = conn.createStatement();
@@ -635,12 +647,12 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
rs = stmt.executeQuery(ddl);
assertEquals(limitPlan, QueryUtil.getExplainPlan(rs));
- ddl = "explain select a_string, col1 from test_table union all select a_string, col1 from b_table";
+ ddl = "explain select a_string, col1 from " + tableName1 + " union all select a_string, col1 from " + tableName2;
rs = conn.createStatement().executeQuery(ddl);
assertEquals(
"UNION ALL OVER 2 QUERIES\n" +
- " CLIENT PARALLEL 1-WAY FULL SCAN OVER TEST_TABLE\n" +
- " CLIENT PARALLEL 1-WAY FULL SCAN OVER B_TABLE", QueryUtil.getExplainPlan(rs));
+ " CLIENT PARALLEL 1-WAY FULL SCAN OVER " + tableName1 + "\n" +
+ " CLIENT PARALLEL 1-WAY FULL SCAN OVER " + tableName2, QueryUtil.getExplainPlan(rs));
} finally {
conn.close();
}
@@ -648,66 +660,68 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testBug2295() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
+ String itableName1 = generateRandomString();
+ String itableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE table1(" +
+ String ddl = "CREATE TABLE " + tableName1 + "(" +
"id BIGINT, col1 VARCHAR, col2 integer, CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true";
createTestTable(getUrl(), ddl);
- ddl = "CREATE TABLE table2(" +
+ ddl = "CREATE TABLE " + tableName2 + "(" +
"id BIGINT, col1 VARCHAR, col2 integer, CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true";
createTestTable(getUrl(), ddl);
- ddl = "CREATE index idx_table1_col1 on table1(col1)";
+ ddl = "CREATE index " + itableName1 + " on " + tableName1 + "(col1)";
createTestTable(getUrl(), ddl);
- ddl = "CREATE index idx_table2_col1 on table2(col1)";
+ ddl = "CREATE index " + itableName2 + " on " + tableName2 + "(col1)";
createTestTable(getUrl(), ddl);
- ddl = "Explain SELECT /*+ INDEX(table1 idx_table1_col1) */ col1, col2 from table1 where col1='123' " +
- "union all SELECT /*+ INDEX(table2 idx_table2_col1) */ col1, col2 from table2 where col1='123'";
+ ddl = "Explain SELECT /*+ INDEX(" + tableName1 + " " + itableName1 + ") */ col1, col2 from " + tableName1 + " where col1='123' " +
+ "union all SELECT /*+ INDEX(" + tableName2 + " " + itableName2 + ") */ col1, col2 from " + tableName2 + " where col1='123'";
ResultSet rs = conn.createStatement().executeQuery(ddl);
assertTrue(rs.next());
} finally {
- String ddl = "drop table table1";
- conn.createStatement().execute(ddl);
- ddl = "drop table table2";
- conn.createStatement().execute(ddl);
conn.close();
}
}
@Test
public void testParameterMetaDataNotNull() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "CREATE TABLE test_table " +
+ String ddl = "CREATE TABLE " + tableName1 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO test_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 10);
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE b_table " +
+ ddl = "CREATE TABLE " + tableName2 + " " +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO b_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "b");
stmt.setInt(2, 20);
stmt.execute();
conn.commit();
- String query = "select * from test_table union all select * from b_table";
+ String query = "select * from " + tableName1 + " union all select * from " + tableName2;
try{
PreparedStatement pstmt = conn.prepareStatement(query);
@@ -727,13 +741,17 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testDiffDataTypes() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
+ String tableName3 = generateRandomString();
+ String tableName4 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "create table person ( id bigint not null primary key, " +
+ String ddl = "create table " + tableName1 + " ( id bigint not null primary key, " +
"firstname varchar(10), lastname varchar(10) )";
createTestTable(getUrl(), ddl);
- String dml = "upsert into person values (?, ?, ?)";
+ String dml = "upsert into " + tableName1 + " values (?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "john");
@@ -745,10 +763,10 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table user ( id integer not null primary key, firstname char(12)," +
+ ddl = "create table " + tableName2 + " ( id integer not null primary key, firstname char(12)," +
" lastname varchar(12) )";
createTestTable(getUrl(), ddl);
- dml = "upsert into user values (?, ?, ?)";
+ dml = "upsert into " + tableName2 + " values (?, ?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "sam");
@@ -760,20 +778,20 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table t1 ( id varchar(20) not null primary key)";
+ ddl = "create table " + tableName3 + " ( id varchar(20) not null primary key)";
createTestTable(getUrl(), ddl);
- dml = "upsert into t1 values ('abcd')";
+ dml = "upsert into " + tableName3 + " values ('abcd')";
stmt = conn.prepareStatement(dml);
stmt.execute();
conn.commit();
- ddl = "create table t2 ( id char(50) not null primary key)";
+ ddl = "create table " + tableName4 + " ( id char(50) not null primary key)";
createTestTable(getUrl(), ddl);
- dml = "upsert into t2 values ('xyz')";
+ dml = "upsert into " + tableName4 + " values ('xyz')";
stmt = conn.prepareStatement(dml);
stmt.execute();
conn.commit();
- String query = "select id, 'foo' firstname, lastname from person union all" +
- " select * from user";
+ String query = "select id, 'foo' firstname, lastname from " + tableName1 + " union all" +
+ " select * from " + tableName2;
try {
PreparedStatement pstmt = conn.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
@@ -795,7 +813,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals("wiely", rs.getString(3));
assertFalse(rs.next());
- pstmt = conn.prepareStatement("select * from t1 union all select * from t2");
+ pstmt = conn.prepareStatement("select * from " + tableName3 + " union all select * from " + tableName4);
rs = pstmt.executeQuery();
assertTrue(rs.next());
assertEquals("abcd", rs.getString(1));
@@ -809,13 +827,17 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testDiffScaleSortOrder() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
+ String tableName3 = generateRandomString();
+ String tableName4 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "create table person ( id bigint not null primary key desc, " +
+ String ddl = "create table " + tableName1 + " ( id bigint not null primary key desc, " +
"firstname char(10), lastname varchar(10) )";
createTestTable(getUrl(), ddl);
- String dml = "upsert into person values (?, ?, ?)";
+ String dml = "upsert into " + tableName1 + " values (?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "john");
@@ -827,10 +849,10 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table user ( id integer not null primary key asc, " +
+ ddl = "create table " + tableName2 + " ( id integer not null primary key asc, " +
"firstname varchar(12), lastname varchar(10) )";
createTestTable(getUrl(), ddl);
- dml = "upsert into user values (?, ?, ?)";
+ dml = "upsert into " + tableName2 + " values (?, ?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "sam");
@@ -842,20 +864,20 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table t1 ( id varchar(20) not null primary key, col1 decimal)";
+ ddl = "create table " + tableName3 + " ( id varchar(20) not null primary key, col1 decimal)";
createTestTable(getUrl(), ddl);
- dml = "upsert into t1 values ('abcd', 234.23)";
+ dml = "upsert into " + tableName3 + " values ('abcd', 234.23)";
stmt = conn.prepareStatement(dml);
stmt.execute();
conn.commit();
- ddl = "create table t2 ( id char(50) not null primary key, col1 decimal(12,4))";
+ ddl = "create table " + tableName4 + " ( id char(50) not null primary key, col1 decimal(12,4))";
createTestTable(getUrl(), ddl);
- dml = "upsert into t2 values ('xyz', 1342.1234)";
+ dml = "upsert into " + tableName4 + " values ('xyz', 1342.1234)";
stmt = conn.prepareStatement(dml);
stmt.execute();
conn.commit();
- String query = "select * from user union all select * from person";
+ String query = "select * from " + tableName2 + " union all select * from " + tableName1;
try {
PreparedStatement pstmt = conn.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
@@ -877,7 +899,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals("doe", rs.getString(3));
assertFalse(rs.next());
- pstmt = conn.prepareStatement("select * from t1 union all select * from t2");
+ pstmt = conn.prepareStatement("select * from " + tableName3 + " union all select * from " + tableName4);
rs = pstmt.executeQuery();
assertTrue(rs.next());
assertEquals("abcd", rs.getString(1));
@@ -893,13 +915,15 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testVarcharChar() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "create table user ( id integer not null primary key asc, " +
+ String ddl = "create table " + tableName2 + " ( id integer not null primary key asc, " +
"firstname char(8), lastname varchar )";
createTestTable(getUrl(), ddl);
- String dml = "upsert into user values (?, ?, ?)";
+ String dml = "upsert into " + tableName2 + " values (?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "sam");
@@ -911,10 +935,10 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table person ( id bigint not null primary key desc, " +
+ ddl = "create table " + tableName1 + " ( id bigint not null primary key desc, " +
"firstname varchar(10), lastname char(10) )";
createTestTable(getUrl(), ddl);
- dml = "upsert into person values (?, ?, ?)";
+ dml = "upsert into " + tableName1 + " values (?, ?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "john");
@@ -926,8 +950,8 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "select id, 'baa' firstname, lastname from user " +
- "union all select * from person";
+ String query = "select id, 'baa' firstname, lastname from " + tableName2 + " " +
+ "union all select * from " + tableName1;
try {
PreparedStatement pstmt = conn.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
@@ -955,13 +979,15 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
@Test
public void testCoerceExpr() throws Exception {
+ String tableName1 = generateRandomString();
+ String tableName2 = generateRandomString();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "create table user ( id integer not null primary key desc, " +
+ String ddl = "create table " + tableName2 + " ( id integer not null primary key desc, " +
"firstname char(8), lastname varchar, sales double)";
createTestTable(getUrl(), ddl);
- String dml = "upsert into user values (?, ?, ?, ?)";
+ String dml = "upsert into " + tableName2 + " values (?, ?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "sam");
@@ -975,10 +1001,10 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "create table person (id bigint not null primary key, " +
+ ddl = "create table " + tableName1 + " (id bigint not null primary key, " +
"firstname char(10), lastname varchar(10), sales decimal)";
createTestTable(getUrl(), ddl);
- dml = "upsert into person values (?, ?, ?, ?)";
+ dml = "upsert into " + tableName1 + " values (?, ?, ?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setInt(1, 1);
stmt.setString(2, "john");
@@ -993,7 +1019,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
conn.commit();
String query = "select id, cast('foo' as char(10)) firstname, lastname, sales " +
- "from person union all select * from user";
+ "from " + tableName1 + " union all select * from " + tableName2;
try {
PreparedStatement pstmt = conn.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
@@ -1019,7 +1045,7 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
assertEquals(BigDecimal.valueOf(100.6798), rs.getBigDecimal(4));
assertFalse(rs.next());
- query = "select id, cast('foo' as char(10)) firstname, lastname, sales from person";
+ query = "select id, cast('foo' as char(10)) firstname, lastname, sales from " + tableName1;
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
assertTrue(rs.next());
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java
index 867c0f7..32f272d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java
@@ -46,9 +46,6 @@ public class ImmutableIndexWithStatsIT extends BaseOwnClusterHBaseManagedTimeIT
public static void doSetup() throws Exception {
Map<String,String> props = Maps.newHashMapWithExpectedSize(5);
props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(1));
- props.put(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, Boolean.TRUE.toString());
- props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(4));
- props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(500));
setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
}
@@ -77,7 +74,7 @@ public class ImmutableIndexWithStatsIT extends BaseOwnClusterHBaseManagedTimeIT
conn.createStatement().execute("UPDATE STATISTICS " + tableName);
query = "SELECT COUNT(*) FROM " + tableName;
rs = conn.createStatement().executeQuery("EXPLAIN " + query);
- assertTrue(QueryUtil.getExplainPlan(rs).startsWith("CLIENT 7-CHUNK PARALLEL 1-WAY FULL SCAN"));
+ assertTrue(QueryUtil.getExplainPlan(rs).startsWith("CLIENT PARALLEL 1-WAY FULL SCAN"));
String indexName = TestUtil.DEFAULT_INDEX_TABLE_NAME;
conn.createStatement().execute("CREATE INDEX " + indexName + " ON " + tableName + " (v)");