/**
   * Produces single-node and distributed plans for testCase and compares plan and scan range
   * results. Appends the actual single-node and distributed plan as well as the printed scan ranges
   * to actualOutput, along with the requisite section header. locations to
   * actualScanRangeLocations; compares both to the appropriate sections of 'testCase'.
   */
  private void RunTestCase(
      TestCase testCase,
      StringBuilder errorLog,
      StringBuilder actualOutput,
      String dbName,
      TQueryOptions options)
      throws CatalogException {

    if (options == null) {
      options = defaultQueryOptions();
    } else {
      options = mergeQueryOptions(defaultQueryOptions(), options);
    }

    String query = testCase.getQuery();
    LOG.info("running query " + query);
    if (query.isEmpty()) {
      throw new IllegalStateException(
          "Cannot plan empty query in line: " + testCase.getStartingLineNum());
    }
    TQueryCtx queryCtx = TestUtils.createQueryContext(dbName, System.getProperty("user.name"));
    queryCtx.request.query_options = options;
    // single-node plan and scan range locations
    testSingleNodePlan(testCase, queryCtx, errorLog, actualOutput);
    testDistributedPlan(testCase, queryCtx, errorLog, actualOutput);
    testColumnLineageOutput(testCase, queryCtx, errorLog, actualOutput);
  }
示例#2
0
 /**
  * Produces single-node and distributed plans for testCase and compares plan and scan range
  * results. Appends the actual single-node and distributed plan as well as the printed scan ranges
  * to actualOutput, along with the requisite section header. locations to
  * actualScanRangeLocations; compares both to the appropriate sections of 'testCase'.
  */
 private void RunTestCase(
     TestCase testCase, StringBuilder errorLog, StringBuilder actualOutput, String dbName)
     throws CatalogException {
   String query = testCase.getQuery();
   LOG.info("running query " + query);
   TQueryContext queryCtxt = TestUtils.createQueryContext(dbName, System.getProperty("user.name"));
   queryCtxt.request.query_options.setExplain_level(TExplainLevel.STANDARD);
   queryCtxt.request.query_options.allow_unsupported_formats = true;
   // single-node plan and scan range locations
   testSingleNodePlan(testCase, queryCtxt, errorLog, actualOutput);
   // distributed plan
   testDistributedPlan(testCase, queryCtxt, errorLog, actualOutput);
 }
示例#3
0
 private static AnalysisContext.AnalysisResult analyze(String query) {
   try {
     AnalysisContext analysisCtxt = new AnalysisContext(catalog_, TestUtils.createQueryContext());
     analysisCtxt.analyze(query);
     AnalysisContext.AnalysisResult analysisResult = analysisCtxt.getAnalysisResult();
     Preconditions.checkNotNull(analysisResult.getStmt());
     return analysisResult;
   } catch (Exception e) {
     e.printStackTrace();
     fail("Failed to analyze query: " + query + "\n" + e.getMessage());
   }
   return null;
 }