Giter Site home page Giter Site logo

Comments (6)

DarkWanderer avatar DarkWanderer commented on August 23, 2024

readthedocs.io is not the official CH documentation, the official one is here: https://clickhouse.tech/docs. RowBinaryWithNamesAndTypes is described here

Your query has string enclosed in single quotes, this is incorrect according to official docs - it should be without quotes, e.g.:
select {val:String}
http://<clickhouse.server>/?query=select%20{val:String}%20format%20JSONCompact&param_val=str

Basically it seems there's a bug with "legacy" HTTP parameter passing, which allows a query with single quotes to work. I'll fix it in version 2.0.0, thanks for reporting

from clickhouse.client.

ozeno avatar ozeno commented on August 23, 2024

Also, when I try to add a parameter to the where condition the SubstituteParameters method creates the correct query but
when httpParametersSupported is true it returns empty results as well, like so:

command.CommandText = "select col from tbl where {p1:String} like {p2:String}";
command.AddParameter("p1", "String", "col2");
command.AddParameter("p2", "String", "some_string");

About the single quotes, when I left them out SubstituteParameters didn't enclose the parameters in single quotes that's why I kept them within the query.

from clickhouse.client.

DarkWanderer avatar DarkWanderer commented on August 23, 2024

By "when httpParametersSupported is true" do you mean that you force it to true? It won't work that way as the server will not support the parameters in that format. Lack of enclosing string with quotes is the bug I'm talking about, yes.

from clickhouse.client.

DarkWanderer avatar DarkWanderer commented on August 23, 2024

Actually, something does not make sense here. If your server version is 20.3.11.97, you should not be hitting the "parameters compatibility" mode.

I'm trying to reproduce the issue right now and cannot:

            command.CommandText = "select count(*) from system.tables where name = {p1:String}";
            command.AddParameter("p1", "tables");
            Console.WriteLine(await command.ExecuteScalarAsync());

This returns 1, as expected

            command.CommandText = "select count(*) from system.tables where name = '{p1:String}'";
            command.AddParameter("p1", "tables");
            Console.WriteLine(await command.ExecuteScalarAsync());

This returns 0, because of single quotes, again, as expected

Can you share, please:

  • Which version of ClickHouse.Client you use?
  • What is the code you're using to reproduce it?

from clickhouse.client.

ozeno avatar ozeno commented on August 23, 2024

I'm using the 20.3.11.97 version of the ClickHouse and here's what happens as a quick recap:

When I run these lines of code I get empty results (with single quotes):

var command = connection.CreateCommand();
command.CommandText = "select col from tbl where col2 = '{p1:String}'";
command.AddParameter("p1", "some_string");

But it works when I remove the quotes as so:

command.CommandText = "select col from tbl where col2 = {p1:String}";

And stops working again when I have two sides of the where clause as a parameter:

command.CommandText = "select col from tbl where {p1:String} like {p2:String}";
command.AddParameter("p1", "col2");
command.AddParameter("p2", "some_string");

Because it interprets the column name as a string as well, but If I were able to specify the quotes myself (as I can when httpParametersSupported = false) for the p2 only, it would work just fine or if there were another way to specify that the p1 is a column name and not a regular string.

For the question about httpParametersSupported, yes I forced it to be false by changing the value in runtime.

from clickhouse.client.

DarkWanderer avatar DarkWanderer commented on August 23, 2024

Well, first of all, I asked about what version of CliclHouse.Client you use, not about the server. Second, contrary to what you said, the code in your original question works, now you're providing some other scenario - it's not a recap. Third, what you're trying to do is not supported by ADO at all. If you need dynamic SQL, you can generate it yourself and then feed to ClickHouse.Client:
sql = "select col from tbl where " + SomeColumn + " = {param:String}"

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.