Skip to content

Commit

Permalink
fix: convert to datetime and also change naming
Browse files Browse the repository at this point in the history
  • Loading branch information
joel authored and joel committed Jan 25, 2024
1 parent 35848d8 commit d5acf7b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/cognito.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ By default, Postgres stores FDW credentials inide `pg_catalog.pg_foreign_server`
```sql
insert into vault.secrets (name, secret)
values (
'vault_secret_access_key',
'cognito_secret_access_key',
'<secret access key>'
)
returning key_id;
Expand Down
1 change: 1 addition & 0 deletions wrappers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ cognito_fdw = [
"serde",
"url",
"thiserror",
"chrono",
]
logflare_fdw = [
"http",
Expand Down
9 changes: 7 additions & 2 deletions wrappers/src/fdw/cognito_fdw/cognito_client/row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use aws_sdk_cognitoidentityprovider::types::UserType;
use chrono::DateTime;
use serde::Deserialize;
use serde_json::Value;
use std::collections::HashMap;
Expand Down Expand Up @@ -43,10 +44,14 @@ impl IntoRow for UserType {
}
"created_at" => {
if let Some(created_at) = self.extract_attribute_value("created_at") {
row.push("created_at", Some(Cell::String(created_at)));
let parsed_date = DateTime::parse_from_rfc3339(&created_at)
.expect("Failed to parse date");
row.push(
"created_at",
Some(Cell::Timestamp(parsed_date.timestamp().into())),
);
}
}
// TODO: update columns
"email" => {
if let Some(email) = self.extract_attribute_value("email") {
row.push("email", Some(Cell::String(email)));
Expand Down
2 changes: 1 addition & 1 deletion wrappers/src/fdw/cognito_fdw/cognito_fdw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl ForeignDataWrapper<CognitoFdwError> for CognitoFdw {

let mut builder = config.to_builder();
if let Some(endpoint_url) = options.get("endpoint_url") {
if endpoint_url != "" {
if !endpoint_url.is_empty() {
builder.set_endpoint_url(Some(endpoint_url.clone()));
}
}
Expand Down

0 comments on commit d5acf7b

Please sign in to comment.