public class QueryTestUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static long |
ConvertDateToLong(String dateString)
When writing Drill unit tests, Drill will output strings for dates.
|
static DrillClient |
createClient(DrillConfig drillConfig,
RemoteServiceSet remoteServiceSet,
int maxWidth,
Properties props)
Create a DrillClient that can be used to query a drill cluster.
|
static void |
generateCompressedFile(String fileName,
String codecName,
String outFileName)
Generates a compressed version of the file for testing
|
static int |
getFreePortNumber(int portNumber,
int numberOfAttempts)
Checks that port with specified number is free and returns it.
|
static String |
normalizeQuery(String query)
Normalize the query relative to the test environment.
|
static void |
restoreScalarReplacementOption(Drillbit drillbit,
String srOption)
Restore the original scalar replacement option returned from
setupScalarReplacementOption().
|
static OptionValue |
setupScalarReplacementOption(Drillbit drillbit,
ClassTransformer.ScalarReplacementOption srOption)
Set up the options to test the scalar replacement retry option (see
ClassTransformer.java).
|
static void |
testRunAndLog(DrillClient drillClient,
String queryString)
Execute one or more queries separated by semicolons, and log the results.
|
static void |
testRunAndLog(DrillClient drillClient,
String query,
Object... args)
Execute one or more queries separated by semicolons, and log the results, with the option to
add formatted arguments to the query string.
|
static int |
testRunAndLog(DrillClient drillClient,
UserBitShared.QueryType type,
String queryString)
Execute a SQL query, and log the results.
|
static void |
testRunAndOutput(DrillClient drillClient,
String queryString,
boolean print)
Execute one or more queries separated by semicolons, and output the results.
|
static void |
testRunAndPrint(DrillClient drillClient,
String queryString)
Execute one or more queries separated by semicolons, and print the results.
|
static void |
testRunAndPrint(DrillClient drillClient,
String query,
Object... args)
Execute one or more queries separated by semicolons, and print the results, with the option to
add formatted arguments to the query string.
|
static int |
testRunAndPrint(DrillClient drillClient,
UserBitShared.QueryType type,
String queryString)
Execute a SQL query, and print the results.
|
static void |
testWithListener(DrillClient drillClient,
UserBitShared.QueryType type,
String queryString,
UserResultsListener resultListener)
Execute a single query with a user supplied result listener.
|
public static DrillClient createClient(DrillConfig drillConfig, RemoteServiceSet remoteServiceSet, int maxWidth, Properties props) throws RpcException, OutOfMemoryException
drillConfig - remoteServiceSet - remote service setmaxWidth - maximum width per nodeprops - Connection properties contains properties such as "user", "password", "schema" etcRpcException - if there is a problem setting up the clientOutOfMemoryExceptionpublic static String normalizeQuery(String query)
Looks for "${WORKING_PATH}" in the query string, and replaces it the current
working patch obtained from TestTools#WORKING_PATH.
query - the query stringpublic static void testRunAndOutput(DrillClient drillClient, String queryString, boolean print) throws Exception
drillClient - drill client to usequeryString - the query stringprint - True to output results to stdout. False to log results.Exception - An error while running the query.public static int testRunAndLog(DrillClient drillClient, UserBitShared.QueryType type, String queryString) throws Exception
drillClient - drill client to usetype - type of the queryqueryString - query stringException - An error while running the query.public static void testRunAndLog(DrillClient drillClient, String queryString) throws Exception
drillClient - drill client to usequeryString - the query stringException - An error while running the queries.public static void testRunAndLog(DrillClient drillClient, String query, Object... args) throws Exception
drillClient - drill client to usequery - the query string; may contain formatting specifications to be used by
String.format(String, Object...).args - optional args to use in the formatting call for the query stringException - An error while running the query.public static int testRunAndPrint(DrillClient drillClient, UserBitShared.QueryType type, String queryString) throws Exception
drillClient - drill client to usetype - type of the queryqueryString - query stringException - An error while running the query.public static void testRunAndPrint(DrillClient drillClient, String queryString) throws Exception
drillClient - drill client to usequeryString - the query stringException - An error while running the queries.public static void testRunAndPrint(DrillClient drillClient, String query, Object... args) throws Exception
drillClient - drill client to usequery - the query string; may contain formatting specifications to be used by
String.format(String, Object...).args - optional args to use in the formatting call for the query stringException - An error while running the query.public static void testWithListener(DrillClient drillClient, UserBitShared.QueryType type, String queryString, UserResultsListener resultListener)
drillClient - drill client to usetype - type of queryqueryString - the query stringresultListener - the result listenerpublic static OptionValue setupScalarReplacementOption(Drillbit drillbit, ClassTransformer.ScalarReplacementOption srOption)
This also flushes the compiled code cache.
drillbit - the drillbitsrOption - the scalar replacement option value to usepublic static void restoreScalarReplacementOption(Drillbit drillbit, String srOption)
This also flushes the compiled code cache.
drillbit - the drillbitsrOption - the scalar replacement option value to usepublic static int getFreePortNumber(int portNumber,
int numberOfAttempts)
throws IOException
portNumber - initial port numbernumberOfAttempts - max number of attempts to find port with greater numberBindException - if free port was not found and all attempts were used.IOExceptionpublic static void generateCompressedFile(String fileName, String codecName, String outFileName) throws IOException
fileName - Name of the input filecodecName - The desired CODEC to be used.outFileName - Name of generated compressed fileIOException - If function cannot generate file, throws IOExceptionpublic static long ConvertDateToLong(String dateString)
dateString - An input date string from Drill outputCopyright © 2022 The Apache Software Foundation. All rights reserved.