fix: janky check for values

This commit is contained in:
dal 2025-02-04 17:26:57 -07:00
parent 87a6225f1d
commit 960c89ab84
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
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 {