miguelcorderopamphile commented on code in PR #11572:
URL: https://github.com/apache/arrow-rs/pull/11572#discussion_r4506801863
##########
arrow-cast/src/parse.rs:
##########
@@ -1314,23 +1314,36 @@ const NANOS_PER_MILLIS: i64 = 1_000_000;
const NANOS_PER_SECOND: i64 = 1_000 * NANOS_PER_MILLIS;
const NANOS_PER_MINUTE: i64 = 60 * NANOS_PER_SECOND;
const NANOS_PER_HOUR: i64 = 60 * NANOS_PER_MINUTE;
-#[cfg(test)]
-const NANOS_PER_DAY: i64 = 24 * NANOS_PER_HOUR;
+pub(crate) const NANOS_PER_DAY: i64 = 24 * NANOS_PER_HOUR;
/// Config to parse interval strings
///
-/// Currently stores the `default_unit` to use if the string doesn't have one
specified
+/// Stores the `default_unit` to use if the string doesn't have one specified,
+/// and whether fractional calendar units may be spilled into smaller units.
#[derive(Debug, Clone)]
pub struct IntervalParseConfig {
/// The default unit to use if none is specified
/// e.g. `INTERVAL 1` represents `INTERVAL 1 SECOND` when default_unit =
[IntervalUnit::Second]
default_unit: IntervalUnit,
+ /// Whether fractional calendar units (centuries, decades, years, months)
+ /// may be spilled into smaller units. `0.5 months` is parsed as 15 days
+ /// when this is `true`.
+ allow_fractional_calendar_units: bool,
}
impl IntervalParseConfig {
/// Create a new [IntervalParseConfig] with the given default unit
pub fn new(default_unit: IntervalUnit) -> Self {
- Self { default_unit }
+ Self {
+ default_unit,
+ allow_fractional_calendar_units: true,
+ }
+ }
+
+ /// Reject fractional calendar units instead of spilling them into smaller
units
+ pub fn reject_fractional_calendar_units(mut self) -> Self {
Review Comment:
Done in 1acdefb09 — `reject_fractional_calendar_units` is now `pub(crate)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]