Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update base64 0.13 to base64 0.21. Replace use of deprecated chrono method #451

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nexus/Cargo.lock

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

7 changes: 3 additions & 4 deletions nexus/peer-bigquery/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<Utc>::from_utc(
naive_datetime,
Utc,
Some(Value::Timestamp(Utc.from_utc_datetime(
&naive_datetime,
)))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion nexus/peer-snowflake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions nexus/peer-snowflake/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use anyhow::Context;
use base64::encode as base64_encode;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use jsonwebtoken::{encode as jwt_encode, Algorithm, EncodingKey, Header};
use pkcs1::EncodeRsaPrivateKey;
use pkcs8::{DecodePrivateKey, EncodePublicKey};
Expand Down Expand Up @@ -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_STANDARD.encode(Sha256::new_with_prefix(public_key.as_bytes()).finalize())
);
Ok(res)
}
Expand Down
22 changes: 9 additions & 13 deletions nexus/peer-snowflake/src/stream.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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::<Utc>::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::<Utc>::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,
)),
}
}
Expand All @@ -166,18 +164,16 @@ impl SnowflakeRecordStream {
),
SnowflakeDataType::TimestampTz => {
match DateTime::parse_from_str(elem, TIMESTAMP_TZ_PARSE_FORMAT) {
Ok(_) => TimestampWithTimeZone(DateTime::<Utc>::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::<Utc>::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,
)),
}
}
Expand Down
5 changes: 3 additions & 2 deletions nexus/value/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use array::ArrayValue;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use bytes::Bytes;
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
use rust_decimal::Decimal;
Expand Down Expand Up @@ -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_STANDARD.encode(b)),
Value::VarBinary(b) => serde_json::Value::String(BASE64_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()),
Expand Down