Skip to content

Commit f19de18

Browse files
committed
chore(cubesql): Bump chrono and fix deprecation warnings
1 parent 84f90c0 commit f19de18

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

packages/cubejs-backend-native/Cargo.lock

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

rust/cubenativeutils/Cargo.lock

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

rust/cubesql/Cargo.lock

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

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async-trait = "0.1.36"
3939
regex = "1.5"
4040
uuid = { version = "1", features = ["serde", "v4"] }
4141
bincode = "1.3.1"
42-
chrono = "0.4.31"
42+
chrono = "0.4.39"
4343
chrono-tz = "0.6"
4444
tokio-util = { version = "0.7", features = ["compat"] }
4545
comfy-table = "7.1.0"

rust/cubesql/cubesql/src/compile/engine/df/scan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ pub fn transform_response<V: ValueObject>(
11291129
// TODO switch parsing to microseconds
11301130
if timestamp.and_utc().timestamp_millis() > (((1i64) << 62) / 1_000_000) {
11311131
builder.append_null()?;
1132-
} else if let Some(nanos) = timestamp.timestamp_nanos_opt() {
1132+
} else if let Some(nanos) = timestamp.and_utc().timestamp_nanos_opt() {
11331133
builder.append_value(nanos)?;
11341134
} else {
11351135
log::error!(

rust/cubesql/cubesql/src/compile/engine/udf/common.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,8 @@ pub fn create_to_char_udf() -> ScalarUDF {
16691669

16701670
let secs = duration.num_seconds();
16711671
let nanosecs = duration.num_nanoseconds().unwrap_or(0) - secs * 1_000_000_000;
1672-
let timestamp = NaiveDateTime::from_timestamp_opt(secs, nanosecs as u32)
1672+
let timestamp = ::chrono::DateTime::from_timestamp(secs, nanosecs as u32)
1673+
.map(|dt| dt.naive_utc())
16731674
.unwrap_or_else(|| panic!("Invalid secs {} nanosecs {}", secs, nanosecs));
16741675

16751676
// chrono's strftime is missing quarter format, as such a workaround is required
@@ -2316,24 +2317,26 @@ macro_rules! generate_series_udtf {
23162317

23172318
macro_rules! generate_series_helper_date32 {
23182319
($CURRENT:ident, $STEP:ident, $PRIMITIVE_TYPE: ident) => {
2319-
let current_dt = NaiveDateTime::from_timestamp_opt(($CURRENT as i64) * 86400, 0)
2320+
let current_dt = ::chrono::DateTime::from_timestamp(($CURRENT as i64) * 86400, 0)
2321+
.map(|dt| dt.naive_utc())
23202322
.ok_or_else(|| {
23212323
DataFusionError::Execution(format!(
23222324
"Cannot convert date to NaiveDateTime: {}",
23232325
$CURRENT
23242326
))
23252327
})?;
23262328
let res = date_addsub_month_day_nano(current_dt, $STEP, true)?;
2327-
$CURRENT = (res.timestamp() / 86400) as $PRIMITIVE_TYPE;
2329+
$CURRENT = (res.and_utc().timestamp() / 86400) as $PRIMITIVE_TYPE;
23282330
};
23292331
}
23302332

23312333
macro_rules! generate_series_helper_timestamp {
23322334
($CURRENT:ident, $STEP:ident, $PRIMITIVE_TYPE: ident) => {
2333-
let current_dt = NaiveDateTime::from_timestamp_opt(
2335+
let current_dt = ::chrono::DateTime::from_timestamp(
23342336
($CURRENT as i64) / 1_000_000_000,
23352337
($CURRENT % 1_000_000_000) as u32,
23362338
)
2339+
.map(|dt| dt.naive_utc())
23372340
.ok_or_else(|| {
23382341
DataFusionError::Execution(format!(
23392342
"Cannot convert timestamp to NaiveDateTime: {}",

rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use chrono::{
3434
Numeric::{Day, Hour, Minute, Month, Second, Year},
3535
Pad::Zero,
3636
},
37-
Datelike, Days, Duration, Months, NaiveDate, NaiveDateTime, Timelike, Weekday,
37+
DateTime, Datelike, Days, Duration, Months, NaiveDate, NaiveDateTime, Timelike, Weekday,
3838
};
3939
use cubeclient::models::V1CubeMeta;
4040
use datafusion::{
@@ -4836,7 +4836,7 @@ impl FilterRules {
48364836
};
48374837
let ts_seconds = *ts / 1_000_000_000;
48384838
let ts_nanos = (*ts % 1_000_000_000) as u32;
4839-
let dt = NaiveDateTime::from_timestamp_opt(ts_seconds, ts_nanos).map(|dt| Some(dt));
4839+
let dt = DateTime::from_timestamp(ts_seconds, ts_nanos).map(|dt| Some(dt.naive_utc()));
48404840
return dt;
48414841
};
48424842

rust/cubesql/cubesql/src/compile/rewrite/rules/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
sync::Arc,
55
};
66

7-
use chrono::{Datelike, NaiveDateTime, Timelike};
7+
use chrono::{DateTime, Datelike, Timelike, Utc};
88
use datafusion::{
99
arrow::datatypes::{ArrowPrimitiveType, IntervalDayTimeType, IntervalMonthDayNanoType},
1010
error::DataFusionError,
@@ -457,9 +457,9 @@ pub fn is_literal_date_trunced(ns: i64, granularity: &str) -> Option<bool> {
457457
return Some(false);
458458
}
459459
let seconds = ns / ns_in_seconds;
460-
let dt = NaiveDateTime::from_timestamp_opt(seconds, 0)?;
460+
let dt = DateTime::from_timestamp(seconds, 0)?;
461461

462-
let is_minute_trunced = |dt: NaiveDateTime| dt.second() == 0;
462+
let is_minute_trunced = |dt: DateTime<Utc>| dt.second() == 0;
463463
let is_hour_trunced = |dt| is_minute_trunced(dt) && dt.minute() == 0;
464464
let is_day_trunced = |dt| is_hour_trunced(dt) && dt.hour() == 0;
465465
let is_week_trunced = |dt| is_day_trunced(dt) && dt.weekday().num_days_from_monday() == 0;

rust/cubesqlplanner/Cargo.lock

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

0 commit comments

Comments
 (0)