Giter Site home page Giter Site logo

Comments (5)

MikeAmputer avatar MikeAmputer commented on August 23, 2024

This library uses the HTTP interface of the ClickHouse server. According to the official documentation:

For successful requests that do not return a data table, an empty response body is returned.

So, there are no options to retrieve the amount of affected rows, while the ADO.NET contract of DbCommand requires an int value to be returned.

In some cases, you can use the ClickHouseCommand.QueryStats attribute to access written_rows metrics provided by the X-ClickHouse-Summary response header. This is particularly useful for INSERT statements, but note that it is set to 0 for TRUNCATE statements.

from clickhouse.client.

MikeAmputer avatar MikeAmputer commented on August 23, 2024

To be honest, Iā€™m not entirely sure if the ExecuteNonQueryAsync implementation will ever return a non-zero value:

using var reader = new ExtendedBinaryReader(await response.Content.ReadAsStreamAsync().ConfigureAwait(false));
return reader.PeekChar() != -1 ? reader.Read7BitEncodedInt() : 0;

All the tests still pass (checked for 23.6) if I simplify this to return 0; (or any other value) =)

from clickhouse.client.

nikkhn avatar nikkhn commented on August 23, 2024

hm ok i misunderstood the client code then. I was looking at this Connection Extensions method and assumed it was using this method as a wrapper over the DbCommand class. (im a bit new to .NET so trying to get my head around things)

from clickhouse.client.

MikeAmputer avatar MikeAmputer commented on August 23, 2024

Correct. The extension method you mentioned calls command.ExecuteNonQueryAsync(), which is the method I was referring to. To access WrittenRows, you'll need to create a command manually:

using var command = connection.CreateCommand();
command.CommandText = sql;
await command.ExecuteNonQueryAsync();
var writtenRows = command.QueryStats.WrittenRows;

from clickhouse.client.

nikkhn avatar nikkhn commented on August 23, 2024

AH i see, ok! thank you @MikeAmputer :)

from clickhouse.client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.