protected static void testSqlFromFile(String file) throws Exception{ test(getFile(file)); }
public void compareResultsHyperVector() throws Exception { RecordBatchLoader loader = new RecordBatchLoader(getAllocator()); BaseTestQuery.test(testOptionSettingQueries); List<QueryDataBatch> results = BaseTestQuery.testRunAndReturn(queryType, query); checkNumBatches(results); // To avoid extra work for test writers, types can optionally be inferred from the test query addTypeInfoIfMissing(results.get(0), testBuilder); Map<String, HyperVectorValueIterator> actualSuperVectors = addToHyperVectorMap(results, loader); BaseTestQuery.test(baselineOptionSettingQueries); List<QueryDataBatch> expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery()); Map<String, HyperVectorValueIterator> expectedSuperVectors = addToHyperVectorMap(expected, loader); compareHyperVectors(expectedSuperVectors, actualSuperVectors); cleanupBatches(results, expected); }
BaseTestQuery.test(testOptionSettingQueries); actual = BaseTestQuery.testRunAndReturn(queryType, query); BaseTestQuery.test(baselineOptionSettingQueries); expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery()); addToMaterializedResults(expectedRecords, expected, loader);
public static FileStatus testAndGetResult(final String query, final String testName) throws Exception { final String tableName = format("%s%d", testName, random.nextInt(100000)); final String ctasQuery = format("CREATE TABLE dfs_test.%s STORE AS (type => 'json', prettyPrint => false) WITH SINGLE WRITER AS %s", tableName, query); final Path tableDir = new Path(getDfsTestTmpSchemaLocation(), tableName); test(ctasQuery); // find file final FileStatus fileStatus = localFs.listStatus(tableDir, new GlobFilter("*.json"))[0]; return fileStatus; }
BaseTestQuery.test(testOptionSettingQueries); actual = BaseTestQuery.testRunAndReturn(queryType, query); BaseTestQuery.test(baselineOptionSettingQueries); expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery()); BatchIterator exBatchIter = new BatchIterator(expected, loader);
/** * Utility method which tests given query produces a {@link UserException} and the exception message contains * the given message. * @param testSqlQuery Test query * @param expectedErrorMsg Expected error message. */ protected static void errorMsgTestHelper(final String testSqlQuery, final String expectedErrorMsg) throws Exception { try { test(testSqlQuery); fail("Expected a UserException when running " + testSqlQuery); } catch (final Exception actualException) { try { Assert.assertThat(actualException.getMessage(), CoreMatchers.containsString(expectedErrorMsg)); } catch (AssertionError e) { e.addSuppressed(actualException); throw e; } } }
List<QueryDataBatch> actual = null; try { BaseTestQuery.test(testOptionSettingQueries); actual = BaseTestQuery.testRunAndReturn(queryType, query); QueryDataBatch batch = actual.get(0);
/** * Utility method which tests given query produces a {@link UserException} with the expected * errorType and exception message. * @param testSqlQuery Test query * @param expectedErrorType Expected error type * @param expectedErrorMsg Expected error message. */ protected static void errorMsgWithTypeTestHelper(final String testSqlQuery, final ErrorType expectedErrorType, final String expectedErrorMsg) { try { test(testSqlQuery); fail("Query expected to fail"); } catch (Exception ex) { Assert.assertTrue("UserRemoteException expected", ex instanceof UserRemoteException); UserRemoteException uex = ((UserRemoteException) ex); Assert.assertEquals("Invalid ErrorType. Expected " + expectedErrorType + " but got " + uex.getErrorType(), expectedErrorType, uex.getErrorType()); Assert.assertTrue("Expected message to contain " + expectedErrorMsg + " but was " + uex.getOriginalMessage() + " instead", uex.getOriginalMessage().contains(expectedErrorMsg)); } }