Functions for data types

    ParseType

    Building a type from a string with description. Documentation for its format.

    Examples

    TypeOf

    Getting the type of value passed to the argument.

    Examples

    For types - 图2

    1. SELECT FormatType(TypeOf(AsTuple(1, 1u))); -- Tuple<Int32,Uint32>

    InstanceOf

    Returns an instance of the specified type that can only be used to get the type of the result of an expression that uses this type.

    If this instance remains in the computation graph by the end of optimization, the operation fails.

    Examples

    1. SELECT FormatType(TypeOf(
    2. InstanceOf(ParseType("Int32")) +
    3. InstanceOf(ParseType("Double"))
    4. )); -- Double, because "Int32 + Double" returns Double

    For types - 图4

    DataType

    Returns a type for primitive data types based on type name.

    Examples

    1. SELECT FormatType(DataType("Bool")); -- Bool
    2. SELECT FormatType(DataType("Decimal","5","1")); -- Decimal(5,1)

    OptionalType

    Adds the option to assign NULL to the passed type.

    Examples

    1. SELECT FormatType(OptionalType(DataType("Bool"))); -- Bool?

    For types - 图6

    Builds a list type or stream type based on the passed element type.

    Examples

    DictType

    Builds a dictionary type based on the passed key types (first argument) and value types (second argument).

    Examples

    1. SELECT FormatType(DictType(
    2. DataType("String"),
    3. DataType("Double")
    4. )); -- Dict<String,Double>

    TupleType

    Builds the tuple type from the passed element types.

    Examples

    1. SELECT FormatType(TupleType(
    2. DataType("String"),
    3. OptionalType(DataType("Bool"))

    For types - 图9

    StructType

    Builds the structure type based on the passed element types. The standard syntax of named arguments is used to specify the element names.

    Examples

    1. SELECT FormatType(StructType(
    2. DataType("Bool") AS MyBool,
    3. ListType(DataType("String")) AS StringList
    4. )); -- Struct<'MyBool':Bool,'StringList':List<String>>

    VariantType

    Returns the type of a variant based on the underlying type (structure or tuple).

    Examples

    1. SELECT FormatType(VariantType(
    2. ParseType("Struct<foo:Int32,bar:Double>")
    3. )); -- Variant<'bar':Double,'foo':Int32>

    For types - 图11

    ResourceType

    Returns the type of the based on the passed string label.

    Examples

    1. SELECT FormatType(ResourceType("Foo")); -- Resource<'Foo'>

    Constructs the type of the called value using the following arguments:

    1. Number of optional arguments (if all arguments are required — 0).
    2. Result type.
    3. All the next arguments of CallableType are treated as types of arguments of the callable value, but with a shift for two required arguments (for example, the third argument of the CallableType describes the type of the first argument in the callable value).

    Examples

    For types - 图13

    GenericType, UnitType, and VoidType

    Return the same-name . They have no arguments because they are not parameterized.

    1. SELECT FormatType(VoidType()); -- Void

    OptionalItemType, ListItemType and StreamItemType

    Perform the action reverse to , ListType, and : return the item type based on its container type.

    Examples

    1. SELECT FormatType(ListItemType(
    2. ParseType("List<Int32>")
    3. )); -- Int32

    For types - 图15

    DictKeyType and DictPayloadType

    Returns the type of the key or value based on the dictionary type.

    Examples

    1. SELECT FormatType(DictKeyType(
    2. )); -- Int32

    TupleElementType

    Returns the tuple’s element type based on the tuple type and the element index (index starts from zero).

    Examples

    1. SELECT FormatType(TupleElementType(
    2. ParseType("Tuple<Int32,Double>"), "1"
    3. )); -- Double

    For types - 图17

    StructMemberType

    Returns the type of the structure element based on the structure type and element name.

    Examples

    1. SELECT FormatType(StructMemberType(
    2. ParseType("Struct<foo:Int32,bar:Double>"), "foo"
    3. )); -- Int32

    CallableResultType returns the result type based on the type of the called value. CallableArgumentType returns the argument type based on the called value type and its index (index starts from zero).

    Examples

    For types - 图19

    VariantUnderlyingType

    Performs an action reverse to VariantType: it returns the underlying type based on the variant type.

    Examples

    1. SELECT FormatType(VariantUnderlyingType(
    2. ParseType("Variant<foo:Int32,bar:Double>")
    3. )), -- Struct<'bar':Double,'foo':Int32>
    4. FormatType(VariantUnderlyingType(
    5. )); -- Tuple<Int32,Double>