diff --git a/nexus/Cargo.lock b/nexus/Cargo.lock index 3876b4be1f..2ea6421fef 100644 --- a/nexus/Cargo.lock +++ b/nexus/Cargo.lock @@ -1989,7 +1989,7 @@ dependencies = [ "anyhow", "async-recursion", "async-trait", - "base64 0.13.1", + "base64 0.21.4", "catalog", "chrono", "dashmap", diff --git a/nexus/peer-bigquery/src/stream.rs b/nexus/peer-bigquery/src/stream.rs index 0edf35757d..e4c3aca513 100644 --- a/nexus/peer-bigquery/src/stream.rs +++ b/nexus/peer-bigquery/src/stream.rs @@ -4,7 +4,7 @@ use std::{ task::{Context, Poll}, }; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{NaiveDateTime, TimeZone, Utc}; use futures::Stream; use gcp_bigquery_client::model::{ field_type::FieldType, query_response::ResultSet, table_field_schema::TableFieldSchema, @@ -149,9 +149,8 @@ impl BqRecordStream { if let Some(ts) = timestamp { let naive_datetime = NaiveDateTime::from_timestamp_opt(ts, 0) .ok_or(anyhow::Error::msg("Invalid naive datetime"))?; - Some(Value::Timestamp(DateTime::::from_utc( - naive_datetime, - Utc, + Some(Value::Timestamp(Utc.from_utc_datetime( + &naive_datetime, ))) } else { None diff --git a/nexus/peer-snowflake/Cargo.toml b/nexus/peer-snowflake/Cargo.toml index c8e5f673be..ce61c79778 100644 --- a/nexus/peer-snowflake/Cargo.toml +++ b/nexus/peer-snowflake/Cargo.toml @@ -15,7 +15,7 @@ pgerror = { path = "../pgerror" } secrecy = { version = "0.8.0" } async-trait = "0.1.57" jsonwebtoken = { version = "8.0", features = ["use_pem"] } -base64 = "0.13" +base64 = "0.21" dashmap = "5.0" pgwire = "0.15" sha2 = "0.10" diff --git a/nexus/peer-snowflake/src/auth.rs b/nexus/peer-snowflake/src/auth.rs index e71c6f8973..1798349a81 100644 --- a/nexus/peer-snowflake/src/auth.rs +++ b/nexus/peer-snowflake/src/auth.rs @@ -4,7 +4,7 @@ use std::{ }; use anyhow::Context; -use base64::encode as base64_encode; +use base64::Engine; use jsonwebtoken::{encode as jwt_encode, Algorithm, EncodingKey, Header}; use pkcs1::EncodeRsaPrivateKey; use pkcs8::{DecodePrivateKey, EncodePublicKey}; @@ -99,7 +99,7 @@ impl SnowflakeAuth { let public_key = EncodePublicKey::to_public_key_der(&RsaPublicKey::from(private_key))?; let res = format!( "SHA256:{}", - base64_encode(Sha256::new_with_prefix(public_key.as_bytes()).finalize()) + base64::engine::general_purpose::STANDARD.encode(Sha256::new_with_prefix(public_key.as_bytes()).finalize()) ); Ok(res) } diff --git a/nexus/peer-snowflake/src/stream.rs b/nexus/peer-snowflake/src/stream.rs index 0417163957..b4290707a9 100644 --- a/nexus/peer-snowflake/src/stream.rs +++ b/nexus/peer-snowflake/src/stream.rs @@ -1,5 +1,5 @@ use crate::{auth::SnowflakeAuth, PartitionResult, ResultSet}; -use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; +use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc}; use futures::Stream; use peer_cursor::Schema; use peer_cursor::{Record, RecordStream, SchemaRef}; @@ -146,18 +146,16 @@ impl SnowflakeRecordStream { // really hacky workaround for parsing the UTC timezone specifically. SnowflakeDataType::TimestampLtz => { match DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT) { - Ok(_) => TimestampWithTimeZone(DateTime::::from_utc( - DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT)? + Ok(_) => TimestampWithTimeZone(Utc.from_utc_datetime( + &DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT)? .naive_utc(), - Utc, )), - Err(_) => TimestampWithTimeZone(DateTime::::from_utc( - DateTime::parse_from_str( + Err(_) => TimestampWithTimeZone(Utc.from_utc_datetime( + &DateTime::parse_from_str( &elem.replace("Z", "+0000"), TIMESTAMP_TZ_PARSE_FORMAT, )? .naive_utc(), - Utc, )), } } @@ -166,18 +164,16 @@ impl SnowflakeRecordStream { ), SnowflakeDataType::TimestampTz => { match DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT) { - Ok(_) => TimestampWithTimeZone(DateTime::::from_utc( - DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT)? + Ok(_) => TimestampWithTimeZone(Utc.from_utc_datetime( + &DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT)? .naive_utc(), - Utc, )), - Err(_) => TimestampWithTimeZone(DateTime::::from_utc( - DateTime::parse_from_str( + Err(_) => TimestampWithTimeZone(Utc.from_utc_datetime( + &DateTime::parse_from_str( &elem.replace("Z", "+0000"), TIMESTAMP_TZ_PARSE_FORMAT, )? .naive_utc(), - Utc, )), } } diff --git a/nexus/value/src/lib.rs b/nexus/value/src/lib.rs index 8627a50d41..2c65738c65 100644 --- a/nexus/value/src/lib.rs +++ b/nexus/value/src/lib.rs @@ -1,4 +1,5 @@ use array::ArrayValue; +use base64::Engine; use bytes::Bytes; use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; use rust_decimal::Decimal; @@ -236,8 +237,8 @@ impl Value { Value::Char(c) => serde_json::Value::String(c.to_string()), Value::VarChar(s) => serde_json::Value::String(s.clone()), Value::Text(s) => serde_json::Value::String(s.clone()), - Value::Binary(b) => serde_json::Value::String(base64::encode(b)), - Value::VarBinary(b) => serde_json::Value::String(base64::encode(b)), + Value::Binary(b) => serde_json::Value::String(base64::engine::general_purpose::STANDARD.encode(b)), + Value::VarBinary(b) => serde_json::Value::String(base64::engine::general_purpose::STANDARD.encode(b)), Value::Date(d) => serde_json::Value::String(d.to_string()), Value::Time(t) => serde_json::Value::String(t.to_string()), Value::TimeWithTimeZone(t) => serde_json::Value::String(t.to_string()),