ClickHouse / clickhouse-cpp

C++ client library for ClickHouse
Apache License 2.0
305 stars 159 forks source link

query SetSetting has not effect #392

Closed 1261385937 closed 2 months ago

1261385937 commented 2 months ago

The test code below:

void Client::Impl::Insert(const std::string& table_name, const std::string& query_id, const Block& block) {
    if (options_.ping_before_query) {
        RetryGuard([this]() { Ping(); });
    }

    std::stringstream fields_section;
        const auto num_columns = block.GetColumnCount();

    for (unsigned int i = 0; i < num_columns; ++i) {
        if (i == num_columns - 1) {
            fields_section << NameToQueryString(block.GetColumnName(i));
        } else {
            fields_section << NameToQueryString(block.GetColumnName(i)) << ",";
        }
    }

    Query query("INSERT INTO " + table_name + " ( " + fields_section.str() + " ) VALUES", query_id);
    query.SetSetting("async_insert", QuerySettingsField{"1", 1});
    query.SetSetting("wait_for_async_insert", QuerySettingsField{"1", 1});
    query.SetSetting("async_insert_busy_timeout_ms", QuerySettingsField{"10000", 1});
    SendQuery(query);
...

The Insert interface return immediately , it seems no effect

1261385937 commented 2 months ago

@Enmk Thank you

1261385937 commented 2 months ago

I can not change any item in config.xml. So how to use clickhouse-cpp to enabe async_insert

  1. user level.
  2. connection level.
  3. insert query level.

If the lib has no implementation, it is pleasure to add the feature. Please show the doc 😄 Or could you help me ? @alexey-milovidov @Enmk

1261385937 commented 2 months ago

Available for data is sent as SQL text