Skip to content

Commit

Permalink
chore: upgrade dependencies (#2769)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
tychoish and dependabot[bot] committed Mar 13, 2024
1 parent 3c22200 commit 4b8395e
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 86 deletions.
57 changes: 32 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ strip = true
wildcard_imports = "deny"

[workspace.dependencies]
clap = { version = "4.5.1", features = ["derive"] }
clap = { version = "4.5.2", features = ["derive"] }
datafusion = { version = "35.0.0", features = ["avro"] }
arrow-flight = { version = "50.0.0", features = ["flight-sql-experimental"] }
datafusion-proto = { version = "35.0.0" }
Expand All @@ -30,7 +30,7 @@ tokio = { version = "1", features = ["full"] }
tonic = { version = "0.10", features = ["transport", "tls", "tls-roots"] }
anyhow = "1.0.80"
async-trait = "0.1.77"
chrono = "0.4.34"
chrono = "0.4.35"
futures = "0.3.30"
object_store = "0.9"
prost = "0.12"
Expand Down
3 changes: 2 additions & 1 deletion crates/datasources/src/cassandra/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ impl CqlValueArrayBuilder {
(Int64(builder), CqlValue::BigInt(value)) => builder.append_value(value),
(Date64(builder), CqlValue::Date(value)) => {
let days_since_unix_epoch = value.0 as i64 - (1 << 31);
let duration_since_unix_epoch = chrono::Duration::days(days_since_unix_epoch);
let duration_since_unix_epoch =
chrono::Duration::try_days(days_since_unix_epoch).unwrap();
let unix_epoch = chrono::NaiveDate::from_yo_opt(1970, 1).unwrap();
let date = unix_epoch + duration_since_unix_epoch;
let time = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); // Midnight
Expand Down
4 changes: 3 additions & 1 deletion crates/datasources/src/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ pub fn encode_literal_to_text(
ScalarValue::Date32(Some(v)) => {
let epoch = Utc.timestamp_nanos(0).naive_utc().date();
let naive = epoch
.checked_add_signed(Duration::days(*v as i64))
.checked_add_signed(Duration::try_days(*v as i64).ok_or_else(|| {
DatasourceCommonError::Unsupported("timestamp conversion error")
})?)
.expect("scalar value should be a valid date");
encode_date(buf, &naive)?;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/datasources/src/excel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn xlsx_sheet_value_to_record_batch(
let mut arr = Date64Array::builder(rows.len());
for r in rows {
if let Some(v) = r.get(i).and_then(|v| v.as_datetime()) {
let v = v.timestamp_millis();
let v = v.and_utc().timestamp_millis();
arr.append_value(v);
} else {
arr.append_null();
Expand Down
4 changes: 2 additions & 2 deletions crates/datasources/src/mysql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ fn mysql_row_to_record_batch(rows: Vec<MysqlRow>, schema: ArrowSchemaRef) -> Res
for row in rows.iter() {
let val: Option<NaiveDateTime> =
row.get_opt(col_idx).expect("row value should exist")?;
let val = val.map(|v| v.timestamp_nanos_opt().unwrap());
let val = val.and_then(|v| v.and_utc().timestamp_nanos_opt());
arr.append_option(val);
}
Arc::new(arr.finish())
Expand All @@ -727,7 +727,7 @@ fn mysql_row_to_record_batch(rows: Vec<MysqlRow>, schema: ArrowSchemaRef) -> Res
for row in rows.iter() {
let val: Option<NaiveDateTime> =
row.get_opt(col_idx).expect("row value should exist")?;
let val = val.map(|v| v.timestamp_nanos_opt().unwrap());
let val = val.and_then(|v| v.and_utc().timestamp_nanos_opt());
arr.append_option(val);
}
Arc::new(arr.finish())
Expand Down
2 changes: 1 addition & 1 deletion crates/datasources/src/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ fn binary_rows_to_record_batch<E: Into<PostgresError>>(
let mut arr = TimestampMicrosecondBuilder::with_capacity(rows.len());
for row in rows.iter() {
let val: Option<NaiveDateTime> = row.try_get(col_idx)?;
let val = val.map(|v| v.timestamp_micros());
let val = val.map(|v| v.and_utc().timestamp_micros());
arr.append_option(val);
}
Arc::new(arr.finish())
Expand Down
26 changes: 12 additions & 14 deletions crates/datasources/src/sqlite/convert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_sqlite::rusqlite::types::{Value, ValueRef};
use async_sqlite::rusqlite::Rows;
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime};
use datafusion::arrow::array::{
ArrayBuilder,
BinaryBuilder,
Expand Down Expand Up @@ -419,24 +419,22 @@ impl Converter {
match val_ref {
ValueRef::Null => builder.append_null(),
ValueRef::Integer(i) => {
let timestamp =
NaiveDateTime::from_timestamp_opt(i, /* nsecs = */ 0)
.ok_or_else(|| SqliteError::InvalidConversion {
from: Value::Integer(i),
to: DataType::Timestamp(TimeUnit::Microsecond, None),
})?;
let timestamp = DateTime::from_timestamp(i, /* nsecs = */ 0)
.ok_or_else(|| SqliteError::InvalidConversion {
from: Value::Integer(i),
to: DataType::Timestamp(TimeUnit::Microsecond, None),
})?;
let micros = timestamp.timestamp_micros();
builder.append_value(micros);
}
ValueRef::Real(r) => {
let seconds = r as i64;
let sub_nanos = (r.fract() * 1_000_000_000_f64) as u32;
let timestamp =
NaiveDateTime::from_timestamp_opt(seconds, sub_nanos)
.ok_or_else(|| SqliteError::InvalidConversion {
from: Value::Real(r),
to: DataType::Timestamp(TimeUnit::Microsecond, None),
})?;
let timestamp = DateTime::from_timestamp(seconds, sub_nanos)
.ok_or_else(|| SqliteError::InvalidConversion {
from: Value::Real(r),
to: DataType::Timestamp(TimeUnit::Microsecond, None),
})?;
let micros = timestamp.timestamp_micros();
builder.append_value(micros);
}
Expand All @@ -454,7 +452,7 @@ impl Converter {
from: Value::Text(t.to_string()),
to: DataType::Timestamp(TimeUnit::Microsecond, None),
})?;
let micros = timestamp.timestamp_micros();
let micros = timestamp.and_utc().timestamp_micros();
builder.append_value(micros);
}
v => {
Expand Down
4 changes: 2 additions & 2 deletions crates/datasources/src/sqlserver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ fn rows_to_record_batch(
let mut arr = TimestampNanosecondBuilder::with_capacity(rows.len());
for row in rows.iter() {
let val: Option<NaiveDateTime> = row.try_get(col_idx)?;
let val = val.map(|v| v.timestamp_nanos_opt().unwrap());
let val = val.and_then(|v| v.and_utc().timestamp_nanos_opt());
arr.append_option(val);
}
Arc::new(arr.finish())
Expand All @@ -753,7 +753,7 @@ fn rows_to_record_batch(
.with_data_type(dt.clone());
for row in rows.iter() {
let val: Option<DateTime<Utc>> = row.try_get(col_idx)?;
let val = val.map(|v| v.timestamp_nanos_opt().unwrap());
let val = val.and_then(|v| v.timestamp_nanos_opt());
arr.append_option(val);
}
Arc::new(arr.finish())
Expand Down
2 changes: 1 addition & 1 deletion crates/glaredb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ terminal_util = { path = "../terminal_util" }

num_cpus = "1.16.0"
colored = "2.1.0"
reedline = "0.29.0"
reedline = "0.30.0"
nu-ansi-term = "0.50.0"
atty = "0.2.14"
console-subscriber = "0.2.0"
Expand Down
Loading

0 comments on commit 4b8395e

Please sign in to comment.