支持的数据类型Supported data types

下表列出了 Azure 时序见解第 2 代支持的数据类型The following table lists the data types supported by Azure Time Series Insights Gen2

数据类型Data type 说明Description 示例Example 时序表达式语法Time Series Expression syntax Parquet 中的属性列名称Property column name in Parquet
boolbool 具有两种状态之一的数据类型:truefalseA data type having one of two states: true or false. "isQuestionable" : true $event.isQuestionable.Bool$event['isQuestionable'].Bool$event.isQuestionable.Bool or $event['isQuestionable'].Bool isQuestionable_bool
datetimedatetime 表示某个时刻,通常以日期和当天的时间表示。Represents an instant in time, typically expressed as a date and time of day. ISO 8601 格式表示。Expressed in ISO 8601 format. 日期/时间属性始终以 UTC 格式存储。Datetime properties are always stored in UTC format. 如果格式正确,将应用时区偏移,然后以 UTC 格式存储值。Time zone offsets, if correctly formatted, will be applied and then the valued stored in UTC. 有关环境时间戳属性和日期/时间偏移的详细信息,请参阅部分See this section for more information on the environment timestamp property and datetime offsets "eventProcessedLocalTime": "2020-03-20T09:03:32.8301668Z" 如果“eventProcessedLocalTime”是事件源时间戳:$event.$tsIf "eventProcessedLocalTime" is the event source timestamp: $event.$ts. 如果它是另一个 JSON 属性:$event.eventProcessedLocalTime.DateTime$event['eventProcessedLocalTime'].DateTimeIf it's another JSON property: $event.eventProcessedLocalTime.DateTime or $event['eventProcessedLocalTime'].DateTime eventProcessedLocalTime_datetime
doubledouble 一个双精度 64 位数字A double-precision 64-bit number "value": 31.0482941 $event.value.Double$event['value'].Double$event.value.Double or $event['value'].Double value_double
longlong 已签名的 64 位整数A signed 64-bit integer "value" : 31 $event.value.Long$event['value'].Long$event.value.Long or $event['value'].Long value_long
stringstring 文本值,必须包含有效的 UTF-8。Text values, must consist of valid UTF-8. Null 字符串和空字符串的处理方式相同。Null and empty strings are treated the same. "site": "DIM_MLGGG" $event.site.String$event['site'].String$event.site.String or $event['site'].String site_string
dynamicdynamic 一个复杂的(非基元)类型,由数组或属性包(字典)组成。A complex (non-primitive) type consisting of either an array or property bag (dictionary). 目前只会将基元的字符串化 JSON 数组或不包含 TS ID 或时间戳属性的对象数组存储为动态数组。Currently only stringified JSON arrays of primitives or arrays of objects not containing the TS ID or timestamp property(ies) will be stored as dynamic. 请阅读此文章,了解对象如何平展,以及数组如何展开。Read this article to understand how objects will be flattened and arrays may be unrolled. 存储为此类型的有效负载属性只能通过以下方式进行访问:在时序见解资源管理器中选择 Explore Events 来查看原始事件,或者使用用于客户端分析的 GetEvents 查询 API。Payload properties stored as this type are only accessible by selecting Explore Events in the Time Series Insights Explorer to view raw events, or through the GetEvents Query API for client-side parsing. "values": "[197, 194, 189, 188]" 尚不支持在时序表达式中引用动态类型Referencing dynamic types in a Time Series Expression is not yet supported values_dynamic


支持 64 位整数值,但是由于 JavaScript 的限制,Azure 时序见解资源管理器可以安全地表示的最大值是 9,007,199,254,740,991 (2^53-1)。64 bit integer values are supported, but the largest number that the Azure Time Series Insights Explorer can safely express is 9,007,199,254,740,991 (2^53-1) due to JavaScript limitations. 如果在以上数据模型中使用数字,可以通过创建时序模型变量转换值来减小大小。If you work with numbers in your data model above this, you can reduce the size by creating a Time Series Model variable and converting the value.


字符串类型不可以为 null:String type is not nullable:

  • 时序查询中表示的时序表达式 (TSX) 将空字符串 ('') 的值与 NULL 进行比较,其行为方式相同:$event.siteid.String = NULL 等效于 $event.siteid.String = ''A Time Series Expression (TSX) expressed in a Time Series Query comparing the value of an empty string ('') against NULL will behave the same way: $event.siteid.String = NULL is equivalent to $event.siteid.String = ''.
  • 即使原始事件包含空字符串,API 也可能返回 NULL 值。The API may return NULL values even if original events contained empty strings.
  • 不要依赖于 String 列中的 NULL 值来进行比较或求值,请将它们视为空字符串 。Do not take dependency on NULL values in String columns to do comparisons or evaluations, treat them the same way as empty strings.

发送混合数据类型Sending mixed data types

Azure 时序见解第 2 代环境为强类型环境。Your Azure Time Series Insights Gen2 environment is strongly typed. 如果设备或标记为某个设备属性发送不同类型的数据,则值会存储在两个不同的列中,而你在 API 调用中定义时序模型变量表达式时应使用 coalesce() 函数If devices or tags send data of different types for a device property, values will be stored in two separated columns and the coalesce() function should be used when defining your Time Series Model Variable expressions in API calls.

Azure 时序见解资源管理器提供了一种方法来自动联合同一设备属性的不同列。The Azure Time Series Insights Explorer offers a way to auto-coalesce the separate columns of the same device property. 在下面的示例中,传感器会发送一个 PresentValue 属性,该属性可以是 Long 或 Double。In the example below, the sensor sends a PresentValue property that can be both a Long or Double. 若要查询 PresentValue 属性的所有已存储值(不管数据类型如何),请选择 PresentValue (Double | Long),系统会替你联合这些列。To query against all stored values (regardless of data type) of the PresentValue property, choose PresentValue (Double | Long) and the columns will be coalesced for you.

资源管理器自动联合Explorer auto coalesce

对象和数组Objects and arrays

你可以在事件有效负载中发送复杂类型,例如对象和数组。You may send complex types such as objects and arrays as part of your event payload. 嵌套对象将被平展,数组将存储为 dynamic 或进行平展以生成多个事件,具体取决于你的环境配置和 JSON 形状。Nested objects will be flattened and arrays will either be stored as dynamic or flattened to produce multiple events depending on your environment configuration and JSON shape. 若要了解详细信息,请阅读 JSON 平展和转义规则To learn more read about the JSON Flattening and Escaping Rules

后续步骤Next steps