Package org.apache.calcite.adapter.file
Class SqlTest
- java.lang.Object
-
- org.apache.calcite.adapter.file.SqlTest
-
public class SqlTest extends java.lang.Object
System test of the Calcite file adapter, which can also read and parse HTML tables over HTTP.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SqlTest.Fluent
Fluent API to perform test actions.
-
Constructor Summary
Constructors Constructor Description SqlTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkSql(java.lang.String sql, java.lang.String model, java.util.function.Function<java.sql.ResultSet,java.lang.Void> fn)
private void
close(java.sql.Connection connection, java.sql.Statement statement)
private static void
collect(java.util.List<java.lang.String> result, java.sql.ResultSet resultSet)
private static java.util.function.Function<java.sql.ResultSet,java.lang.Void>
expect(java.lang.String... expectedLines)
private static java.util.function.Function<java.sql.ResultSet,java.lang.Void>
expectUnordered(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.private SqlTest.Fluent
sql(java.lang.String model, java.lang.String sql)
void
testCsvSalesDepts()
Reads the DEPTS table from the CSV schema.void
testCsvSalesEmps()
Reads the EMPS table from the CSV schema.void
testCsvSalesEmpty()
Reads the EMPTY table from the CSV schema.void
testCsvSalesHeaderOnly()
Reads the HEADER_ONLY table from the CSV schema.void
testFileSelect()
Reads from a local file and checks the result.void
testFindBiggerNoTh()
Reads from a local file - finds larger table even without <TH> elements.void
testGroupByTimestampAdd()
void
testNoThSelect()
Reads from a local file without table headers <TH> and checks the result.void
testSalesDepts()
Reads the DEPTS table.void
testSalesEmps()
Reads the EMPS table.void
testUrlSelect()
Reads from a URL and checks the result.private static java.lang.String
toString(java.sql.ResultSet resultSet)
-
-
-
Method Detail
-
sql
private SqlTest.Fluent sql(java.lang.String model, java.lang.String sql)
-
expect
private static java.util.function.Function<java.sql.ResultSet,java.lang.Void> expect(java.lang.String... expectedLines)
-
expectUnordered
private static java.util.function.Function<java.sql.ResultSet,java.lang.Void> expectUnordered(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.
-
collect
private static void collect(java.util.List<java.lang.String> result, java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
checkSql
private void checkSql(java.lang.String sql, java.lang.String model, java.util.function.Function<java.sql.ResultSet,java.lang.Void> fn) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
toString
private static java.lang.String toString(java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
close
private void close(java.sql.Connection connection, java.sql.Statement statement)
-
testFileSelect
public void testFileSelect() throws java.sql.SQLException
Reads from a local file and checks the result.- Throws:
java.sql.SQLException
-
testNoThSelect
public void testNoThSelect() throws java.sql.SQLException
Reads from a local file without table headers <TH> and checks the result.- Throws:
java.sql.SQLException
-
testFindBiggerNoTh
public void testFindBiggerNoTh() throws java.sql.SQLException
Reads from a local file - finds larger table even without <TH> elements.- Throws:
java.sql.SQLException
-
testUrlSelect
public void testUrlSelect() throws java.sql.SQLException
Reads from a URL and checks the result.- Throws:
java.sql.SQLException
-
testSalesEmps
public void testSalesEmps() throws java.sql.SQLException
Reads the EMPS table.- Throws:
java.sql.SQLException
-
testSalesDepts
public void testSalesDepts() throws java.sql.SQLException
Reads the DEPTS table.- Throws:
java.sql.SQLException
-
testCsvSalesDepts
public void testCsvSalesDepts() throws java.sql.SQLException
Reads the DEPTS table from the CSV schema.- Throws:
java.sql.SQLException
-
testCsvSalesEmps
public void testCsvSalesEmps() throws java.sql.SQLException
Reads the EMPS table from the CSV schema.- Throws:
java.sql.SQLException
-
testCsvSalesHeaderOnly
public void testCsvSalesHeaderOnly() throws java.sql.SQLException
Reads the HEADER_ONLY table from the CSV schema. The CSV file has one line - the column headers - but no rows of data.- Throws:
java.sql.SQLException
-
testCsvSalesEmpty
public void testCsvSalesEmpty() throws java.sql.SQLException
Reads the EMPTY table from the CSV schema. The CSV file has no lines, therefore the table has a system-generated column called "EmptyFileHasNoColumns".- Throws:
java.sql.SQLException
-
testGroupByTimestampAdd
public void testGroupByTimestampAdd() throws java.sql.SQLException
Test case for [CALCITE-1754] In Csv adapter, convert DATE and TIME values to int, and TIMESTAMP values to long.- Throws:
java.sql.SQLException
-
-