diff --git a/src/Common/DateLUT.h b/src/Common/DateLUT.h index b960fb91d77..b7ba37c2bec 100644 --- a/src/Common/DateLUT.h +++ b/src/Common/DateLUT.h @@ -56,17 +56,17 @@ private: std::atomic default_impl; }; -static inline UInt64 timeInMilliseconds(std::chrono::time_point timepoint) +inline UInt64 timeInMilliseconds(std::chrono::time_point timepoint) { return std::chrono::duration_cast(timepoint.time_since_epoch()).count(); } -static inline UInt64 timeInMicroseconds(std::chrono::time_point timepoint) +inline UInt64 timeInMicroseconds(std::chrono::time_point timepoint) { return std::chrono::duration_cast(timepoint.time_since_epoch()).count(); } -static inline UInt64 timeInSeconds(std::chrono::time_point timepoint) +inline UInt64 timeInSeconds(std::chrono::time_point timepoint) { return std::chrono::duration_cast(timepoint.time_since_epoch()).count(); } diff --git a/src/Interpreters/AsynchronousInsertLog.cpp b/src/Interpreters/AsynchronousInsertLog.cpp index 73d2c85dc86..916ec8f3d56 100644 --- a/src/Interpreters/AsynchronousInsertLog.cpp +++ b/src/Interpreters/AsynchronousInsertLog.cpp @@ -19,7 +19,7 @@ NamesAndTypesList AsynchronousInsertLogElement::getNamesAndTypes() auto type_status = std::make_shared( DataTypeEnum8::Values { - {"Ok", static_cast(Status::Ok)}, + {"Ok", static_cast(Status::Ok)}, {"ParsingError", static_cast(Status::ParsingError)}, {"FlushError", static_cast(Status::FlushError)}, }); @@ -64,8 +64,8 @@ void AsynchronousInsertLogElement::appendToBlock(MutableColumns & columns) const } else { - columns[i++]->insert(insert_query.table_id.getDatabaseName()); - columns[i++]->insert(insert_query.table_id.getTableName()); + columns[i++]->insertDefault(); + columns[i++]->insertDefault(); } columns[i++]->insert(insert_query.format); diff --git a/src/Interpreters/AsynchronousInsertLog.h b/src/Interpreters/AsynchronousInsertLog.h index d6ddb727864..e2fdd4c90a0 100644 --- a/src/Interpreters/AsynchronousInsertLog.h +++ b/src/Interpreters/AsynchronousInsertLog.h @@ -11,11 +11,11 @@ namespace DB struct AsynchronousInsertLogElement { - enum Status + enum Status : Int8 { - Ok, - ParsingError, - FlushError, + Ok = 0, + ParsingError = 1, + FlushError = 2, }; time_t event_time{}; @@ -23,15 +23,15 @@ struct AsynchronousInsertLogElement ASTPtr query; String query_id; - UInt64 bytes; + UInt64 bytes{}; String exception; - Status status; + Status status{}; time_t flush_time{}; Decimal64 flush_time_microseconds{}; String flush_query_id; - static std::string name() { return "AsynchronousInserts"; } + static std::string name() { return "AsynchronousInsertLog"; } static NamesAndTypesList getNamesAndTypes(); static NamesAndAliases getNamesAndAliases() { return {}; } void appendToBlock(MutableColumns & columns) const; diff --git a/tests/queries/0_stateless/02456_async_inserts_logs.reference b/tests/queries/0_stateless/02456_async_inserts_logs.reference index cbccd74da11..efd8a88eca4 100644 --- a/tests/queries/0_stateless/02456_async_inserts_logs.reference +++ b/tests/queries/0_stateless/02456_async_inserts_logs.reference @@ -1,3 +1,5 @@ +5 + Values 21 1 Ok 1 t_async_inserts_logs JSONEachRow 39 1 Ok 1 t_async_inserts_logs Values 8 1 Ok 1 t_async_inserts_logs JSONEachRow 6 0 ParsingError 1 diff --git a/tests/queries/0_stateless/02456_async_inserts_logs.sh b/tests/queries/0_stateless/02456_async_inserts_logs.sh index 34fe12b6d56..006455e2d42 100755 --- a/tests/queries/0_stateless/02456_async_inserts_logs.sh +++ b/tests/queries/0_stateless/02456_async_inserts_logs.sh @@ -15,6 +15,8 @@ ${CLICKHOUSE_CURL} -sS "$url" -d "INSERT INTO t_async_inserts_logs VALUES (1, 'a ${CLICKHOUSE_CURL} -sS "$url" -d 'INSERT INTO t_async_inserts_logs FORMAT JSONEachRow qqqqqq' > /dev/null 2>&1 & ${CLICKHOUSE_CURL} -sS "$url" -d 'INSERT INTO t_async_inserts_logs VALUES qqqqqq' > /dev/null 2>&1 & +${CLICKHOUSE_CURL} -sS "$url" -d "INSERT INTO FUNCTION remote('127.0.0.1', currentDatabase(), t_async_inserts_logs) VALUES (1, 'aaa') (2, 'bbb')" & + wait ${CLICKHOUSE_CLIENT} -q "OPTIMIZE TABLE t_async_inserts_logs FINAL" @@ -24,11 +26,14 @@ ${CLICKHOUSE_CURL} -sS "$url" -d "INSERT INTO t_async_inserts_logs VALUES (1, 'a wait +${CLICKHOUSE_CLIENT} -q "SELECT count() FROM t_async_inserts_logs" + ${CLICKHOUSE_CLIENT} -q "SYSTEM FLUSH LOGS" ${CLICKHOUSE_CLIENT} -q " SELECT table, format, bytes, empty(exception), status, status = 'ParsingError' ? flush_time_microseconds = 0 : flush_time_microseconds > event_time_microseconds AS time_ok - FROM system.asynchronous_insert_log WHERE database = '$CLICKHOUSE_DATABASE' + FROM system.asynchronous_insert_log + WHERE database = '$CLICKHOUSE_DATABASE' OR query ILIKE 'INSERT INTO FUNCTION%$CLICKHOUSE_DATABASE%' ORDER BY table, status, format" ${CLICKHOUSE_CLIENT} -q "DROP TABLE t_async_inserts_logs"