Skip to content

[ES|QL] improve function validation errors #180518

@drewdaemon

Description

@drewdaemon

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 empty

	Let `S` be the signature matching the types in the invocation.

	If `S` exists
		return.
	If `S` does not exist,
                If `|A| = 1`
		        report the differences between `I` and the single non-matching signature in `A`.
                Else
                        report that `I` matches no call signature and list all valid signatures.

Else
	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)."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:ES|QLES|QL related features in KibanaTeam:ESQLES|QL related features in Kibana t//enhancementNew value added to drive a business resultimpact:mediumAddressing this issue will have a medium level of impact on the quality/strength of our product.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions