fix clickhouse_driver inserts

This commit is contained in:
Sema Checherinda 2024-12-04 20:05:46 +01:00
parent 5902f3058d
commit 0a85fc6524
4 changed files with 30 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include <Poco/Net/NetException.h> #include <Poco/Net/NetException.h>
#include <Poco/Net/SocketAddress.h> #include <Poco/Net/SocketAddress.h>
#include <Poco/Util/LayeredConfiguration.h> #include <Poco/Util/LayeredConfiguration.h>
#include "Common/StackTrace.h"
#include <Common/Exception.h> #include <Common/Exception.h>
#include <Common/CurrentMetrics.h> #include <Common/CurrentMetrics.h>
#include <Common/CurrentThread.h> #include <Common/CurrentThread.h>
@ -1110,8 +1111,13 @@ void TCPHandler::processInsertQuery(QueryState & state)
startInsertQuery(state); startInsertQuery(state);
while (receivePacketsExpectDataConcurrentWithExecutor(state)) while (receivePacketsExpectDataConcurrentWithExecutor(state))
{
executor.push(std::move(state.block_for_insert)); executor.push(std::move(state.block_for_insert));
sendLogs(state);
sendInsertProfileEvents(state);
}
state.read_all_data = true; state.read_all_data = true;
executor.finish(); executor.finish();

View File

@ -0,0 +1,15 @@
import sys
from clickhouse_driver import Client
def run(database):
client = Client("localhost",user="default",password="")
client.execute(f"CREATE TABLE IF NOT EXISTS {database}.test (x Int32) ENGINE = Memory")
client.execute(f"INSERT INTO {database}.test (x) VALUES", [{"x": 100}])
result = client.execute(f"SELECT * FROM {database}.test")
print(result)
if __name__ == "__main__":
database = sys.argv[1]
run(database)

View File

@ -0,0 +1 @@
[(100,)]

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Tags: no-fasttest
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
python3 03279_with_clickhouse_driver.py $CLICKHOUSE_DATABASE