Skip to content

Commit

Permalink
Add AppendRaw to ColumnDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
rtcote committed Sep 27, 2023
1 parent a162509 commit 5948eb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions clickhouse/columns/date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ std::time_t ColumnDateTime::At(size_t n) const {
return data_->At(n);
}

void ColumnDateTime::AppendRaw(uint32_t value) {
data_->Append(value);
}

std::string ColumnDateTime::Timezone() const {
return type_->As<DateTimeType>()->Timezone();
}
Expand Down
3 changes: 3 additions & 0 deletions clickhouse/columns/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ class ColumnDateTime : public Column {
std::time_t At(size_t n) const;
inline std::time_t operator [] (size_t n) const { return At(n); }

/// Append raw as UNIX epoch seconds in uint32
void AppendRaw(uint32_t value);

/// Timezone associated with a data column.
std::string Timezone() const;

Expand Down
4 changes: 2 additions & 2 deletions ut/columns_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ TEST(ColumnsCase, Date32Swap) {
TEST(ColumnsCase, DateTimeSwap) {
auto col = std::make_shared<ColumnDateTime>();

col->Append(1u);
col->Append(1234u);
col->AppendRaw(1u);
col->AppendRaw(1234u);

ASSERT_EQ(col->Size(), 2u);
ASSERT_EQ(col->At(0), 1u);
Expand Down

0 comments on commit 5948eb6

Please sign in to comment.