Forum Discussion

Jens_Fiederer's avatar
Jens_Fiederer
Copper Contributor
Apr 19, 2024

"gettype()" function in KQL - "double" result

"double" is supposedly not a datatype in Kusto (Copilot says it is a synonym for "real"), but the gettype function will return it as a value...
gettype(123.45) -> "real"

gettype(cm.total) -> "double"

(where cm was a container of measurements used to contain a number of C# double values)

 

MS should either return "real" or mention "real" in the gettype documentation so programmers writing switch statements will realize that "double" is a possible value that should be handled.

2 Replies

  • How about this:

     

    - Normalize the output: You can write a wrapper function or conditional logic that maps "double" to "real" before processing.
    - Raise a documentation request: You're spot-on, Microsoft should either:
    - Normalize gettype() to always return "real" for doubles, or
    - Explicitly mention "double" as a possible return value in the docs.

    let type = gettype(cm.total);
    case(
        type == "double", "real",
        type == "long", "long",
        type == "string", "string",
        "unknown"
    )

     

    • Jens_Fiederer's avatar
      Jens_Fiederer
      Copper Contributor

      Thanks, didn't actually have any problems dealing with it when I found out what was going on...don't know how to do a formal "documentation request", this was sort of my ineffectual attempt at one!

Resources