phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject [50/50] [abbrv] phoenix git commit: Fix compilation errors from merge
Date Wed, 14 Sep 2016 21:43:48 GMT
Fix compilation errors from merge


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/faff90af
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/faff90af
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/faff90af

Branch: refs/heads/calcite
Commit: faff90afdebfa007f7f82e65678cdb90a36b6a43
Parents: a9526a9 6861a5e
Author: maryannxue <maryann.xue@gmail.com>
Authored: Wed Sep 14 14:42:36 2016 -0700
Committer: maryannxue <maryann.xue@gmail.com>
Committed: Wed Sep 14 14:42:36 2016 -0700

----------------------------------------------------------------------
 .../apache/phoenix/calcite/BaseCalciteIT.java   |  51 +++---
 .../phoenix/calcite/BaseCalciteIndexIT.java     |   9 +-
 .../apache/phoenix/calcite/CalciteDMLIT.java    |   2 +-
 .../org/apache/phoenix/calcite/CalciteIT.java   |  11 +-
 .../end2end/BaseClientManagedTimeIT.java        |   2 +-
 .../phoenix/end2end/BaseHBaseManagedTimeIT.java |   2 +-
 .../BaseOwnClusterClientManagedTimeIT.java      |   2 +-
 .../BaseOwnClusterHBaseManagedTimeIT.java       |   2 +-
 .../org/apache/phoenix/end2end/HashJoinIT.java  |  36 ++--
 .../calcite/jdbc/PhoenixCalciteFactory.java     |  94 +++++++++++
 .../calcite/jdbc/PhoenixCalciteDriver.java      | 101 +++---------
 .../jdbc/PhoenixCalciteEmbeddedDriver.java      | 116 +++++++++++++
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |   2 +-
 .../phoenix/jdbc/PhoenixEmbeddedDriver.java     |  10 +-
 .../org/apache/phoenix/util/PhoenixRuntime.java |   4 +
 .../java/org/apache/phoenix/util/QueryUtil.java |  30 ++--
 .../phoenix/jdbc/PhoenixCalciteTestDriver.java  |  43 +++++
 .../apache/phoenix/jdbc/PhoenixTestDriver.java  |   3 -
 .../query/BaseConnectionlessQueryTest.java      |  36 ++--
 .../java/org/apache/phoenix/query/BaseTest.java | 164 +++++++++++++++----
 .../java/org/apache/phoenix/util/TestUtil.java  |   2 +
 21 files changed, 524 insertions(+), 198 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
index 7a16ed1,3ea8db7..5f98f8d
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
@@@ -43,7 -43,7 +43,7 @@@ import java.util.Properties
  import org.apache.calcite.avatica.util.ArrayImpl;
  import org.apache.calcite.config.CalciteConnectionProperty;
  import org.apache.phoenix.calcite.rel.PhoenixRel;
--import org.apache.phoenix.end2end.BaseClientManagedTimeIT;
++import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
  import org.apache.phoenix.query.QueryServices;
  import org.apache.phoenix.schema.TableAlreadyExistsException;
  import org.apache.phoenix.util.PhoenixRuntime;
@@@ -53,12 -54,12 +54,14 @@@ import org.junit.Assert
  import org.junit.BeforeClass;
  
  import com.google.common.collect.Lists;
++import com.google.common.collect.Maps;
  
