apache / apache/datafusion

Type signature matching errors are overly verbose and show internal details

Abierto
#20,501 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
9.3k
Forks
2.4k
Merge medio
3 d 11 h
PR fusionados (30 d)
360

Descripción

## Description

After upgrading to DataFusion 52, error messages for function signature mismatches have become less concise and helpful. When a user tries to call an aggregate function with an unsupported type, they now see verbose internal errors instead of user-friendly messages.

This regression was introduced in PR #18769 ("Refactor avg & sum signatures away from user defined"), which was part of the broader effort in #12725 to avoid use of `Signature::user_defined`.

## To Reproduce

```sql
CREATE TABLE test (bool_col BOOLEAN);
SELECT SUM(bool_col) FROM test;
```

**Before (DataFusion 51):**
```
Error during planning: Execution error: Function 'sum' user-defined coercion failed with "Execution error: Sum not supported for Boolean" No function matches the given name and argument types 'sum(Boolean)'. You might need to add explicit type casts.
Candidate functions:
sum(UserDefined)
```

The key message **"Sum not supported for Boolean"** was clear and actionable.

**After (DataFusion 52):**
```
Error during planning: Internal error: Function 'sum' failed to match any signature, errors: Internal error: Expect TypeSignatureClass::Decimal but received NativeType::Boolean, DataType: Boolean.
This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues,Internal error: Expect TypeSignatureClass::Native(LogicalType(Native(UInt64), UInt64)) but received NativeType::Boolean, DataType: Boolean.
This issue was likely caused by a bug in DataFusion's code...
[repeats for each signature variant]
Candidate functions:
sum(Coercion(TypeSignatureClass::Decimal))
sum(Coercion(TypeSignatureClass::Native(LogicalType(Native(UInt64), UInt64)), implicit_coercion=...))
...
```

### Problems With New Error

1. **Misleading**: Says "Internal error" and asks users to file a bug report, but this is a user error (wrong argument type), not a DataFusion bug
2. **Verbose**: Shows every failed signature match attempt with internal type system details (`TypeSignatureClass::Native(LogicalType(...))`)
3. **Lost context**: The meaningful message "Sum not supported for Boolean" is no longer present

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Reproduce el problema con el ejemplo de SQL y compare el comportamiento de coincidencia de firmas introducido por PR #18769, centrándose en el reemplazo de Signature::user_defined. Rastree cómo se informan los tipos de argumentos de agregados no compatibles. Se considera terminado cuando los errores visibles para el usuario son concisos y accionables, conservan el contexto significativo del tipo no compatible y omiten los detalles internos de la firma.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust, sql
Área
databases
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.