apache / apache/datafusion-sqlparser-rs
Optional GROUP BY statement
- Lenguaje dominante
- Rust
- Estrellas
- 3.5k
- Forks
- 772
- Merge medio
- 4 d 9 h
- PR fusionados (30 d)
- 17
Descripción
Working on my custom sql validation, I needed somehow to check, does user provide group_by/limit+offset/sort_by clauses.
I got smth like this and found `.group_by` field as non-optional. Is it right?
```rust
let wrong_query = "SELECT * FROM example_table GROUP BY example_field";
//Parser returns success(!) below
if let Statement::Query(q) = Parser::parse_sql(&GenericDialect {}, &query)?.first().unwrap() {
if q.limit_clause.is_none() {...}
if q.order_by.is_none() {...}
let select_query = query.body.as_select().unwrap();
//And I expected smth like this:
if select_query.group_by.is_none() {...}
}
```
Maybe I'm doing smth wrong and there is a proper and faster way for that?
Also I noticed a `parse_optional_group_by` fn but I didn't get how to use it., there is no info nor examples in docs about it. Looks like it's inner fn?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Start by reading the Select.group_by field returned through Parser::parse_sql and the parse_optional_group_by function mentioned in the issue. Determine how the parser represents an absent GROUP BY clause and whether the public API or its documentation needs to expose that distinction; done means the intended behavior is documented or covered by an appropriate parser test.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust, sql
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100