--public class BaseCalciteIT extends BaseClientManagedTimeIT {
++public class BaseCalciteIT extends BaseHBaseManagedTimeIT {
      
      @BeforeClass
      public static void doSetup() throws Exception {
--        Map<String,String> props = getDefaultProps();
++        Map<String,String> props = Maps.newHashMapWithExpectedSize(5);
++        props.put(QueryServices.STATS_USE_CURRENT_TIME_ATTRIB, Boolean.FALSE.toString());
          props.put(QueryServices.RUN_UPDATE_STATS_ASYNC, Boolean.FALSE.toString());
          props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(1000));
          props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(200));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIndexIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIndexIT.java
index 62943aa,1f32591..b7e5955
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIndexIT.java
@@@ -21,6 -21,6 +21,7 @@@ import java.sql.Connection
  import java.sql.DriverManager;
  import java.util.Properties;
  
++import org.apache.phoenix.util.TestUtil;
  import org.junit.Before;
  
  public class BaseCalciteIndexIT extends BaseCalciteIT {
@@@ -33,11 -33,11 +34,11 @@@
      
      @Before
      public void initTable() throws Exception {
-         final String url = getUrl();
+         final String url = getOldUrl();
          final String index = localIndex ? "LOCAL INDEX" : "INDEX";
--        initATableValues(getOrganizationId(), null, url);
-         initSaltedTables(index);
-         initMultiTenantTables(index);
++        initATableValues(TestUtil.ATABLE_NAME, getOrganizationId(), null, null, null, url);
+         initSaltedTables(url, index);
+         initMultiTenantTables(url, index);
          Connection connection = DriverManager.getConnection(url);
          connection.createStatement().execute("CREATE " + index + " IF NOT EXISTS IDX1 ON
aTable (a_string) INCLUDE (b_string, x_integer)");
          connection.createStatement().execute("CREATE " + index + " IF NOT EXISTS IDX2 ON
aTable (b_string) INCLUDE (a_string, y_integer)");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
index da60b15,da60b15..6705042
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
@@@ -21,7 -21,7 +21,7 @@@ public class CalciteDMLIT extends BaseC
      
      @Before
      public void initTable() throws Exception {
--        final String url = getUrl();
++        final String url = getOldUrl();
          ensureTableCreated(url, ATABLE_NAME);
      }
  

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
index e65d386,0ecf330..da6303b
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
@@@ -30,6 -30,6 +30,7 @@@ import java.sql.Timestamp
  import java.text.SimpleDateFormat;
  import java.util.Properties;
  
++import org.apache.phoenix.util.TestUtil;
  import org.junit.Before;
  import org.junit.Ignore;
  import org.junit.Test;
@@@ -41,12 -41,12 +42,12 @@@ public class CalciteIT extends BaseCalc
      
      @Before
      public void initTable() throws Exception {
-         final String url = getUrl();
-         initATableValues(getOrganizationId(), null, url);
+         final String url = getOldUrl();
 -        initATableValues(getOrganizationId(), null, url);
++        initATableValues(TestUtil.ATABLE_NAME, getOrganizationId(), null, null, null, url);
          initJoinTableValues(url, null, null);
-         initArrayTable();
-         initSaltedTables(null);
-         initKeyOrderingTable();
+         initArrayTable(url);
+         initSaltedTables(url, null);
+         initKeyOrderingTable(url);
          final Connection connection = DriverManager.getConnection(url);
          connection.createStatement().execute("CREATE VIEW IF NOT EXISTS v AS SELECT * from
aTable where a_string = 'a'");
          connection.createStatement().execute("CREATE SEQUENCE IF NOT EXISTS seq0 START WITH
1 INCREMENT BY 1");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java
index dee7200,0dada7a..879d9fd
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseClientManagedTimeIT.java
@@@ -56,7 -56,7 +56,7 @@@ public abstract class BaseClientManaged
      @After
      public void cleanUpAfterTest() throws Exception {
          long ts = nextTimestamp();
-         deletePriorMetaData(ts - 1, getUrl());
 -        deletePriorTables(ts - 1, getOldUrl());    
++        deletePriorMetaData(ts - 1, getOldUrl());
      }
      
      public static Map<String,String> getDefaultProps() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java
index 7439b1d,6aeafbf..8da0998
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeIT.java
@@@ -64,6 -61,6 +64,6 @@@ public abstract class BaseHBaseManagedT
      
      @After
      public void cleanUpAfterTest() throws Exception {
-         deletePriorMetaData(HConstants.LATEST_TIMESTAMP, getUrl());
 -        deletePriorTables(HConstants.LATEST_TIMESTAMP, getOldUrl());    
++        deletePriorMetaData(HConstants.LATEST_TIMESTAMP, getOldUrl());
      }
  }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java
index 6ece674,25b3128..5631e19
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterClientManagedTimeIT.java
@@@ -24,6 -26,6 +24,6 @@@ public class BaseOwnClusterClientManage
      @After
      public void cleanUpAfterTest() throws Exception {
          long ts = nextTimestamp();
-         deletePriorMetaData(ts - 1, getUrl());
 -        deletePriorTables(ts - 1, getOldUrl());    
++        deletePriorMetaData(ts - 1, getOldUrl());
      }    
  }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java
index 63a4300,a7458f2..3569a6e
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOwnClusterHBaseManagedTimeIT.java
@@@ -24,6 -26,6 +24,6 @@@ import org.junit.After
  public class BaseOwnClusterHBaseManagedTimeIT extends BaseOwnClusterIT {
      @After
      public void cleanUpAfterTest() throws Exception {
-         deletePriorMetaData(HConstants.LATEST_TIMESTAMP, getUrl());
 -        deletePriorTables(HConstants.LATEST_TIMESTAMP, getOldUrl());    
++        deletePriorMetaData(HConstants.LATEST_TIMESTAMP, getOldUrl());
      }
  }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
index 272fb22,566d8d8..047cc24
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriver.java
@@@ -416,23 -329,20 +416,29 @@@ public abstract class PhoenixEmbeddedDr
          private final boolean isConnectionless;
          private final String principal;
          private final String keytab;
 +        private final User user;
+         private final boolean isCalciteEnabled;
          
          public ConnectionInfo(String zookeeperQuorum, Integer port, String rootNode, String
principal, String keytab) {
+          this(zookeeperQuorum, port, rootNode, principal, keytab, false);
+         }
+         
+         public ConnectionInfo(String zookeeperQuorum, Integer port, String rootNode, String
principal, String keytab, boolean isCalciteEnabled) {
              this.zookeeperQuorum = zookeeperQuorum;
              this.port = port;
              this.rootNode = rootNode;
              this.isConnectionless = PhoenixRuntime.CONNECTIONLESS.equals(zookeeperQuorum);
              this.principal = principal;
              this.keytab = keytab;
 +            try {
 +                this.user = User.getCurrent();
 +            } catch (IOException e) {
 +                throw new RuntimeException("Couldn't get the current user!!");
 +            }
 +            if (null == this.user) {
 +                throw new RuntimeException("Acquired null user which should never happen");
 +            }
+             this.isCalciteEnabled = isCalciteEnabled;
          }
          
          public ConnectionInfo(String zookeeperQuorum, Integer port, String rootNode) {
@@@ -544,26 -437,9 +550,26 @@@
  		}
  
          public String toUrl() {
-             return PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR
-                     + toString();
+             return (isCalciteEnabled? PhoenixRuntime.JDBC_PROTOCOL_CALCITE : PhoenixRuntime.JDBC_PROTOCOL)
+                     + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + toString();
          }
 +
 +        private static ConnectionInfo defaultConnectionInfo(String url) throws SQLException
{
 +            Configuration config =
 +                    HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
 +            String quorum = config.get(HConstants.ZOOKEEPER_QUORUM);
 +            if (quorum == null || quorum.isEmpty()) {
 +                throw getMalFormedUrlException(url);
 +            }
 +            String clientPort = config.get(HConstants.ZOOKEEPER_CLIENT_PORT);
 +            Integer port = clientPort==null ? null : Integer.parseInt(clientPort);
 +            if (port == null || port < 0) {
 +                throw getMalFormedUrlException(url);
 +            }
 +            String znodeParent = config.get(HConstants.ZOOKEEPER_ZNODE_PARENT);
 +            LOG.debug("Getting default jdbc connection url " + quorum + ":" + port + ":"
+ znodeParent);
 +            return new ConnectionInfo(quorum, port, znodeParent);
 +        }
      }
  
      public static boolean isTestUrl(String url) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
index 6d8e00d,ba6227a..69690a6
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
@@@ -233,53 -229,46 +233,53 @@@ public final class QueryUtil 
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
      public static String getUrl(String zkQuorum) {
-         return getUrlInternal(zkQuorum, null, null, null);
 -        return getUrlInternal(zkQuorum, null, null, false);
++        return getUrlInternal(zkQuorum, null, null, null, false);
      }
  
      /**
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
      public static String getUrl(String zkQuorum, int clientPort) {
-         return getUrlInternal(zkQuorum, clientPort, null, null);
 -        return getUrlInternal(zkQuorum, clientPort, null, false);
++        return getUrlInternal(zkQuorum, clientPort, null, null, false);
      }
  
      /**
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
      public static String getUrl(String zkQuorum, String znodeParent) {
-         return getUrlInternal(zkQuorum, null, znodeParent, null);
 -        return getUrlInternal(zkQuorum, null, znodeParent, false);
++        return getUrlInternal(zkQuorum, null, znodeParent, null, false);
 +    }
 +
 +    /**
 +     * Create the Phoenix JDBC connection URL from the provided cluster connection details.
 +     */
 +    public static String getUrl(String zkQuorum, int port, String znodeParent, String principal)
{
-         return getUrlInternal(zkQuorum, port, znodeParent, principal);
++        return getUrlInternal(zkQuorum, port, znodeParent, principal, false);
      }
  
      /**
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
      public static String getUrl(String zkQuorum, int port, String znodeParent) {
-         return getUrlInternal(zkQuorum, port, znodeParent, null);
 -        return getUrlInternal(zkQuorum, port, znodeParent, false);
++        return getUrlInternal(zkQuorum, port, znodeParent, null, false);
      }
  
      /**
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
      public static String getUrl(String zkQuorum, Integer port, String znodeParent) {
-         return getUrlInternal(zkQuorum, port, znodeParent, null);
 -        return getUrlInternal(zkQuorum, port, znodeParent, false);
++        return getUrlInternal(zkQuorum, port, znodeParent, null, false);
      }
  
      /**
       * Create the Phoenix JDBC connection URL from the provided cluster connection details.
       */
-     public static String getUrl(String zkQuorum, Integer port, String znodeParent, String
principal) {
-         return getUrlInternal(zkQuorum, port, znodeParent, principal);
 -    public static String getUrl(String zkQuorum, Integer port, String znodeParent, boolean
isCalciteEnabled) {
 -        return getUrlInternal(zkQuorum, port, znodeParent, isCalciteEnabled);
++    public static String getUrl(String zkQuorum, Integer port, String znodeParent, String
principal, boolean isCalciteEnabled) {
++        return getUrlInternal(zkQuorum, port, znodeParent, principal, isCalciteEnabled);
      }
  
-     private static String getUrlInternal(String zkQuorum, Integer port, String znodeParent,
String principal) {
-         return new PhoenixEmbeddedDriver.ConnectionInfo(zkQuorum, port, znodeParent, principal,
null).toUrl()
 -    private static String getUrlInternal(String zkQuorum, Integer port, String znodeParent,
boolean isCalciteEnabled) {
 -        return new PhoenixEmbeddedDriver.ConnectionInfo(zkQuorum, port, znodeParent, null,
null, isCalciteEnabled).toUrl()
++    private static String getUrlInternal(String zkQuorum, Integer port, String znodeParent,
String principal, boolean isCalciteEnabled) {
++        return new PhoenixEmbeddedDriver.ConnectionInfo(zkQuorum, port, znodeParent, principal,
null, isCalciteEnabled).toUrl()
                  + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
      }
  
@@@ -342,10 -314,12 +342,16 @@@
  
      public static String getConnectionUrl(Properties props, Configuration conf)
              throws ClassNotFoundException, SQLException {
-         return getConnectionUrl(props, conf, null);
 -        return getConnectionUrl(props, conf, false);
++        return getConnectionUrl(props, conf, null, false);
      }
 -    
 -    public static String getConnectionUrl(Properties props, Configuration conf,
 -            boolean isCalciteEnabled)
++
 +    public static String getConnectionUrl(Properties props, Configuration conf, String principal)
 +            throws ClassNotFoundException, SQLException {
++        return getConnectionUrl(props, conf, principal, false);
++    }
++
++    public static String getConnectionUrl(Properties props, Configuration conf, String principal,
boolean isCalciteEnabled)
+             throws ClassNotFoundException, SQLException {
          // TODO: props is ignored!
          // read the hbase properties from the configuration
          String server = ZKConfig.getZKQuorumServersString(conf);
@@@ -380,7 -354,7 +386,7 @@@
          server = Joiner.on(',').join(servers);
          String znodeParent = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
                  HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-         String url = getUrl(server, port, znodeParent, principal);
 -        String url = getUrl(server, port, znodeParent, isCalciteEnabled);
++        String url = getUrl(server, port, znodeParent, principal, isCalciteEnabled);
          // Mainly for testing to tack on the test=true part to ensure driver is found on
server
          String extraArgs = conf.get(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
          if (extraArgs.length() > 0) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index cb0bceb,d511b36..e064dc9
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@@ -134,13 -133,17 +135,13 @@@ import org.apache.hadoop.hbase.io.encod
  import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory;
  import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
  import org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory;
 -import org.apache.hadoop.hbase.master.LoadBalancer;
 -import org.apache.hadoop.hbase.regionserver.LocalIndexMerger;
  import org.apache.hadoop.hbase.regionserver.RSRpcServices;
--import org.apache.hadoop.hbase.util.Bytes;
  import org.apache.phoenix.end2end.BaseClientManagedTimeIT;
  import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
  import org.apache.phoenix.exception.SQLExceptionCode;
  import org.apache.phoenix.exception.SQLExceptionInfo;
 -import org.apache.phoenix.hbase.index.balancer.IndexLoadBalancer;
 -import org.apache.phoenix.hbase.index.master.IndexMasterObserver;
 +import org.apache.phoenix.jdbc.PhoenixConnection;
+ import org.apache.phoenix.jdbc.PhoenixCalciteTestDriver;
  import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
  import org.apache.phoenix.jdbc.PhoenixDriver;
  import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver;
@@@ -645,7 -656,8 +655,8 @@@ public abstract class BaseTest 
              try {
                  utility.startMiniCluster(NUM_SLAVES_BASE);
                  utility.startMiniMapReduceCluster();
 -                url = QueryUtil.getConnectionUrl(new Properties(), utility.getConfiguration(),
false);
 +                url = QueryUtil.getConnectionUrl(new Properties(), utility.getConfiguration());
+                 calciteUrl = url.replaceFirst(PhoenixRuntime.JDBC_PROTOCOL, PhoenixRuntime.JDBC_PROTOCOL_CALCITE);
              } catch (Throwable t) {
                  throw new RuntimeException(t);
              }
@@@ -893,61 -884,16 +906,63 @@@
      }
      
      protected static byte[][] getDefaultSplits(String tenantId) {
-         return new byte[][] { 
-             Bytes.toBytes(tenantId + "00A"),
-             Bytes.toBytes(tenantId + "00B"),
-             Bytes.toBytes(tenantId + "00C"),
-             };
+     	return null;
+     	// TODO CALCITE-1319
+ //        return new byte[][] { 
+ //            Bytes.toBytes(tenantId + "00A"),
+ //            Bytes.toBytes(tenantId + "00B"),
+ //            Bytes.toBytes(tenantId + "00C"),
+ //            };
      }
 -    
 -    protected static void deletePriorTables(long ts, String url) throws Exception {
 +
 +    private static void deletePriorSchemas(long ts, String url) throws Exception {
 +        Properties props = new Properties();
 +        props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024));
 +        if (ts != HConstants.LATEST_TIMESTAMP) {
 +            props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts));
 +        }
 +        try (Connection conn = DriverManager.getConnection(url, props)) {
 +            DatabaseMetaData dbmd = conn.getMetaData();
 +            ResultSet rs = dbmd.getSchemas();
 +            while (rs.next()) {
 +                String schemaName = rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM);
 +                if (schemaName.equals(PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME)) {
 +                    continue;
 +                }
 +                schemaName = SchemaUtil.getEscapedArgument(schemaName);
 +
 +                String ddl = "DROP SCHEMA " + schemaName;
 +                conn.createStatement().executeUpdate(ddl);
 +            }
 +            rs.close();
 +        }
 +        // Make sure all schemas have been dropped
 +        props.remove(CURRENT_SCN_ATTRIB);
 +        try (Connection seeLatestConn = DriverManager.getConnection(url, props)) {
 +            DatabaseMetaData dbmd = seeLatestConn.getMetaData();
 +            ResultSet rs = dbmd.getSchemas();
 +            boolean hasSchemas = rs.next();
 +            if (hasSchemas) {
 +                String schemaName = rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM);
 +                if (schemaName.equals(PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME)) {
 +                    hasSchemas = rs.next();
 +                }
 +            }
 +            if (hasSchemas) {
 +                fail("The following schemas are not dropped that should be:" + getSchemaNames(rs));
 +            }
 +        }
 +    }
 +
 +    protected static void deletePriorMetaData(long ts, String url) throws Exception {
 +        deletePriorTables(ts, url);
 +        if (ts != HConstants.LATEST_TIMESTAMP) {
 +            ts = nextTimestamp() - 1;
 +        }
 +        deletePriorSchemas(ts, url);
 +    }
 +
 +    private static void deletePriorTables(long ts, String url) throws Exception {
          deletePriorTables(ts, (String)null, url);
      }
      
@@@ -1345,15 -1248,17 +1360,14 @@@
              stmt.execute();
                  
              conn.commit();
++            return tableName;
          } finally {
              conn.close();
-             return tableName;
          }
      }
- 
      
 -    protected static void initATableValues(String tenantId, byte[][] splits, Date date,
Long ts) throws Exception {
 -        initATableValues(tenantId, splits, date, ts, getOldUrl());
 -    }
 -    
      protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits,
Date date, Long ts) throws Exception {
-         initEntityHistoryTableValues(tenantId, splits, date, ts, getUrl());
+         initEntityHistoryTableValues(tenantId, splits, date, ts, getOldUrl());
      }
      
      protected static void initSaltedEntityHistoryTableValues(String tenantId, byte[][] splits,
Date date, Long ts) throws Exception {
@@@ -1594,9 -1499,9 +1608,9 @@@
          if (ts != null) {
              props.setProperty(CURRENT_SCN_ATTRIB, ts.toString());
          }
 -        Connection conn = DriverManager.getConnection(getOldUrl(), props);
 +        Connection conn = DriverManager.getConnection(url, props);
          try {
-             conn.createStatement().execute("CREATE SEQUENCE IF NOT EXISTS my.seq");
+             //conn.createStatement().execute("CREATE SEQUENCE IF NOT EXISTS my.seq");
              // Insert into customer table
              PreparedStatement stmt = conn.prepareStatement(
                      "upsert into " + JOIN_CUSTOMER_TABLE_FULL_NAME +
@@@ -2092,29 -1997,90 +2106,113 @@@
          } finally {
              conn.close();
          }
 -    }  
 -    
 -    
 -    
 +    }
 +
 +    protected static void verifySequence(String tenantID, String sequenceName, String sequenceSchemaName,
boolean exists) throws SQLException {
 +
 +        PhoenixConnection phxConn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class);
 +        String ddl = "SELECT "
 +                + PhoenixDatabaseMetaData.TENANT_ID + ","
 +                + PhoenixDatabaseMetaData.SEQUENCE_SCHEMA + ","
 +                + PhoenixDatabaseMetaData.SEQUENCE_NAME
 +                + " FROM " + PhoenixDatabaseMetaData.SYSTEM_SEQUENCE
 +                + " WHERE ";
 +
 +        ddl += " TENANT_ID  " + ((tenantID == null ) ? "IS NULL " : " = '" + tenantID +
"'");
 +        ddl += " AND SEQUENCE_NAME " + ((sequenceName == null) ? "IS NULL " : " = '" + 
sequenceName + "'");
 +        ddl += " AND SEQUENCE_SCHEMA " + ((sequenceSchemaName == null) ? "IS NULL " : "
= '" + sequenceSchemaName + "'" );
 +
 +        ResultSet rs = phxConn.createStatement().executeQuery(ddl);
 +
 +        if(exists) {
 +            assertTrue(rs.next());
 +        } else {
 +            assertFalse(rs.next());
 +        }
 +        phxConn.close();
++    }        
++
++
+     //=============================================================================================
+     // Overriden assertEquals to mask EXPLAIN PLAN check.
+     // TODO to be removed later.
+     // ============================================================================================
+     
+     protected static void assertEquals(String message, String expected, String actual) {
+         if ((expected != null && expected.contains("PhoenixToEnumerableConverter"))
+                 || (actual != null && actual.contains("PhoenixToEnumerableConverter")))
{
+             return;
+         }
+         org.junit.Assert.assertEquals(message, expected, actual);
+     }
+ 
+     protected static void assertEquals(String expected, String actual) {
+         if ((expected != null && expected.contains("PhoenixToEnumerableConverter"))
+                 || (actual != null && actual.contains("PhoenixToEnumerableConverter")))
{
+             return;
+         }
+         org.junit.Assert.assertEquals(expected, actual);        
+     }
+     
+     protected static void assertEquals(String message, float expected, float actual, float
delta) {
+         org.junit.Assert.assertEquals(message, expected, actual, delta);
+     }
+     
+     protected static void assertEquals(float expected, float actual, float delta) {
+         org.junit.Assert.assertEquals(expected, actual, delta);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(String message, float expected, float actual) {
+         org.junit.Assert.assertEquals(message, expected, actual);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(float expected, float actual) {
+         org.junit.Assert.assertEquals(expected, actual);
+     }
+     
+     protected static void assertEquals(String message, double expected, double actual, double
delta) {
+         org.junit.Assert.assertEquals(message, expected, actual, delta);        
+     }
+     
+     protected static void assertEquals(double expected, double actual, double delta) {
+         org.junit.Assert.assertEquals(expected, actual, delta);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(String message, double expected, double actual) {
+         org.junit.Assert.assertEquals(message, expected, actual);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(double expected, double actual) {
+         org.junit.Assert.assertEquals(expected, actual);
+     }
+     
+     protected static void assertEquals(String message, long expected, long actual) {
+         org.junit.Assert.assertEquals(message, expected, actual);
+     }
+     
+     protected static void assertEquals(long expected, long actual) {
+         org.junit.Assert.assertEquals(expected, actual);
+     }
+     
+     protected static void assertEquals(String message, Object expected, Object actual) {
+         org.junit.Assert.assertEquals(message, expected, actual);
+     }
+     
+     protected static void assertEquals(Object expected, Object actual) {
+         org.junit.Assert.assertEquals(expected, actual);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(String message, Object[] expecteds, Object[] actuals)
{
+         org.junit.Assert.assertEquals(message, expecteds, actuals);
+     }
+     
+     @SuppressWarnings("deprecation")
+     protected static void assertEquals(Object[] expecteds, Object[] actuals) {
+         org.junit.Assert.assertEquals(expecteds, actuals);
      }
 -}
 +}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/faff90af/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
----------------------------------------------------------------------
diff --cc phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index 68e7b9b,212a7cc..8629535
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@@ -17,12 -17,10 +17,13 @@@
   */
  package org.apache.phoenix.util;
  
 +import static org.apache.phoenix.query.BaseTest.generateRandomString;
  import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY;
 +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY_NAME;
 +import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_NAME;
  import static org.apache.phoenix.util.PhoenixRuntime.CONNECTIONLESS;
  import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+ import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_CALCITE;
  import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
  import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
  import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;


Mime
View raw message