コード例 #1
0
  @Test
  public void testInvalidQueries() {

    String[] timeInstants = getTimeInstants();
    String inputTimeRange = getLastTwoDaysTimeRange(timeInstants[0], timeInstants[1]);

    for (final InvalidQuery invalidQuery : IN_VALID_QUERIES) {
      String formattedActualQuery = String.format(invalidQuery.hql, inputTimeRange);
      try {
        DruidVisitor.rewrite(druidDriverConfig, hiveConf, formattedActualQuery);
        Assert.fail("The invalid query" + invalidQuery.name + "did NOT suffer any exception");
      } catch (Throwable e) {
        continue;
      }
    }
  }
コード例 #2
0
  @Test
  public void testQueryTranslation() throws LensException {

    String[] timeInstants = getTimeInstants();
    String inputTimeRange = getLastTwoDaysTimeRange(timeInstants[0], timeInstants[1]);
    String outputTimeRange = getLastTwoDaysJodaTimeRange(timeInstants[0], timeInstants[1]);

    for (final ValidQuery query : VALID_QUERIES) {

      String formattedActualQuery = String.format(query.hql, inputTimeRange);
      String formattedExpectedQuery =
          String.format(query.expectedJson.toString().replace("\"", ""), outputTimeRange);
      String actualQuery =
          DruidVisitor.rewrite(druidDriverConfig, hiveConf, formattedActualQuery).toString();

      log.info("Actual : " + actualQuery);
      log.info("Expected : " + formattedExpectedQuery);
      Assert.assertEquals(
          actualQuery, formattedExpectedQuery, "Test case '" + query.name + "' failed.");
    }
  }