feat(dynamodb): support querying, editing, and exporting

This commit is contained in:
zipg authored and GitHub committed 2026-08-17 03:27:44 +08:00
1 parent 92ab9bb0dc
commit e97c9ab5d7
73 files changed
+4493 -134

No files matched your search

@@ -13,6 +13,10 @@ pub struct DocumentQueryResult {
// unchanged and only send the flag when Elasticsearch reports a lower bound.
#[serde(default = "default_total_is_exact", skip_serializing_if = "is_true")]
pub total_is_exact: bool,
/// Opaque document-store cursor for APIs such as DynamoDB that do not
/// support offset pagination.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub next_cursor: Option<String>,
}
fn default_total_is_exact() -> bool {
@@ -35,6 +39,7 @@ mod tests {
extended_documents: None,
total: 1,
total_is_exact: true,
next_cursor: None,
};
let serialized = serde_json::to_value(result).unwrap();
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,103 @@
use std::time::Duration;
use crate::db::document_result::DocumentQueryResult;
use crate::models::connection::ConnectionConfig;
use crate::types::QueryResult;
const FEATURE_DISABLED: &str = "DynamoDB support is not included in this DBX build";
#[derive(Clone)]
pub struct DynamoDbClient {
pub region: String,
pub endpoint_url: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DynamoDbKeyInfo {
pub name: String,
pub attribute_type: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DynamoDbIndexInfo {
pub name: String,
pub kind: String,
pub partition_key: DynamoDbKeyInfo,
pub sort_key: Option<DynamoDbKeyInfo>,
pub projection_type: String,
pub non_key_attributes: Vec<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DynamoDbTableDescription {
pub name: String,
pub status: String,
pub item_count: u64,
pub size_bytes: u64,
pub partition_key: DynamoDbKeyInfo,
pub sort_key: Option<DynamoDbKeyInfo>,
pub indexes: Vec<DynamoDbIndexInfo>,
}
pub fn connect(_config: &ConnectionConfig, _host: &str, _port: u16) -> Result<DynamoDbClient, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn test_connection(_client: &DynamoDbClient, _timeout: Duration) -> Result<(), String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn execute_statement(
_client: &DynamoDbClient,
_source: &str,
_max_rows: usize,
) -> Result<QueryResult, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn list_tables(_client: &DynamoDbClient) -> Result<Vec<String>, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn describe_table(_client: &DynamoDbClient, _table_name: &str) -> Result<DynamoDbTableDescription, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn find_items(
_client: &DynamoDbClient,
_table_name: &str,
_limit: i64,
_filter_json: Option<&str>,
_sort_json: Option<&str>,
_cursor: Option<&str>,
) -> Result<DocumentQueryResult, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn count_items(
_client: &DynamoDbClient,
_table_name: &str,
_filter_json: Option<&str>,
) -> Result<u64, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn insert_item(_client: &DynamoDbClient, _table_name: &str, _doc_json: &str) -> Result<String, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn update_item(
_client: &DynamoDbClient,
_table_name: &str,
_id: &str,
_doc_json: &str,
) -> Result<u64, String> {
Err(FEATURE_DISABLED.to_string())
}
pub async fn delete_item(_client: &DynamoDbClient, _table_name: &str, _id: &str) -> Result<u64, String> {
Err(FEATURE_DISABLED.to_string())
}
@@ -829,6 +829,7 @@ fn search_response_to_document_result(result: SearchResponse) -> Result<Document
extended_documents: None,
total,
total_is_exact,
next_cursor: None,
})
}
@@ -274,6 +274,7 @@ pub async fn find_documents(
extended_documents: None,
total: result.total,
total_is_exact: true,
next_cursor: None,
})
}
+6
View File
@@ -11,6 +11,12 @@ pub mod duckdb_sql;
pub mod duckdb_worker_process;
#[cfg(feature = "duckdb-sidecar")]
pub mod duckdb_worker_protocol;
#[cfg(feature = "dynamodb")]
#[path = "dynamodb_driver.rs"]
pub mod dynamodb_driver;
#[cfg(not(feature = "dynamodb"))]
#[path = "dynamodb_driver_disabled.rs"]
pub mod dynamodb_driver;
pub mod easysearch_driver;
pub mod elasticsearch_driver;
pub mod elasticsearch_sql;
+8
View File
@@ -189,6 +189,7 @@ pub async fn run_command(client: &Client, database: &str, command_json: &str) ->
extended_documents: Some(vec![extended_document]),
total: 1,
total_is_exact: true,
next_cursor: None,
})
}
@@ -1198,6 +1199,7 @@ async fn find_documents_with_total(
extended_documents: Some(extended_documents),
total,
total_is_exact,
next_cursor: None,
})
}
@@ -1354,6 +1356,7 @@ pub async fn find_documents_extended_json(
raw_documents: None,
total,
total_is_exact,
next_cursor: None,
})
}
@@ -1422,6 +1425,7 @@ pub async fn aggregate_documents(
extended_documents: Some(vec![extended]),
total: 1,
total_is_exact: true,
next_cursor: None,
});
}
@@ -1479,6 +1483,7 @@ async fn drain_document_cursor(
extended_documents: Some(extended_documents),
total,
total_is_exact: true,
next_cursor: None,
})
}
@@ -1539,6 +1544,7 @@ pub async fn distinct(
extended_documents: Some(extended_documents),
total,
total_is_exact: true,
next_cursor: None,
})
}
@@ -2107,6 +2113,7 @@ fn single_document_result(document: Option<Document>) -> MongoDocumentResult {
extended_documents: Some(vec![Bson::Document(document).into_canonical_extjson()]),
total: 1,
total_is_exact: true,
next_cursor: None,
},
None => MongoDocumentResult {
documents: Vec::new(),
@@ -2114,6 +2121,7 @@ fn single_document_result(document: Option<Document>) -> MongoDocumentResult {
extended_documents: Some(Vec::new()),
total: 0,
total_is_exact: true,
next_cursor: None,
},
}
}
+2
View File
@@ -621,6 +621,7 @@ pub async fn find_documents(
extended_documents: None,
total: result.affected_rows,
total_is_exact: true,
next_cursor: None,
});
}
@@ -669,6 +670,7 @@ pub async fn find_documents(
extended_documents: None,
total: result.affected_rows,
total_is_exact: true,
next_cursor: None,
})
}