MCPcopy Create free account
hub / github.com/apache/arrow / TimestampLogicalTypeFromArrowTimestamp

Function TimestampLogicalTypeFromArrowTimestamp

cpp/src/parquet/arrow/schema.cc:178–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178static std::shared_ptr<const LogicalType> TimestampLogicalTypeFromArrowTimestamp(
179 const ::arrow::TimestampType& timestamp_type, ::arrow::TimeUnit::type time_unit) {
180 const bool utc = !(timestamp_type.timezone().empty());
181 // ARROW-5878(wesm): for forward compatibility reasons, and because
182 // there's no other way to signal to old readers that values are
183 // timestamps, we force the ConvertedType field to be set to the
184 // corresponding TIMESTAMP_* value. This does cause some ambiguity
185 // as Parquet readers have not been consistent about the
186 // interpretation of TIMESTAMP_* values as being UTC-normalized.
187 switch (time_unit) {
188 case ::arrow::TimeUnit::MILLI:
189 return LogicalType::Timestamp(utc, LogicalType::TimeUnit::MILLIS,
190 /*is_from_converted_type=*/false,
191 /*force_set_converted_type=*/true);
192 case ::arrow::TimeUnit::MICRO:
193 return LogicalType::Timestamp(utc, LogicalType::TimeUnit::MICROS,
194 /*is_from_converted_type=*/false,
195 /*force_set_converted_type=*/true);
196 case ::arrow::TimeUnit::NANO:
197 return LogicalType::Timestamp(utc, LogicalType::TimeUnit::NANOS,
198 /*is_from_converted_type=*/false,
199 /*force_set_converted_type=*/false);
200 case ::arrow::TimeUnit::SECOND:
201 // No equivalent parquet logical type.
202 break;
203 }
204 return LogicalType::None();
205}
206
207static Status GetTimestampMetadata(const ::arrow::TimestampType& type,
208 const WriterProperties& properties,

Callers 1

GetTimestampMetadataFunction · 0.85

Calls 3

timezoneMethod · 0.80
TimestampClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected