Package org.apache.calcite.test
Class ReflectiveSchemaTest
- java.lang.Object
-
- org.apache.calcite.test.ReflectiveSchemaTest
-
public class ReflectiveSchemaTest extends java.lang.Object
Unit tests forReflectiveSchema
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReflectiveSchemaTest.AllPrivate
All field are private, therefore the resulting record has no fields.static class
ReflectiveSchemaTest.BadType
Table that has a field that cannot be recognized as a SQL type.static class
ReflectiveSchemaTest.CatchallSchema
Object whose fields are relations.static class
ReflectiveSchemaTest.DateColumnSchema
Schema that contains a table with a date column.static class
ReflectiveSchemaTest.EmployeeWithHireDate
Extension toJdbcTest.Employee
with ahireDate
column.static class
ReflectiveSchemaTest.EveryType
Record that has a field of every interesting type.static class
ReflectiveSchemaTest.IntAndString
Table that has integer and string fieldsstatic class
ReflectiveSchemaTest.IntHolder
Custom java class that holds just a single field.
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.calcite.adapter.java.ReflectiveSchema
CATCHALL
static java.lang.reflect.Method
LINQ4J_AS_ENUMERABLE_METHOD
-
Constructor Summary
Constructors Constructor Description ReflectiveSchemaTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
check(java.sql.ResultSetMetaData metaData, java.lang.String columnName, java.lang.Class expectedType)
private void
checkAgg(CalciteAssert.AssertThat with, java.lang.String fn)
private void
checkOp(CalciteAssert.AssertThat with, java.lang.String fn)
private int
count(java.sql.ResultSet resultSet)
private java.lang.Object
get(java.sql.ResultSet input)
private static boolean
isNumeric(java.lang.Class type)
void
testAggregateFunctions()
Tests columns based on types such as java.sql.Date and java.util.Date.void
testArrayOfBoxedPrimitives()
Table with single field as Integer[]void
testArrayOfPrimitives()
Table with single field as int[]void
testAvgInt()
void
testCastFromString()
void
testClassNames()
void
testColumnTypes()
Tests columns based on types such as java.sql.Date and java.util.Date.void
testCompareJavaAndSqlTypes()
void
testCustomBoxedSalarCalc()
void
testCustomBoxedScalar()
void
testDateCanCompare()
void
testDateColumn()
Tests column based on java.sql.Date field.void
testDivideWraperPrimitive()
void
testDivideWraperWrapper()
void
testDivideWraperWrapperMultipleTimes()
void
testJavaBoolean()
void
testNoPublicFields()
Tests querying an object that has no public fields.void
testOp()
void
testOperator()
Tests a relation that is accessed via method syntax.void
testPrefix()
Test case for a bug where a Java string 'Abc' compared to a char 'Ab' would be truncated to the char precision and falsely match.void
testQueryProvider()
Test that uses a JDBC connection as a linq4jQueryProvider
.void
testQueryProviderSingleColumn()
void
testReflectiveSchemaInUnnamedPackage()
void
testSchemaFieldHasBadType()
Tests that a schema with a field whose type cannot be recognized throws an informative exception.void
testSelectNOT()
Tests NOT for nullable columnsvoid
testSelectWithFieldAccessOnFirstLevelRecordType()
void
testSelectWithFieldAccessOnFirstLevelRecordTypeArray()
void
testSelectWithFieldAccessOnSecondLevelRecordType()
void
testSelectWithFieldAccessOnSecondLevelRecordTypeArray()
void
testTableFieldHasBadType()
Tests that if a field of a relation has an unrecognized type (in this case aBitSet
) then it is treated as an object.void
testTableMacro()
Finds a table-macro using reflection.void
testTableMacroIsView()
If a method returns aViewTable
.ViewTableMacro
, then it should be expanded.void
testUnknownInOr()
CALCITE-2611 unknown on one side of an or may lead to uncompilable codevoid
testView()
Tests a view.void
testViewPath()
Tests a view with a path.void
testWhereNOT()
Tests NOT for nullable columnsvoid
testWhereWithFieldAccessOnFirstLevelRecordType()
void
testWhereWithFieldAccessOnFirstLevelRecordTypeArray()
void
testWhereWithFieldAccessOnSecondLevelRecordType()
void
testWhereWithFieldAccessOnSecondLevelRecordTypeArray()
-
-
-
Method Detail
-
testQueryProvider
public void testQueryProvider() throws java.lang.Exception
Test that uses a JDBC connection as a linq4jQueryProvider
.- Throws:
java.lang.Exception
- on error
-
testQueryProviderSingleColumn
public void testQueryProviderSingleColumn() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testOperator
public void testOperator() throws java.sql.SQLException, java.lang.ClassNotFoundException
Tests a relation that is accessed via method syntax. The function returns aQueryable
.- Throws:
java.sql.SQLException
java.lang.ClassNotFoundException
-
testView
public void testView() throws java.sql.SQLException, java.lang.ClassNotFoundException
Tests a view.- Throws:
java.sql.SQLException
java.lang.ClassNotFoundException
-
testViewPath
public void testViewPath() throws java.sql.SQLException, java.lang.ClassNotFoundException
Tests a view with a path.- Throws:
java.sql.SQLException
java.lang.ClassNotFoundException
-
count
private int count(java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testDateColumn
public void testDateColumn() throws java.lang.Exception
Tests column based on java.sql.Date field.- Throws:
java.lang.Exception
-
testNoPublicFields
public void testNoPublicFields() throws java.lang.Exception
Tests querying an object that has no public fields.- Throws:
java.lang.Exception
-
testColumnTypes
public void testColumnTypes() throws java.lang.Exception
Tests columns based on types such as java.sql.Date and java.util.Date.- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.everyTypes
-
testWhereNOT
public void testWhereNOT() throws java.lang.Exception
Tests NOT for nullable columns- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.everyTypes
-
testSelectNOT
public void testSelectNOT() throws java.lang.Exception
Tests NOT for nullable columns- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.everyTypes
-
testSelectWithFieldAccessOnFirstLevelRecordType
public void testSelectWithFieldAccessOnFirstLevelRecordType()
-
testSelectWithFieldAccessOnSecondLevelRecordType
public void testSelectWithFieldAccessOnSecondLevelRecordType()
-
testWhereWithFieldAccessOnFirstLevelRecordType
public void testWhereWithFieldAccessOnFirstLevelRecordType()
-
testWhereWithFieldAccessOnSecondLevelRecordType
public void testWhereWithFieldAccessOnSecondLevelRecordType()
-
testSelectWithFieldAccessOnFirstLevelRecordTypeArray
public void testSelectWithFieldAccessOnFirstLevelRecordTypeArray()
-
testSelectWithFieldAccessOnSecondLevelRecordTypeArray
public void testSelectWithFieldAccessOnSecondLevelRecordTypeArray()
-
testWhereWithFieldAccessOnFirstLevelRecordTypeArray
public void testWhereWithFieldAccessOnFirstLevelRecordTypeArray()
-
testWhereWithFieldAccessOnSecondLevelRecordTypeArray
public void testWhereWithFieldAccessOnSecondLevelRecordTypeArray()
-
testAggregateFunctions
public void testAggregateFunctions() throws java.lang.Exception
Tests columns based on types such as java.sql.Date and java.util.Date.- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.everyTypes
-
checkAgg
private void checkAgg(CalciteAssert.AssertThat with, java.lang.String fn)
-
get
private java.lang.Object get(java.sql.ResultSet input) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testClassNames
public void testClassNames() throws java.lang.Exception
- Throws:
java.lang.Exception
-
check
private void check(java.sql.ResultSetMetaData metaData, java.lang.String columnName, java.lang.Class expectedType) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testJavaBoolean
public void testJavaBoolean() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testCompareJavaAndSqlTypes
public void testCompareJavaAndSqlTypes() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testDivideWraperPrimitive
public void testDivideWraperPrimitive() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testDivideWraperWrapper
public void testDivideWraperWrapper() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testDivideWraperWrapperMultipleTimes
public void testDivideWraperWrapperMultipleTimes() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testOp
public void testOp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
checkOp
private void checkOp(CalciteAssert.AssertThat with, java.lang.String fn)
-
testCastFromString
public void testCastFromString()
-
testAvgInt
public void testAvgInt() throws java.lang.Exception
- Throws:
java.lang.Exception
-
isNumeric
private static boolean isNumeric(java.lang.Class type)
-
testTableFieldHasBadType
public void testTableFieldHasBadType() throws java.lang.Exception
Tests that if a field of a relation has an unrecognized type (in this case aBitSet
) then it is treated as an object.- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.badTypes
-
testSchemaFieldHasBadType
public void testSchemaFieldHasBadType() throws java.lang.Exception
Tests that a schema with a field whose type cannot be recognized throws an informative exception.- Throws:
java.lang.Exception
- See Also:
ReflectiveSchemaTest.CatchallSchema.enumerable
,ReflectiveSchemaTest.CatchallSchema.list
-
testPrefix
public void testPrefix() throws java.lang.Exception
Test case for a bug where a Java string 'Abc' compared to a char 'Ab' would be truncated to the char precision and falsely match.- Throws:
java.lang.Exception
-
testTableMacroIsView
public void testTableMacroIsView() throws java.lang.Exception
If a method returns aViewTable
.ViewTableMacro
, then it should be expanded.- Throws:
java.lang.Exception
-
testTableMacro
public void testTableMacro() throws java.lang.Exception
Finds a table-macro using reflection.- Throws:
java.lang.Exception
-
testArrayOfBoxedPrimitives
public void testArrayOfBoxedPrimitives()
Table with single field as Integer[]
-
testArrayOfPrimitives
public void testArrayOfPrimitives()
Table with single field as int[]
-
testCustomBoxedScalar
public void testCustomBoxedScalar()
-
testCustomBoxedSalarCalc
public void testCustomBoxedSalarCalc()
-
testDateCanCompare
public void testDateCanCompare()
-
testReflectiveSchemaInUnnamedPackage
public void testReflectiveSchemaInUnnamedPackage() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testUnknownInOr
public void testUnknownInOr()
CALCITE-2611 unknown on one side of an or may lead to uncompilable code
-
-