Comments (8)
@vboilay I was able to reproduce the issues you reported.
First, it seems explicit list of columns in insert command is required (@killwort please correct me if I wrong); I guess some error message should be shown instead of just handing forever.
Regarding "Checksum doesn't match: corrupted data", it seems lz4 compression doesn't work correctly for insert commands. I've tried to use command parameters:
ClickHouseConnection conn; /// correct opened CH connection
var cmd = conn.CreateCommand();
cmd.CommandText = "insert into vince_test (fakedate,csa,server) values (@p0, @p1, @p2)";
cmd.AddParameter("p0", DbType.Date, new DateTime(2017, 05, 18) );
cmd.AddParameter("p1", DbType.String, "CSA_CPTY1233");
cmd.AddParameter("p2", DbType.Int32, 0);
cmd.ExecuteNonQuery();
and also got 'Checksum verification failed' exception. But when I disabled the compression ("Compress=False") I was able to execute insert successfully. Please note that DbType should be defined for parameters explicitly, without them I also get strange errors like "Cannot convert parameter with type AnsiString to Date."
Hope this helps.
@killwort what do you think about the following changes/enhancements:
- When "ExecuteNonQuery" is called for non-opened connection NullReferenceException is thrown (not very informative, actually) - possibly it is better to check the connection state and return more relevent exception message
- If insert syntax without columns list is not supported, connector should behave more adequate instead of just hanging up forever.
- Should compression work for inserts? If not, I guess more relevant error message should be shown too.
- If DbType is not specified, I guess it is good idea to infer it from the value - say,
cmd.AddParameter("p0", new DateTime(2017, 05, 18) );
should also work fine.
from clickhouse-net.
from clickhouse-net.
I've added checksum verification only in latest version, and it is still somewhat experimental. Please downgrade to 1.1.2 from nuget and give it a try. Meanwhile, I'll try to reproduce your error and maybe i'll be able to fix it.
PS: Don't use INSERT syntax with parametrized values, even with list of them, it is VERY inefficient! See readme.md to learn how to insert in clickhouse-friendly way. In most cases it leads to some in-memory data collection and then flushing it all in one jumbo insert.
from clickhouse-net.
As for INSERT syntax, its structure is checked in the client library, see /ClickHouse.Ado/Impl/ATG/Insert/Insert.atg. My grammar does not include that case (I think its a generally bad idea not to specify field list), however I'll rewrite this grammar to support fieldless inserts as nothing keeps from doing that. Maybe there would be some problems on the server side as clickhouse is not SQL-92 (or any other version) compliant, time will show :)
from clickhouse-net.
@VitaliyMF :
3: It should, however checksum errors indicate that something is wrong with decompression code itself
4: I could try implement reasonable DbType detection from value although ClickHouse has type system completely incompartible with DbType enum and it will limit its applicability.
from clickhouse-net.
I've added checksum verification only in latest version, and it is still somewhat experimental.
what about adding special settings option (smth like "ChecksumCheck") and keep it disabled by default? It will allow to use latest version with compression for all types of commands, and enable checksum verification when needed.
It would be nice to have some unit tests (even quote primitive) for things like checksum check, SQL parser and data types handling etc. I understand that this might need some time that you possibly don't have.
from clickhouse-net.
I thought about adding checksum check as a connection string parameter. Can't say if it would be disabled by default as it validates message integrity in case of compression, it would be better to leave this enabled (provided that I'll repair it).
As for tests - there're some tests in ClickHouse.Test folder/project yet it is incomplete and covers only core functionality. If you'd like, you could write some test cases and pull request 'em.
from clickhouse-net.
I've fixed both errors, fieldless inserts now work (still, it is bad practice) and checksums are now correctly counted (there were small mistake with checksums for strings of length 16 - 127).
Checksum checking on client side are now controlled by CheckCompressedHash connection string parameter which is on by default.
Update to nuget v.1.1.4 to get these fixes. All older releases are prone to these checksum errors!
from clickhouse-net.
Related Issues (20)
- Any Way To optimize the ClickHouseCommand memory Use HOT 1
- how to set timezone in current connect HOT 3
- Driver hangs when inserting into ReplicatedMergeTree tables HOT 6
- Connection string for cluster db
- Inserting multiple rows doesn't work returns an timeout error HOT 4
- Please add a English and Russian headings in documentation / readme.md HOT 1
- Replace sql parameter error when execute sql HOT 1
- DataTable.Load(DbDataReader) has a wrong hadppend Can't use it in this way? HOT 3
- Пул подключений к БД HOT 1
- System.NotSupportedException:“Unknown column type Decimal(9, 4)” HOT 3
- find a bug ,when process nullable(DateTime) fields
- ClickHouseConnection how to use it properly HOT 1
- how to get correct value from datetime64 ? HOT 1
- DialogueLock of ClickhouseConnection is not released when read command fails and the reader is not created (the method dispose of the reader do the release when it's at least created) HOT 1
- Json Column types are not supported
- Special Character and connect string requirements HOT 1
- Type LowCardinality(Nullable(String)) not supported in v2.0.5 HOT 1
- Best way to measure write performance of batch insertion
- No rows returned in select statement, though data is present in the table HOT 1
- INSERT ... SETTINGS syntax does not work with bulk insertion
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-net.