userver: userver/storages/clickhouse/io/columns/datetime64_column.hpp Source File
Loading...
Searching...
No Matches
datetime64_column.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/clickhouse/io/columns/datetime64_column.hpp
4/// @brief DateTime64 columns support
5/// @ingroup userver_clickhouse_types
6
7#include <chrono>
8
9#include <userver/storages/clickhouse/io/columns/column_includes.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace storages::clickhouse::io::columns {
14
15/// @brief Helper class for instantiating DateTime64 columns
16///
17/// see
18/// - storages::clickhouse::io::columns::DateTime64ColumnMilli
19/// - storages::clickhouse::io::columns::DateTime64ColumnMicro
20/// - storages::clickhouse::io::columns::DateTime64ColumnNano
21template <size_t Precision, typename T>
22class DateTime64Column;
23
24template <size_t Precision, typename Rep, typename Period,
25 template <typename, typename> typename Duration>
26class DateTime64Column<Precision, Duration<Rep, Period>>
27 : public ClickhouseColumn<
28 DateTime64Column<Precision, Duration<Rep, Period>>> {
29 public:
30 using cpp_type = std::chrono::system_clock::time_point;
31 using container_type = std::vector<cpp_type>;
32
33 struct Tag final {
34 static constexpr size_t kPrecision = Precision;
35 using time_resolution = Duration<Rep, Period>;
36 };
37 using time_resolution = typename Tag::time_resolution;
38
39 DateTime64Column(ColumnRef column);
40
41 static ColumnRef Serialize(const container_type& from);
42};
43
44/// @brief Represents ClickHouse DateTime64(3) column
45using DateTime64ColumnMilli = DateTime64Column<3, std::chrono::milliseconds>;
46
47/// @brief Represents ClickHouse DateTime64(6) column
48using DateTime64ColumnMicro = DateTime64Column<6, std::chrono::microseconds>;
49
50/// @brief Represents ClickHouse DateTime64(9) column
51using DateTime64ColumnNano = DateTime64Column<9, std::chrono::nanoseconds>;
52
53} // namespace storages::clickhouse::io::columns
54
55USERVER_NAMESPACE_END