Search in sources :

Example 6 with InsertMethod

use of io.questdb.cairo.sql.InsertMethod in project questdb by bluestreak01.

the class ImportIODispatcherTest method testImportMisDetectsTimestampColumn.

private void testImportMisDetectsTimestampColumn(HttpServerConfigurationBuilder serverConfigBuilder, int rowCount) throws Exception {
    new HttpQueryTestBuilder().withTempFolder(temp).withWorkerCount(1).withHttpServerConfigBuilder(serverConfigBuilder).withTelemetry(false).run((engine) -> {
        setupSql(engine);
        compiler.compile("create table trips(" + "timestamp TIMESTAMP," + "str STRING," + "i STRING" + ") timestamp(timestamp)", sqlExecutionContext);
        String request = PostHeader.replace("name=trips", "name=trips&skipLev=true") + Request1DataHeader + generateImportCsv(0, rowCount, "aaaaaaaaaaaaaaaaa,22222222222222222222,33333333333333333") + Request1SchemaPart;
        new SendAndReceiveRequestBuilder().withExpectSendDisconnect(true).execute(request, "HTTP/1.1 200 OK\r\n" + "Server: questDB/1.0\r\n" + "Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n" + "Transfer-Encoding: chunked\r\n" + "Content-Type: text/plain; charset=utf-8\r\n" + "\r\n" + "12\r\n" + "not a timestamp ''\r\n" + "00\r\n" + "\r\n");
        CompiledQuery compiledQuery = compiler.compile("insert into trips values (" + "'2021-07-20T00:01:00', 'ABC', 'DEF'" + ")", sqlExecutionContext);
        final InsertStatement insertStatement = compiledQuery.getInsertStatement();
        try (InsertMethod insertMethod = insertStatement.createMethod(sqlExecutionContext)) {
            insertMethod.execute();
            insertMethod.commit();
        }
        compiler.close();
    });
}
Also used : InsertMethod(io.questdb.cairo.sql.InsertMethod) CompiledQuery(io.questdb.griffin.CompiledQuery) InsertStatement(io.questdb.cairo.sql.InsertStatement)

Aggregations

InsertMethod (io.questdb.cairo.sql.InsertMethod)6 InsertStatement (io.questdb.cairo.sql.InsertStatement)5 Test (org.junit.Test)3 CairoException (io.questdb.cairo.CairoException)2 AbstractCairoTest (io.questdb.cairo.AbstractCairoTest)1 CairoEngine (io.questdb.cairo.CairoEngine)1 CompiledQuery (io.questdb.griffin.CompiledQuery)1 SqlCompiler (io.questdb.griffin.SqlCompiler)1 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)1 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)1