Skip to content

Commit

Permalink
fix sets type column result
Browse files Browse the repository at this point in the history
  • Loading branch information
py committed Dec 3, 2024
1 parent 7c54d65 commit 3f6989e
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 290 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ tracing = "0.1"
url = "2"
uuid = "1"
aws-config = { version = "1.1.7", features = ["behavior-version-latest"] }
aws-sdk-dynamodb = "1.50.0"
aws-sdk-dynamodb = "1.50.0"
base64 = "0.22.1"
1 change: 1 addition & 0 deletions crates/query-engine/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ tracing = { workspace = true }
bytes = { workspace = true }
aws-config = { workspace = true }
aws-sdk-dynamodb = { workspace = true }
base64 = { workspace = true }
47 changes: 47 additions & 0 deletions crates/query-engine/execution/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{collections::HashMap, vec};
use crate::error::Error;
use crate::metrics;
use aws_sdk_dynamodb::Client;
use base64;
use bytes::{BufMut, Bytes, BytesMut};
use serde_json::{self, to_string, Value};

Expand Down Expand Up @@ -55,6 +56,52 @@ pub async fn execute(
let bool = attribute_value.as_bool().unwrap();
let bool_str = bool.to_string();
hashmap.insert(key, bool_str);
} else if attribute_value.is_null() {
hashmap.insert(key, "null".to_string());
} else if attribute_value.is_b() {
let b = attribute_value.as_b().unwrap();
let b_str = base64::Engine::encode(
&base64::engine::general_purpose::STANDARD,
b.as_ref(),
);
hashmap.insert(key, b_str);
} else if attribute_value.is_ss() {
let ss = attribute_value.as_ss().unwrap();
let ss_str = ss.join(", ");
hashmap.insert(key, ss_str);
} else if attribute_value.is_ns() {
let ns = attribute_value.as_ns().unwrap();
let ns_str = ns.join(", ");
hashmap.insert(key, ns_str);
} else if attribute_value.is_bs() {
let bs = attribute_value.as_bs().unwrap();
let bs_str = bs
.iter()
.map(|b| {
base64::Engine::encode(
&base64::engine::general_purpose::STANDARD,
b.as_ref(),
)
})
.collect::<Vec<String>>()
.join(", ");
hashmap.insert(key, bs_str);
} else if attribute_value.is_m() {
let m = attribute_value.as_m().unwrap();
let mut m_str = "{".to_string();
for (k, v) in m {
m_str.push_str(&format!("{k}: {v:?}, "));
}
m_str.push('}');
hashmap.insert(key, m_str);
} else if attribute_value.is_l() {
let l = attribute_value.as_l().unwrap();
let mut l_str = "[".to_string();
for v in l {
l_str.push_str(&format!("{v:?}, "));
}
l_str.push(']');
hashmap.insert(key, l_str);
} else {
println!("Unknown");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ pub fn translate_expression(
let (filter_expression, joins) =
translate_expression_with_joins(env, state, root_and_current_tables, predicate)?;

let mut joins = vec![joins];
let filter = match joins.pop() {
let mut joins = VecDeque::from(joins);
let filter = match joins.pop_front() {
// When there are no joins, the expression will suffice.
None => filter_expression,
// When there are joins, wrap in an EXISTS query.
Some(first) => where_exists_select(
{
let (select, alias) = first[0].clone().get_select_and_alias();
let (select, alias) = first.get_select_and_alias();
sql::ast::From::Select { alias, select }
},
sql::ast::Where(filter_expression),
Expand Down
193 changes: 187 additions & 6 deletions static/configuration.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"version": 1,
"connectionSettings": {
"connectionPlaceholder": {
"variable": "HASURA_DYNAMODB_CONNECTION_URI_PLACEHOLDER"
"accessKeyId": {
"variable": "HASURA_DYNAMODB_AWS_ACCESS_KEY_ID"
},
"secretAccessKey": {
"variable": "HASURA_DYNAMODB_AWS_SECRET_ACCESS_KEY"
},
"region": {
"variable": "HASURA_DYNAMODB_AWS_REGION"
}
},
"metadata": {
Expand Down Expand Up @@ -34,6 +40,14 @@
"nullable": "nullable",
"description": null
},
"attachments": {
"name": "attachments",
"type": {
"scalarType": "Any"
},
"nullable": "nullable",
"description": null
},
"comm_date": {
"name": "comm_date",
"type": {
Expand All @@ -42,6 +56,30 @@
"nullable": "nullable",
"description": null
},
"comm_id": {
"name": "comm_id",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"comm_text": {
"name": "comm_text",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"complaint_description": {
"name": "complaint_description",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"complaint_id": {
"name": "complaint_id",
"type": {
Expand All @@ -50,6 +88,30 @@
"nullable": "nullable",
"description": null
},
"complaint_state": {
"name": "complaint_state",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"creation_time": {
"name": "creation_time",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"current_state": {
"name": "current_state",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"customer_id": {
"name": "customer_id",
"type": {
Expand All @@ -73,6 +135,14 @@
},
"nullable": "nullable",
"description": null
},
"severity": {
"name": "severity",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
}
},
"partitionKey": "PK",
Expand Down Expand Up @@ -108,6 +178,30 @@
"SkiLifts": {
"tableName": "SkiLifts",
"columns": {
"AvalancheDanger": {
"name": "AvalancheDanger",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"AverageSnowCoverageInches": {
"name": "AverageSnowCoverageInches",
"type": {
"scalarType": "Number"
},
"nullable": "nullable",
"description": null
},
"ExperiencedRidersOnly": {
"name": "ExperiencedRidersOnly",
"type": {
"scalarType": "Boolean"
},
"nullable": "nullable",
"description": null
},
"Lift": {
"name": "Lift",
"type": {
Expand All @@ -116,6 +210,22 @@
"nullable": "nullable",
"description": null
},
"LiftStatus": {
"name": "LiftStatus",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"LiftTime": {
"name": "LiftTime",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"Metadata": {
"name": "Metadata",
"type": {
Expand All @@ -124,13 +234,29 @@
"nullable": "nullable",
"description": null
},
"OpenLifts": {
"name": "OpenLifts",
"type": {
"scalarType": "Any"
},
"nullable": "nullable",
"description": null
},
"TotalUniqueLiftRiders": {
"name": "TotalUniqueLiftRiders",
"type": {
"scalarType": "Number"
},
"nullable": "nullable",
"description": null
},
"VerticalFeet": {
"name": "VerticalFeet",
"type": {
"scalarType": "Number"
},
"nullable": "nullable",
"description": null
}
},
"partitionKey": "Lift",
Expand Down Expand Up @@ -184,6 +310,14 @@
"nullable": "nullable",
"description": null
},
"lastname": {
"name": "lastname",
"type": {
"scalarType": "String"
},
"nullable": "nullable",
"description": null
},
"name": {
"name": "name",
"type": {
Expand Down Expand Up @@ -261,10 +395,58 @@
}
},
"scalarTypes": {
"Boolean": {
"typeName": "Boolean",
"description": null,
"comparisonOperators": {
"_eq": {
"operatorName": "=",
"operatorKind": "equal",
"argumentType": "Boolean",
"isInfix": true
},
"_gt": {
"operatorName": ">",
"operatorKind": "custom",
"argumentType": "Boolean",
"isInfix": true
},
"_gte": {
"operatorName": ">=",
"operatorKind": "custom",
"argumentType": "Boolean",
"isInfix": true
},
"_in": {
"operatorName": "IN",
"operatorKind": "in",
"argumentType": "Boolean",
"isInfix": true
},
"_lt": {
"operatorName": "<",
"operatorKind": "custom",
"argumentType": "Boolean",
"isInfix": true
},
"_lte": {
"operatorName": "<=",
"operatorKind": "custom",
"argumentType": "Boolean",
"isInfix": true
},
"_neq": {
"operatorName": "!=",
"operatorKind": "custom",
"argumentType": "Boolean",
"isInfix": true
}
},
"typeRepresentation": "boolean"
},
"Number": {
"typeName": "Number",
"description": null,
"aggregateFunctions": {},
"comparisonOperators": {
"_eq": {
"operatorName": "=",
Expand Down Expand Up @@ -309,12 +491,11 @@
"isInfix": true
}
},
"typeRepresentation": null
"typeRepresentation": "int64"
},
"String": {
"typeName": "String",
"description": null,
"aggregateFunctions": {},
"comparisonOperators": {
"_eq": {
"operatorName": "=",
Expand Down Expand Up @@ -359,7 +540,7 @@
"isInfix": true
}
},
"typeRepresentation": null
"typeRepresentation": "string"
}
}
}
Expand Down
Loading

0 comments on commit 3f6989e

Please sign in to comment.