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

Function TimestampLogicalTypeFromArrowTimestamp

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

Source from the content-addressed store, hash-verified

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