Comments (6)
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¶m_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.
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.
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.
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.
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.
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)
- Add way to set BulkCopy columns HOT 1
- Perform regression tests on all supported .NET platforms
- Password not being accepted by Clickhouse.Client HOT 1
- Nullable DateTime HOT 1
- ClickHouseConnectionFactory.Instace HOT 1
- Query optimization suggestion HOT 5
- ClickHouseBulkCopy zipstream got a low performance because not in parallel mode HOT 2
- Please consider providing a strong name for ClickHouse.Client HOT 2
- ClickHouseBulkCopy sends additional empty request if BatchSize equals to rows collection length HOT 2
- Writing dates before 01.01.1970 HOT 1
- RowsWritten Problem
- Insert data for nested type inside a nested type HOT 1
- DataTable.Load fails with System.InvalidCastException exception HOT 2
- Support for Brotli compression format HOT 1
- The cancellation token does not cancel the queue on ClickHouse. HOT 5
- New ClickHouse type HOT 1
- Readact Connection String in Tracing HOT 1
- How to use HOT 1
- how to use bulkcopy HOT 1
- SSH tunnel connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clickhouse.client.