Skip to content

Commit

Permalink
Support for timestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <[email protected]>
  • Loading branch information
jjerphan committed Apr 9, 2024
1 parent 8d69576 commit 7115b76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 9 additions & 1 deletion include/sparrow/data_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "fixed_size_layout.hpp"
#include "variable_size_binary_layout.hpp"

using time_point = std::chrono::zoned_time<std::chrono::system_clock>;

namespace sparrow
{

Expand Down Expand Up @@ -125,6 +127,12 @@ namespace sparrow
using default_layout = variable_size_binary_layout<value_type, std::span<byte_t>, std::span<byte_t>>; // FIXME: this is incorrect, change when we have the right types
};

template <>
struct arrow_traits<time_point> : common_native_types_traits<time_point>
{
static constexpr data_type type_id = data_type::TIMESTAMP;
};

namespace predicate
{

Expand All @@ -147,4 +155,4 @@ namespace sparrow
} constexpr has_arrow_traits;
}

}
}
11 changes: 7 additions & 4 deletions include/sparrow/data_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <optional>
#include <string>
#include <vector>
#include <chrono>

#include "sparrow/mp_utils.hpp"

Expand Down Expand Up @@ -82,14 +83,15 @@ namespace sparrow
BINARY,
// Fixed-size binary. Each value occupies the same number of bytes
FIXED_SIZE_BINARY,
// Number of nanoseconds since the UNIX epoch with an optional timezone.
// See: https://arrow.apache.org/docs/python/timestamps.html#timestamps
TIMESTAMP,
};

/// C++ types value representation types matching Arrow types.
// NOTE: this needs to be in sync-order with `data_type`
using all_base_types_t = mpl::typelist<
std::nullopt_t // REVIEW: not sure about if we need to have this one? for representing NA? is this
// the right type?
,
std::nullopt_t,
bool,
std::uint8_t,
std::int8_t,
Expand All @@ -103,7 +105,8 @@ namespace sparrow
float32_t,
float64_t,
std::string,
std::vector<byte_t>
std::vector<byte_t>,
std::chrono::time_point<std::chrono::system_clock>
// TODO: add missing fundamental types here
>;

Expand Down

0 comments on commit 7115b76

Please sign in to comment.