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

[ES|QL] improve function validation errors #180518

Open
drewdaemon opened this issue Apr 10, 2024 · 3 comments
Open

[ES|QL] improve function validation errors #180518

drewdaemon opened this issue Apr 10, 2024 · 3 comments
Labels
enhancement New value added to drive a business result Feature:ES|QL ES|QL related features in Kibana impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Team:ESQL ES|QL related features in Kibana

Comments

@drewdaemon
Copy link
Contributor

drewdaemon commented Apr 10, 2024

WHEN I have typed a function invocation
AND there are no matching function signatures
THEN I expect to see helpful feedback and guidance

Explanation

Today, our validation errors for functions suffer from a few shortcomings like

These generally come down to the validation engine making assumptions about which call signature to use to generate the validation messages.

We should get less smart to get more smart. To do this, we should give the user as much relevant information as possible without being overwhelming.

Note: This is not only a user-facing enhancement. Making these errors more deterministic will result in a more maintainable validation test suite since we always assert against the error strings. It is a pain if they change without changing meaningfully.

Proposed algorithm

Let `I` := the given invocation.

Let `A` := all function definitions with the same number of parameters (arity) as `I`.

If `A` is not the empty set

	Let `S` be the signature matching the invocation.

	If `S` is not `null`
		return.
	If `S` is `null`, 
		report the differences between `I` and each signature in `A`.

If `A` is the empty set
	report that `I` matches no call signature and list all valid signatures.

Examples

Given func has the following signatures

  • version
  • number, number
  • string, string
  • boolean, boolean, boolean

The following invocations should generate the following approximate error messages

func(number)

"Expected func(version) but found func(number)."

func(version, version)

"Expected one of func(number, number), func(string, string) but found func(version, version)."

func()

"Expected one of func(version), func(number, number), func(string, string), or func(boolean, boolean, boolean) but found func(version, version)."

@drewdaemon drewdaemon added enhancement New value added to drive a business result impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:ESQL ES|QL related features in Kibana labels Apr 10, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@drewdaemon
Copy link
Contributor Author

Impact low since the auto-complete should keep most users out of incorrect function signatures.

@drewdaemon drewdaemon changed the title [ES|QL] prioritize function signatures by parameter position [ES|QL] improve validation errors for incorrect function signature scenario Apr 10, 2024
@drewdaemon drewdaemon changed the title [ES|QL] improve validation errors for incorrect function signature scenario [ES|QL] improve function validation errors Jun 11, 2024
@drewdaemon drewdaemon added impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. and removed impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. labels Jun 11, 2024
@drewdaemon
Copy link
Contributor Author

Impact medium since this issue now encompasses a few key enhancements to our validation error messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:ES|QL ES|QL related features in Kibana impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Team:ESQL ES|QL related features in Kibana
Projects
None yet
Development

No branches or pull requests

3 participants