public async Task ShouldInsertParameterizedArray() { await connection.ExecuteStatementAsync("TRUNCATE TABLE IF EXISTS test.float_array"); await connection.ExecuteStatementAsync("CREATE TABLE IF NOT EXISTS test.float_array (arr Array(Float64)) ENGINE Memory"); var command = connection.CreateCommand(); command.AddParameter("values", new[] { 1.0, 2.0, 3.0 }); command.CommandText = "INSERT INTO test.float_array VALUES ({values:Array(Float32)})"; await command.ExecuteNonQueryAsync(); var count = await connection.ExecuteScalarAsync("SELECT COUNT(*) FROM test.float_array"); Assert.AreEqual(1, count); }
public async Task TimeoutShouldCancelConnection() { var builder = TestUtilities.GetConnectionStringBuilder(); builder.UseSession = false; builder.Compression = true; builder.Timeout = TimeSpan.FromMilliseconds(5); var connection = new ClickHouseConnection(builder.ToString()); try { var task = connection.ExecuteScalarAsync("SELECT sleep(1)"); _ = await task; Assert.Fail("The task should have been cancelled before completion"); } catch (TaskCanceledException) { /* Expected: task cancelled */ } }
public async Task ShouldSelectSimpleAggregateFunction() { var result = await connection.ExecuteScalarAsync("SELECT CAST(1,'SimpleAggregateFunction(anyLast, Nullable(Float64))')"); Assert.AreEqual(1, result); }
public async Task <bool> ExecuteExists(string sqlQuery) { return((ulong?)await _clickHouseConnection.ExecuteScalarAsync(sqlQuery) > 0); }