Improve parsing DateTime64 from timestamp represented as string#55146
Improve parsing DateTime64 from timestamp represented as string#55146hanfei1991 merged 5 commits intoClickHouse:masterfrom
Conversation
|
This is an automated comment for commit 22cab68 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
This comment was marked as resolved.
This comment was marked as resolved.
src/IO/ReadHelpers.h
Outdated
There was a problem hiding this comment.
Hm, why this place does does not check that s has enough data? And I don't see any check upper on the stack...
And this is actually the reason why 01179_insert_values_semicolon "works", since it assumes that it has 19 bytes (date_time_broken_down_length), while it definitely not.
There was a problem hiding this comment.
local :) INSERT INTO test_01179 values ('2020-01-01 0'); ('0')
Ok.
local :) INSERT INTO test_01179 values ('2020-01-01 0'); (' ')
Ok.
local :) INSERT INTO test_01179 values ('2020-01-01 0'); ('0 )
Ok.
Exception on client:
Code: 33. DB::Exception: Cannot read data after semicolon: While executing ValuesBlockInputFormat: data for INSERT was parsed from query. (CANNOT_READ_ALL_DATA), Stack trace (when copying this message, always include the lines below):
0. /src/ch/clickhouse/contrib/llvm-project/libcxx/include/exception:134: Poco::Exception::Exception(String const&, int) @ 0x000000001521f5d2 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
1. /src/ch/clickhouse/src/Common/Exception.cpp:103: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000b8309f7 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
2. /src/ch/clickhouse/contrib/llvm-project/libcxx/include/string:1499: DB::Exception::Exception<char const (&) [33]>(int, char const (&) [33]) @ 0x0000000006d55cb8 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
3. /src/ch/clickhouse/src/Processors/Formats/Impl/ValuesBlockInputFormat.cpp:0: DB::ValuesBlockInputFormat::readSuffix() @ 0x00000000124d214d in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
4. /src/ch/clickhouse/src/Processors/Formats/Impl/ValuesBlockInputFormat.cpp:0: DB::ValuesBlockInputFormat::generate() @ 0x00000000124d14ff in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
5. /src/ch/clickhouse/src/Processors/Chunk.h:90: DB::ISource::tryGenerate() @ 0x00000000122e03d8 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
6. /src/ch/clickhouse/contrib/llvm-project/libcxx/include/optional:344: DB::ISource::work() @ 0x00000000122e0089 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
7. /src/ch/clickhouse/src/Processors/Executors/ExecutionThreadContext.cpp:0: DB::ExecutionThreadContext::executeTask() @ 0x00000000122f5d8d in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
8. /src/ch/clickhouse/src/Processors/Executors/PipelineExecutor.cpp:273: DB::PipelineExecutor::executeStepImpl(unsigned long, std::atomic<bool>*) @ 0x00000000122eda90 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
9. /src/ch/clickhouse/src/Processors/Executors/PipelineExecutor.cpp:239: DB::PipelineExecutor::executeImpl(unsigned long, bool) @ 0x00000000122ed11c in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
10. /src/ch/clickhouse/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:274: DB::PipelineExecutor::execute(unsigned long, bool) @ 0x00000000122ecf02 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
11. /src/ch/clickhouse/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:0: void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'(), void ()>>(std::__function::__policy_storage const*) @ 0x00000000122f8c78 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
12. /src/ch/clickhouse/base/base/../base/wide_integer_impl.h:809: ThreadPoolImpl<std::thread>::worker(std::__list_iterator<std::thread, void*>) @ 0x000000000b901f42 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
13. /src/ch/clickhouse/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:302: void* std::__thread_proxy[abi:v15000]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>(void*) @ 0x000000000b905dae in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
14. ? @ 0x00007ffff7e3a9eb in ?
15. ? @ 0x00007ffff7ebe7cc in ?There was a problem hiding this comment.
But to make the last query throw you need to patch PeekableReadBuffer::hasUnreadData() to check that there is no data left
e4641dd to
60b753e
Compare
96f2697 to
05eea5f
Compare
Allow to parse unambigous short DateTime64 Throw error on invalid DT64 representation (as for DateTime)
05eea5f to
7d54c1f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
The only fail is @hanfei1991 could you please take a look at the PR again? Previous run was spoiled by some mess in protobuf contrib submodule |
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20231026) * fix build due to ClickHouse/ClickHouse#50181 * Revert #1837 since ClickHouse/ClickHouse#56014. Fix build due to removing -Wno-shadow-field * ignore test due to ClickHouse/ClickHouse#55146 * ignore test due to ClickHouse/ClickHouse#55146 --------- Co-authored-by: kyligence-git <[email protected]> Co-authored-by: Chang Chen <[email protected]>
It is OK. Previously, CH did not parse this DateTIme64 correctly, and did not throw during parsing, so parsing simply returned zero and CH thought this is a timestamp: In the example above you can see that such comparison is true in 23.9 when it shall not be true. Now it throws an exception, just like for DateTime. What I dislike about this behavior (23.9 and 23.10) is this part of error message: |
Fix parsing of DateTime64 according to #51753 (like for DateTime) and allow to parse DateTime64 from short strings in unambiguous cases (for negative timestamps and timestamps with non-zero fractional part).
Closes #51753
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Allow to parse negative DateTime64 and DateTime with fractional part from short strings