Skip to main content

Module parse

Module parse 

Source
Expand description

Parser implementations for converting strings to Arrow types

Used by the CSV and JSON readers to convert strings to Arrow types

MacrosΒ§

parser_primitive πŸ”’

StructsΒ§

DecimalAccumulator πŸ”’
Accumulates decimal digits into chunk, folding it into value whenever it reaches MAX_CHUNK_DIGITS digits
Interval πŸ”’
IntervalAmount πŸ”’
IntervalParseConfig
Config to parse interval strings
TimestampParser πŸ”’
Helper for parsing RFC3339 timestamps

EnumsΒ§

DecimalParseError πŸ”’
The reason a decimal string could not be parsed.
IntervalUnit
Represents the units of an interval, with each variant corresponding to a bit in the interval’s bitfield representation
MantissaError πŸ”’
Why scanning the digits of a decimal string stopped.

ConstantsΒ§

EPOCH_DAYS_FROM_CE πŸ”’
Number of days between 0001-01-01 and 1970-01-01
ERR_NANOSECONDS_NOT_SUPPORTED πŸ”’
Error message if nanosecond conversion request beyond supported interval
INTERVAL_PRECISION πŸ”’
Chosen based on the number of decimal digits in 1 week in nanoseconds
MAX_CHUNK_DIGITS πŸ”’
The maximum number of decimal digits accumulated in a u64 before the chunk is folded into the native value: every 18-digit number fits in a u64, and splits into two halves that each fit in a u32 (see decimal_chunk_to_native).
NANOS_PER_HOUR πŸ”’
NANOS_PER_MILLIS πŸ”’
NANOS_PER_MINUTE πŸ”’
NANOS_PER_SECOND πŸ”’

TraitsΒ§

Parser
Specialized parsing implementations to convert strings to Arrow types.

FunctionsΒ§

decimal_chunk_to_native πŸ”’
Converts a chunk of at most MAX_CHUNK_DIGITS digits to the native type, negated if negative.
decimal_pow πŸ”’
Returns 10^exp as a T::Native, or an overflow error if the result does not fit in the native type.
fold_decimal_chunk πŸ”’
Folds a chunk of up to MAX_CHUNK_DIGITS digits into value, producing value * 10^chunk_len + chunk (chunk is negated first when parsing a negative number).
not_interval_amount πŸ”’
test if a character is NOT part of an interval numeric amount
parse_date πŸ”’
parse_date_to_days πŸ”’
Parse a date string into days since 1970-01-01, covering the full Date32 range (years β‰ˆ Β±5,881,580) for the signed extended-year form.
parse_decimal
Parses the string representation of a decimal number into the unscaled native value of a decimal type with the given precision and scale.
parse_decimal_checked πŸ”’
Like parse_decimal, but reports failures as a DecimalParseError instead of formatting an error message, for callers that discard or re-wrap the error.
parse_decimal_exponent πŸ”’
Parses the digits of an exponent ([+|-] digits), saturating at the bounds of i64; any exponent that large scales every non-zero mantissa out of range of every decimal type.
parse_decimal_mantissa πŸ”’
Scans mantissa (digits with at most one decimal point; the sign has already been removed) and folds the digits that are significant at scale into a native value, rounding half away from zero on the first digit that is not.
parse_decimal_native πŸ”’
Parses s as a decimal with the given scale into the native type of T, checking only that the result fits the native type (not the precision).
parse_extended_ymd πŸ”’
Parse the ISO 8601 signed extended-year form (Β±YYYY[Y...]-MM-DD) into raw (year, month, day) components, without validating the calendar date.
parse_interval_components πŸ”’
parse the string into a vector of interval components i.e. (amount, unit) tuples
parse_interval_day_time
Parse human-readable interval string to Arrow [IntervalDayTimeType]
parse_interval_month_day_nano
Parse human-readable interval string to Arrow [IntervalMonthDayNanoType]
parse_interval_month_day_nano_config
Parse human-readable interval string to Arrow [IntervalMonthDayNanoType]
parse_interval_year_month
Parse human-readable interval string to Arrow [IntervalYearMonthType]
parse_nanos πŸ”’
Parse nanoseconds from the first N values in digits, subtracting the offset O
split_interval_components πŸ”’
Split an interval into a vec of amounts and units.
split_sign πŸ”’
Splits an optional leading sign from bytes, returning whether it is - and the bytes that follow it.
string_to_datetime
Accepts a string and parses it relative to the provided timezone
string_to_time πŸ”’
string_to_time_nanoseconds
Accepts a string in ISO8601 standard format and some variants and converts it to nanoseconds since midnight.
string_to_timestamp_nanos
Accepts a string in RFC3339 / ISO8601 standard format and some variants and converts it to a nanosecond precision timestamp.
to_timestamp_nanos πŸ”’
Fallible conversion of NaiveDateTime to i64 nanoseconds
trim_pre_and_post_whitespace πŸ”’
this is a no-op if the string starts and ends with a digit, otherwise it will trim whitespace from the start and end of the string.

Type AliasesΒ§

MonthDayNano
A tuple representing (months, days, nanoseconds) in an interval