Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hint to errors for missing fields based on Levenshtein distance #14466

Closed
adriangb opened this issue Feb 3, 2025 · 1 comment · Fixed by #14521
Closed

Add hint to errors for missing fields based on Levenshtein distance #14466

adriangb opened this issue Feb 3, 2025 · 1 comment · Fixed by #14521
Assignees
Labels
enhancement New feature or request

Comments

@adriangb
Copy link
Contributor

adriangb commented Feb 3, 2025

Is your feature request related to a problem or challenge?

We have something internally that parses SchemaError::FieldNotFound and calculates a normalized Levenshtein distance between field and valid_fields, returning a suggestion along the lines of Did you mean x, y, z? for valid_fields with a match of over 0.5.

Given that DataFusion already has a Levenshtein distance function it must have a dependency or implementation internally to calculate it, and with #13664 merged I think it should be possible to make this really nice:

SchemaError: unknown column `timesamp` at row 1 column X.
SELECT id, timesamp
           ^^^^^^^^
           Unknown column `timestamp`. Did you mean `timestamp`?
FROM table

This is something we could upstream if the project wants it, it's only a couple LOC.

@adriangb adriangb added the enhancement New feature or request label Feb 3, 2025
@adriangb adriangb changed the title Add hint to errors for missing fields Add hint to errors for missing fields based on Levenshtein distance Feb 3, 2025
@Lordworms
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants