aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/AsynchronousInsertLog.h
blob: a76db78d3eaa8996eee2553f4342549b12b3cc98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include "Common/Exception.h"
#include <Interpreters/SystemLog.h>
#include <Core/NamesAndTypes.h>
#include <Core/NamesAndAliases.h>
#include <Parsers/IAST_fwd.h>

namespace DB
{

struct AsynchronousInsertLogElement
{
    enum Status : Int8
    {
        Ok = 0,
        ParsingError = 1,
        FlushError = 2,
    };

    time_t event_time{};
    Decimal64 event_time_microseconds{};

    String query_id;
    String query_for_logging;
    String database;
    String table;
    String format;
    UInt64 bytes{};
    UInt64 rows{};
    String exception;
    Status status{};

    time_t flush_time{};
    Decimal64 flush_time_microseconds{};
    String flush_query_id;

    static std::string name() { return "AsynchronousInsertLog"; }
    static NamesAndTypesList getNamesAndTypes();
    static NamesAndAliases getNamesAndAliases() { return {}; }
    void appendToBlock(MutableColumns & columns) const;
    static const char * getCustomColumnList() { return nullptr; }
};

class AsynchronousInsertLog : public SystemLog<AsynchronousInsertLogElement>
{
public:
    using SystemLog<AsynchronousInsertLogElement>::SystemLog;

    /// This table is usually queried for fixed table name.
    static const char * getDefaultOrderBy() { return "database, table, event_date, event_time"; }
};

}