Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 3
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();
 }