Skip to content

Commit b86e644

Browse files
corrected logic
1 parent 933a582 commit b86e644

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/handlers/http/query.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
100100
let table_name = query
101101
.first_table_name()
102102
.ok_or_else(|| QueryError::MalformedQuery("No table name found in query"))?;
103-
let time = Instant::now();
104103

104+
user_auth_for_query(&permissions, &tables)?;
105+
106+
let time = Instant::now();
105107
if let Some(column_name) = query.is_logical_plan_count_without_filters() {
106108
let date_bin_request = DateBinRequest {
107109
stream: table_name.clone(),
@@ -127,9 +129,6 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
127129

128130
return Ok(HttpResponse::Ok().json(response));
129131
}
130-
131-
user_auth_for_query(&permissions, &tables)?;
132-
133132
let (records, fields) = query.execute(table_name.clone()).await?;
134133

135134
let response = QueryResponse {

src/query/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,22 @@ impl Query {
217217
};
218218

219219
// Ensure the input of the Aggregate is a TableScan and there is exactly one expression: SELECT COUNT(*)
220-
if !matches!(&**input, LogicalPlan::TableScan { .. }) || expr.len() == 1 {
220+
if !matches!(&**input, LogicalPlan::TableScan { .. }) || expr.len() != 1 {
221221
return None;
222222
}
223223

224224
// Check if the expression is a column or an alias for COUNT(*)
225225
match &expr[0] {
226226
// Direct column check
227-
Expr::Column(Column { name, .. }) if name == "count(*)" => Some(name),
227+
Expr::Column(Column { name, .. }) if name.to_lowercase() == "count(*)" => Some(name),
228228
// Alias for COUNT(*)
229229
Expr::Alias(Alias {
230230
expr: inner_expr,
231231
name: alias_name,
232232
..
233233
}) => {
234234
if let Expr::Column(Column { name, .. }) = &**inner_expr {
235-
if name == "count(*)" {
235+
if name.to_lowercase() == "count(*)" {
236236
return Some(alias_name);
237237
}
238238
}

0 commit comments

Comments
 (0)