예제 #1
0
 @Test
 public void testScanUri() throws Exception {
   GroupByCaseTest gbt = new GroupByCaseTest();
   long ts = gbt.createTable();
   gbt.loadData(ts);
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   Statement stmt = conn.createStatement();
   ResultSet rs = stmt.executeQuery("select uri from " + GROUPBYTEST_NAME);
   assertTrue(rs.next());
   assertEquals("Report1", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report2", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report3", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("Report4", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL1", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL2", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL3", rs.getString(1));
   assertTrue(rs.next());
   assertEquals("SOQL4", rs.getString(1));
   assertFalse(rs.next());
   conn.close();
 }
예제 #2
0
 private void loadData(long ts) throws SQLException {
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   insertRow(conn, "Report1", 10);
   insertRow(conn, "Report2", 10);
   insertRow(conn, "Report3", 30);
   insertRow(conn, "Report4", 30);
   insertRow(conn, "SOQL1", 10);
   insertRow(conn, "SOQL2", 10);
   insertRow(conn, "SOQL3", 30);
   insertRow(conn, "SOQL4", 30);
   conn.commit();
   conn.close();
 }
예제 #3
0
 @edu.umd.cs.findbugs.annotations.SuppressWarnings(
     value = "RV_RETURN_VALUE_IGNORED",
     justification = "Test code.")
 private void executeQuery(Connection conn, String query) throws SQLException {
   PreparedStatement st = conn.prepareStatement(query);
   st.executeQuery();
 }
예제 #4
0
 @Test
 public void testGroupByCase() throws Exception {
   GroupByCaseTest gbt = new GroupByCaseTest();
   long ts = gbt.createTable();
   gbt.loadData(ts);
   Properties props = new Properties(TEST_PROPERTIES);
   props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1));
   Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
   gbt.executeQuery(conn, GROUPBY1);
   gbt.executeQuery(conn, GROUPBY2);
   // TODO: validate query results
   try {
     gbt.executeQuery(conn, GROUPBY3);
     fail();
   } catch (SQLException e) {
     assertTrue(e.getMessage().contains("Aggregate expressions may not be used in GROUP BY"));
   }
   conn.close();
 }
예제 #5
0
 private void insertRow(Connection conn, String uri, int appcpu) throws SQLException {
   PreparedStatement statement =
       conn.prepareStatement(
           "UPSERT INTO " + GROUPBYTEST_NAME + "(id, uri, appcpu) values (?,?,?)");
   statement.setString(1, "id" + id);
   statement.setString(2, uri);
   statement.setInt(3, appcpu);
   statement.executeUpdate();
   id++;
 }