Skip to content

Commit 8331b64

Browse files
authored
Basic lambda implementation (#15)
* Basic lambda implementation Currently have auth disabled due to inability to store token in between requests. * Fix fmt * Terminal logging * Improve Snowflake v1 API compatibility * Clippy fixes * Make clippy happy * Fix test * Fix rest of tests
1 parent 0cb646c commit 8331b64

25 files changed

Lines changed: 1196 additions & 330 deletions

Cargo.lock

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = [
1111
"crates/queries",
1212
"crates/error-stack",
1313
"crates/error-stack-trace"
14-
]
14+
, "crates/embucket-lambda"]
1515
resolver = "2"
1616
package.license-file = "LICENSE"
1717

crates/api-snowflake-rest/src/models.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,11 @@ pub struct LoginRequestData {
4343
pub svn_revision: Option<String>,
4444
pub account_name: String,
4545
pub login_name: String,
46-
pub client_environment: ClientEnvironment,
46+
pub client_environment: HashMap<String, serde_json::Value>,
4747
pub password: String,
4848
pub session_parameters: HashMap<String, serde_json::Value>,
4949
}
5050

51-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
52-
#[serde(rename_all = "UPPERCASE")]
53-
pub struct ClientEnvironment {
54-
pub application: String,
55-
pub os: String,
56-
pub os_version: String,
57-
pub python_version: String,
58-
pub python_runtime: String,
59-
pub python_compiler: String,
60-
pub ocsp_mode: String,
61-
pub tracing: u32,
62-
pub login_timeout: Option<u32>,
63-
pub network_timeout: Option<u32>,
64-
pub socket_timeout: Option<u32>,
65-
}
66-
6751
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
6852
#[serde(rename_all = "camelCase")]
6953
pub struct QueryRequest {
@@ -76,7 +60,7 @@ pub struct QueryRequest {
7660
#[serde(rename_all = "camelCase")]
7761
pub struct QueryRequestBody {
7862
pub sql_text: String,
79-
pub async_exec: bool,
63+
pub async_exec: Option<bool>,
8064
}
8165

8266
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
@@ -95,7 +79,10 @@ pub struct ResponseData {
9579
pub row_set_base_64: Option<String>,
9680
#[serde(rename = "rowset")]
9781
pub row_set: Option<Box<RawValue>>,
98-
pub total: Option<u32>,
82+
#[serde(skip_serializing_if = "Option::is_none")]
83+
pub total: Option<i64>,
84+
#[serde(skip_serializing_if = "Option::is_none")]
85+
pub returned: Option<i64>,
9986
#[serde(rename = "queryResultFormat")]
10087
pub query_result_format: Option<String>,
10188
#[serde(skip_serializing_if = "Option::is_none")]

crates/api-snowflake-rest/src/server/error.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ impl IntoResponse for Error {
9494
}
9595

9696
impl Error {
97+
#[must_use]
98+
pub fn missing_auth_token() -> Self {
99+
MissingAuthTokenSnafu.build()
100+
}
101+
102+
#[must_use]
103+
pub fn invalid_auth_token() -> Self {
104+
InvalidAuthTokenSnafu.build()
105+
}
106+
107+
#[must_use]
108+
pub fn invalid_auth_data() -> Self {
109+
InvalidAuthDataSnafu.build()
110+
}
111+
97112
pub fn query_id(&self) -> QueryRecordId {
98113
if let Self::Execution { source, .. } = self {
99114
source.query_id()
@@ -216,6 +231,7 @@ impl Error {
216231
row_set_base_64: None,
217232
row_set: None,
218233
total: None,
234+
returned: None,
219235
query_result_format: None,
220236
// Query uuid is returned to the user
221237
query_id: Some(self.query_id().as_uuid().to_string()),

0 commit comments

Comments
 (0)