microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

Expose selected signature for bound function calls and operators #62

Closed davidnx closed 2 years ago

davidnx commented 2 years ago

Feature ask

There is no way (that I could find) to determine the Signature that was bound for a function call or operator. Right now I am having to replicate large amounts of code from Binder_FunctionCalls.cs (the entirety of GetBestMatchingSignatures and friends).

Specifically, it would help if the SemanticInfo would somehow include the signatures that were selected.

https://github.com/microsoft/Kusto-Query-Language/blob/fb8a70cb4f8e6ef6786b0c97764330c646f976a4/src/Kusto.Language/Binder/Binder_FunctionCalls.cs#L69-L75

Motivation

This would help produce better dev experiences knowing the signature that matched a given call-site or operator. It would also help projects like https://github.com/microsofthackathons/baby-kusto-csharp implementing a self-contained Kusto engine that has to figure out what overload of a function to invoke.

mattwar commented 2 years ago

I've added the ability to access the matching signature via the ReferencedSignature property on a SyntaxNode. It might not be enough information to map to some particular function implementation overload you had in mind. The signatures are really just declarations of ways the arguments can be specified and how the result type is determined when the arguments match. Only some built-in functions and operators have more than one signature, and the number and order they are specified may be arbitrary. If you are using them, it would be best not to rely on knowing the specific set of signatures, but in the information they convey. You will probably need to know which arguments correspond to which parameters (sometimes parameters can be repeated). When you have the signature instance you can call GetArgumentParameters to determine the correspondence.

mattwar commented 2 years ago

The signature is now available via the SyntaxNode.ReferencedSignature property.