Skip to content

Commit 0d5dcfc

Browse files
committed
Extract out date time parsing to a DateTimeParser trait with chrono & jiff implementations. Overall jiff seems slightly faster in the case where parsing has no errors but slower when using multiple formats (higher cost for Error handling).
1 parent d103d88 commit 0d5dcfc

File tree

16 files changed

+1430
-485
lines changed

16 files changed

+1430
-485
lines changed

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-examples/examples/builtin_functions/date_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ async fn query_to_timestamp() -> Result<()> {
417417
.collect()
418418
.await;
419419

420-
let expected = "Execution error: Error parsing timestamp from '01-14-2023 01/01/30' using format '%d-%m-%Y %H:%M:%S': input is out of range";
420+
let expected = "Error parsing timestamp from '01-14-2023 01/01/30' using formats: [\"%d-%m-%Y %H:%M:%S\"]: input is out of range";
421421
assert_contains!(result.unwrap_err().to_string(), expected);
422422

423423
// note that using arrays for the chrono formats is not supported

datafusion/common/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,17 @@ config_namespace! {
505505
/// Defaults to the number of CPU cores on the system
506506
pub target_partitions: usize, transform = ExecutionOptions::normalized_parallelism, default = get_available_parallelism()
507507

508+
/// The date time parser to use when parsing date time values.
509+
///
510+
/// Defaults to 'chrono'. 'jiff' is supported when the 'jiff' feature is enabled.
511+
pub date_time_parser: Option<String>, default = Some("chrono".to_string())
512+
508513
/// The default time zone
509514
///
510515
/// Some functions, e.g. `now` return timestamps in this time zone
511516
pub time_zone: Option<String>, default = None
512517

518+
513519
/// Parquet options
514520
pub parquet: ParquetOptions, default = Default::default()
515521

datafusion/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ unicode_expressions = [
109109
"datafusion-functions/unicode_expressions",
110110
]
111111
extended_tests = []
112+
jiff = ["datafusion-functions/jiff"]
112113

113114
[dependencies]
114115
arrow = { workspace = true }

datafusion/functions/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ default = [
5252
]
5353
# enable encode/decode functions
5454
encoding_expressions = ["base64", "hex"]
55+
# enable jiff timestamp parsing
56+
jiff = ["dep:jiff"]
5557
# enable math functions
5658
math_expressions = []
5759
# enable regular expressions
@@ -78,8 +80,11 @@ datafusion-execution = { workspace = true }
7880
datafusion-expr = { workspace = true }
7981
datafusion-expr-common = { workspace = true }
8082
datafusion-macros = { workspace = true }
83+
dyn-eq = "0.1.3"
84+
dyn-hash = "1.0.0"
8185
hex = { workspace = true, optional = true }
8286
itertools = { workspace = true }
87+
jiff = { version = "0.2.16", optional = true }
8388
log = { workspace = true }
8489
md-5 = { version = "^0.10.0", optional = true }
8590
num-traits = { workspace = true }
@@ -115,7 +120,7 @@ required-features = ["string_expressions"]
115120
[[bench]]
116121
harness = false
117122
name = "to_timestamp"
118-
required-features = ["datetime_expressions"]
123+
required-features = ["datetime_expressions", "jiff"]
119124

120125
[[bench]]
121126
harness = false

0 commit comments

Comments
 (0)