Merge pull request #95 from buster-so/staging

fix: janky check for values
This commit is contained in:
dal 2025-02-04 16:27:22 -08:00 committed by GitHub
commit 6535947d23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -49,9 +49,12 @@ pub async fn snowflake_query(
) -> Result<Vec<IndexMap<std::string::String, DataType>>, Error> { ) -> Result<Vec<IndexMap<std::string::String, DataType>>, Error> {
const MAX_ROWS: usize = 5_000; const MAX_ROWS: usize = 5_000;
// Wrap the original query in a limit clause let query_no_semicolon = query.trim_end_matches(';');
// let limited_query = format!("SELECT * FROM ({}) tmp_query LIMIT {}", query.replace(";", ""), MAX_ROWS); let limited_query = if !query_no_semicolon.to_lowercase().contains("limit") {
let limited_query = query; format!("{} FETCH FIRST {} ROWS ONLY", query_no_semicolon, MAX_ROWS)
} else {
query_no_semicolon.to_string()
};
let rows = match snowflake_client.exec(&limited_query).await { let rows = match snowflake_client.exec(&limited_query).await {
Ok(result) => match result { Ok(result) => match result {