|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql.test.AbstractSqlTester
public abstract class AbstractSqlTester
Abstract implementation of SqlTester
. A derived class only needs to
implement SqlTester.check(java.lang.String, org.eigenbase.sql.test.SqlTester.TypeChecker, java.lang.Object, double)
, SqlTester.checkColumnType(java.lang.String, java.lang.String)
and SqlTester.checkFails(java.lang.String, java.lang.String, boolean)
.
Nested Class Summary | |
---|---|
private static class |
AbstractSqlTester.SqlTypeChecker
Checks that a type matches a given SQL type. |
static class |
AbstractSqlTester.StringTypeChecker
Type checker which compares types to a specified string. |
Nested classes/interfaces inherited from interface org.eigenbase.sql.test.SqlTester |
---|
SqlTester.TypeChecker, SqlTester.VmName |
Field Summary | |
---|---|
static SqlTester.TypeChecker |
AnyTypeChecker
Checker which allows any type. |
static SqlTester.TypeChecker |
BooleanTypeChecker
|
static SqlTester.TypeChecker |
IntegerTypeChecker
|
private SqlOperator |
operator
|
Constructor Summary | |
---|---|
AbstractSqlTester()
|
Method Summary | |
---|---|
protected String |
buildQuery(String expression)
Helper method which converts a scalar expression into a SQL query. |
void |
checkAgg(String expr,
String[] inputValues,
Object result,
double delta)
Checks that an aggregate expression returns the expected result. |
void |
checkBoolean(String expression,
Boolean result)
Tests that a scalar SQL expression returns the expected boolean result. |
void |
checkNull(String expression)
Tests that a SQL expression returns the SQL NULL value. |
void |
checkScalar(String expression,
Object result,
String resultType)
Tests that a scalar SQL expression returns the expected result and the expected type. |
void |
checkScalarApprox(String expression,
String expectedType,
double expectedResult,
double delta)
Tests that a scalar SQL expression returns expected appoximate numeric result. |
void |
checkScalarExact(String expression,
String result)
Tests that a scalar SQL expression returns the expected exact numeric result as an integer. |
void |
checkScalarExact(String expression,
String expectedType,
String result)
Tests that a scalar SQL expression returns the expected exact numeric result. |
void |
checkString(String expression,
String result,
String expectedType)
Tests that a scalar SQL expression returns the expected string result. |
void |
checkType(String expression,
String type)
Tests that a SQL expression has a given type. |
void |
checkWinAgg(String expr,
String[] inputValues,
String windowSpec,
String type,
Object result,
double delta)
Checks that a windowed aggregate expression returns the expected result. |
static String |
generateAggQuery(String expr,
String[] inputValues)
|
static String |
generateWinAggQuery(String expr,
String windowSpec,
String[] inputValues)
|
protected SqlOperator |
getFor()
Returns the operator this test is for. |
static String |
getTypeString(RelDataType sqlType)
Helper function to get the string representation of a RelDataType (include precision/scale but no charset or collation) |
void |
setFor(SqlOperator operator,
SqlTester.VmName... unimplementedVmNames)
Declares that this test is for a given operator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eigenbase.sql.test.SqlTester |
---|
check, checkColumnType, checkFails |
Field Detail |
---|
public static final SqlTester.TypeChecker IntegerTypeChecker
public static final SqlTester.TypeChecker BooleanTypeChecker
public static final SqlTester.TypeChecker AnyTypeChecker
private SqlOperator operator
Constructor Detail |
---|
public AbstractSqlTester()
Method Detail |
---|
public void setFor(SqlOperator operator, SqlTester.VmName... unimplementedVmNames)
SqlTester
setFor
in interface SqlTester
operator
- OperatorunimplementedVmNames
- Names of virtual machines for which thispublic void checkAgg(String expr, String[] inputValues, Object result, double delta)
SqlTester
For example, checkAgg("AVG(DISTINCT x)", new String[] {"2", "3",
null, "3" }, new Double(2.5), 0);
checkAgg
in interface SqlTester
expr
- Aggregate expression, e.g. SUM(DISTINCT x)
inputValues
- Array of input values, e.g. ["1", null,
"2"]
.result
- Expected resultdelta
- Allowable variance from expected resultpublic void checkWinAgg(String expr, String[] inputValues, String windowSpec, String type, Object result, double delta)
SqlTester
For example, checkWinAgg("FIRST_VALUE(x)", new String[] {"2",
"3", null, "3" }, "INTEGER NOT NULL", 2, 0d);
checkWinAgg
in interface SqlTester
expr
- Aggregate expression, e.g. SUM(DISTINCT x)
inputValues
- Array of input values, e.g. ["1", null,
"2"]
.type
- Expected result typeresult
- Expected resultdelta
- Allowable variance from expected resultpublic static String getTypeString(RelDataType sqlType)
sqlType
- Type
public static String generateAggQuery(String expr, String[] inputValues)
public static String generateWinAggQuery(String expr, String windowSpec, String[] inputValues)
protected String buildQuery(String expression)
By default, "expr" becomes "VALUES (expr)". Derived classes may override.
expression
- Expression
public void checkType(String expression, String type)
SqlTester
This method checks length/precision, scale, and whether the type allows NULL values, so is more precise than the type-checking done by methods such ascheckType("SUBSTR('hello' FROM 1 FOR 3)", "VARCHAR(3) NOT NULL");
SqlTester.checkScalarExact(java.lang.String, java.lang.String)
.
checkType
in interface SqlTester
expression
- Scalar expressiontype
- Type stringpublic void checkScalarExact(String expression, String result)
SqlTester
checkScalarExact("1 + 2", "3");
checkScalarExact
in interface SqlTester
expression
- Scalar expressionresult
- Expected resultpublic void checkScalarExact(String expression, String expectedType, String result)
SqlTester
checkScalarExact("1 + 2", "3");
checkScalarExact
in interface SqlTester
expression
- Scalar expressionexpectedType
- Type we expect the result to have, including
nullability, precision and scale, for example DECIMAL(2, 1) NOT
NULL
.result
- Expected resultpublic void checkScalarApprox(String expression, String expectedType, double expectedResult, double delta)
SqlTester
checkScalarApprox("1.0 + 2.1", "3.1");
checkScalarApprox
in interface SqlTester
expression
- Scalar expressionexpectedType
- Type we expect the result to have, including
nullability, precision and scale, for example DECIMAL(2, 1) NOT
NULL
.expectedResult
- Expected resultdelta
- Allowed margin of error between expected and actual resultpublic void checkBoolean(String expression, Boolean result)
SqlTester
The expected result can be null:checkScalarExact("TRUE AND FALSE", Boolean.TRUE);
checkScalarExact("NOT UNKNOWN", null);
checkBoolean
in interface SqlTester
expression
- Scalar expressionresult
- Expected result (null signifies NULL).public void checkString(String expression, String result, String expectedType)
SqlTester
checkScalarExact("'ab' || 'c'", "abc");
checkString
in interface SqlTester
expression
- Scalar expressionresult
- Expected resultexpectedType
- Expected result typepublic void checkNull(String expression)
SqlTester
checkNull("CHAR_LENGTH(CAST(NULL AS VARCHAR(3))");
checkNull
in interface SqlTester
expression
- Scalar expressionpublic void checkScalar(String expression, Object result, String resultType)
SqlTester
checkScalar("1.1 + 2.9", "4.0", "DECIMAL(2, 1) NOT NULL");
checkScalar
in interface SqlTester
expression
- Scalar expressionresult
- Expected resultresultType
- Expected result typeprotected SqlOperator getFor()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |