Package org.apache.calcite.test
Class CsvTest
- java.lang.Object
-
- org.apache.calcite.test.CsvTest
-
public class CsvTest extends java.lang.Object
Unit test of the Calcite adapter for CSV.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CsvTest.Fluent
Fluent API to perform test actions.private static class
CsvTest.Worker<E>
Receives commands on a queue and executes them on its own thread.
-
Constructor Summary
Constructors Constructor Description CsvTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.concurrent.Callable<java.lang.Void>
cancel(java.sql.Statement statement)
Creates a command that cancels a statement.private void
checkSql(java.lang.String sql, java.lang.String model, java.util.function.Consumer<java.sql.ResultSet> 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.lang.String
escapeString(java.lang.String s)
Quotes a string for Java or JSON.private static java.lang.StringBuilder
escapeString(java.lang.StringBuilder buf, java.lang.String s)
Quotes a string for Java or JSON, into a builder.private static java.util.function.Consumer<java.sql.ResultSet>
expect(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.private static java.util.function.Consumer<java.sql.ResultSet>
expectUnordered(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.private java.lang.String
jsonPath(java.lang.String model)
private java.lang.Void
output(java.sql.ResultSet resultSet)
private void
output(java.sql.ResultSet resultSet, java.io.PrintStream out)
private java.lang.String
range(int first, int count)
private java.lang.String
resourcePath(java.lang.String path)
private java.util.concurrent.Callable<java.lang.Void>
sleep(long millis)
Creates a command that sleeps.private CsvTest.Fluent
sql(java.lang.String model, java.lang.String sql)
void
testBadDirectory()
Tests an inline schema with a non-existent directory.void
testBoolean()
void
testCsvStream()
void
testCustomTable()
void
testDateType()
void
testDateType2()
void
testFilterableSelect()
void
testFilterableSelectStar()
void
testFilterableWhere()
Filter that can be fully handled by CsvFilterableTable.void
testFilterableWhere2()
Filter that can be partly handled by CsvFilterableTable.void
testFilterOnNullableTimestamp()
void
testFilterOnNullableTimestamp2()
void
testGreaterThanFilterOnDateType()
void
testGroupByTimestampAdd()
void
testInToSemiJoinWithCast()
void
testInToSemiJoinWithoutCast()
void
testJoinOnString()
void
testJson()
void
testNonNullFilterOnDateType()
void
testPrepared()
void
testPushDownProject()
void
testPushDownProject2()
void
testPushDownProjectAggregate()
void
testPushDownProjectAggregateNested()
void
testPushDownProjectAggregateWithFilter()
void
testPushDownProjectDumb()
void
testReadme()
void
testSelect()
Reads from a table.void
testSelectLongMultiplyInteger()
void
testSelectSingleProject()
void
testSelectSingleProjectGz()
void
testTimestampGroupBy()
void
testTimestampGroupByAndOrderBy()
AstestTimestampGroupBy()
but with ORDER BY as well as GROUP BY.void
testTimestampOrderBy()
AstestTimestampGroupBy()
but with ORDER BY.void
testUnionGroupByWithoutGroupKey()
void
testVanityDriver()
Tests the vanity driver.void
testVanityDriverArgsInUrl()
Tests the vanity driver with properties in the URL.void
testWackyColumns()
private java.util.concurrent.Callable<java.lang.Void>
writeLine(java.io.PrintWriter pw, java.lang.String line)
Creates a command that appends a line to the CSV file.
-
-
-
Method Detail
-
close
private void close(java.sql.Connection connection, java.sql.Statement statement)
-
escapeString
private static java.lang.String escapeString(java.lang.String s)
Quotes a string for Java or JSON.
-
escapeString
private static java.lang.StringBuilder escapeString(java.lang.StringBuilder buf, java.lang.String s)
Quotes a string for Java or JSON, into a builder.
-
testVanityDriver
public void testVanityDriver() throws java.sql.SQLException
Tests the vanity driver.- Throws:
java.sql.SQLException
-
testVanityDriverArgsInUrl
public void testVanityDriverArgsInUrl() throws java.sql.SQLException
Tests the vanity driver with properties in the URL.- Throws:
java.sql.SQLException
-
testBadDirectory
public void testBadDirectory() throws java.sql.SQLException
Tests an inline schema with a non-existent directory.- Throws:
java.sql.SQLException
-
testSelect
public void testSelect() throws java.sql.SQLException
Reads from a table.- Throws:
java.sql.SQLException
-
testSelectSingleProjectGz
public void testSelectSingleProjectGz() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testSelectSingleProject
public void testSelectSingleProject() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testSelectLongMultiplyInteger
public void testSelectLongMultiplyInteger() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testCustomTable
public void testCustomTable() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProjectDumb
public void testPushDownProjectDumb() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProject
public void testPushDownProject() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProject2
public void testPushDownProject2() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProjectAggregate
public void testPushDownProjectAggregate() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProjectAggregateWithFilter
public void testPushDownProjectAggregateWithFilter() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testPushDownProjectAggregateNested
public void testPushDownProjectAggregateNested() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testFilterableSelect
public void testFilterableSelect() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testFilterableSelectStar
public void testFilterableSelectStar() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testFilterableWhere
public void testFilterableWhere() throws java.sql.SQLException
Filter that can be fully handled by CsvFilterableTable.- Throws:
java.sql.SQLException
-
testFilterableWhere2
public void testFilterableWhere2() throws java.sql.SQLException
Filter that can be partly handled by CsvFilterableTable.- Throws:
java.sql.SQLException
-
testJson
public void testJson() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
sql
private CsvTest.Fluent sql(java.lang.String model, java.lang.String sql)
-
expect
private static java.util.function.Consumer<java.sql.ResultSet> expect(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.
-
expectUnordered
private static java.util.function.Consumer<java.sql.ResultSet> expectUnordered(java.lang.String... expected)
Returns a function that checks the contents of a result set against an expected string.
-
checkSql
private void checkSql(java.lang.String sql, java.lang.String model, java.util.function.Consumer<java.sql.ResultSet> fn) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
jsonPath
private java.lang.String jsonPath(java.lang.String model)
-
resourcePath
private java.lang.String resourcePath(java.lang.String path)
-
collect
private static void collect(java.util.List<java.lang.String> result, java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
output
private void output(java.sql.ResultSet resultSet, java.io.PrintStream out) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testJoinOnString
public void testJoinOnString() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testWackyColumns
public void testWackyColumns() throws java.sql.SQLException
- 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
-
testUnionGroupByWithoutGroupKey
public void testUnionGroupByWithoutGroupKey()
-
testBoolean
public void testBoolean()
-
testReadme
public void testReadme() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testInToSemiJoinWithCast
public void testInToSemiJoinWithCast() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testInToSemiJoinWithoutCast
public void testInToSemiJoinWithoutCast() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
range
private java.lang.String range(int first, int count)
-
testDateType
public void testDateType() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testDateType2
public void testDateType2() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testTimestampGroupBy
public void testTimestampGroupBy() throws java.sql.SQLException
Test case for [CALCITE-1673] Query with ORDER BY or GROUP BY on TIMESTAMP column throws CompileException.- Throws:
java.sql.SQLException
-
testTimestampOrderBy
public void testTimestampOrderBy() throws java.sql.SQLException
AstestTimestampGroupBy()
but with ORDER BY.- Throws:
java.sql.SQLException
-
testTimestampGroupByAndOrderBy
public void testTimestampGroupByAndOrderBy() throws java.sql.SQLException
AstestTimestampGroupBy()
but with ORDER BY as well as GROUP BY.- Throws:
java.sql.SQLException
-
testPrepared
public void testPrepared() throws java.sql.SQLException
Test case for [CALCITE-1031] In prepared statement, CsvScannableTable.scan is called twice. To see the bug, place a breakpoint in CsvScannableTable.scan, and note that it is called twice. It should only be called once.- Throws:
java.sql.SQLException
-
testFilterOnNullableTimestamp
public void testFilterOnNullableTimestamp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
testFilterOnNullableTimestamp2
public void testFilterOnNullableTimestamp2() throws java.lang.Exception
Test case for [CALCITE-1118] NullPointerException in EXTRACT with WHERE ... IN clause if field has null value.- Throws:
java.lang.Exception
-
testNonNullFilterOnDateType
public void testNonNullFilterOnDateType() throws java.sql.SQLException
Test case for [CALCITE-1427] Code generation incorrect (does not compile) for DATE, TIME and TIMESTAMP fields.- Throws:
java.sql.SQLException
-
testGreaterThanFilterOnDateType
public void testGreaterThanFilterOnDateType() throws java.sql.SQLException
Test case for [CALCITE-1427] Code generation incorrect (does not compile) for DATE, TIME and TIMESTAMP fields.- Throws:
java.sql.SQLException
-
testCsvStream
public void testCsvStream() throws java.lang.Exception
- Throws:
java.lang.Exception
-
writeLine
private java.util.concurrent.Callable<java.lang.Void> writeLine(java.io.PrintWriter pw, java.lang.String line)
Creates a command that appends a line to the CSV file.
-
sleep
private java.util.concurrent.Callable<java.lang.Void> sleep(long millis)
Creates a command that sleeps.
-
cancel
private java.util.concurrent.Callable<java.lang.Void> cancel(java.sql.Statement statement)
Creates a command that cancels a statement.
-
output
private java.lang.Void output(java.sql.ResultSet resultSet)
-
-