Azure 时序见解第 2 代中添加了对 long 数据类型的支持Adding support for long data type in Azure Time Series Insights Gen2

添加对 long 数据类型的支持将仅影响我们在 Azure 时序见解第 2 代环境中对数字数据进行存储和为其编制索引的方式。The addition of support for long data type affects how we store and index numeric data in Azure Time Series Insights Gen2 environments only. 如果你的是第 1 代环境,则可以忽略这些更改。If you have a Gen1 environment, you can disregard these changes.

从 2020 年 6 月 29 日或 6 月 30 日开始(具体取决于你所在的区域),你的数据将采用 LongDouble 数据类型编制索引。Beginning June 29 or June 30, 2020, depending on your region, your data will be indexed as Long and Double. 如果你对此更改有任何疑问或问题,请通过 Azure 门户提交支持票证并提及此信息。If you have any questions or concerns about this change, submit a support ticket through the Azure portal and mention this communication.

如果你受以下任何情况影响,请进行建议的更改:If you're affected by any of the following cases, make the recommended changes:

  • 情况 1:你当前使用时序模型变量并且在遥测数据中仅发送整型数据类型。Case 1: You currently use Time Series Model variables and send only integral data types in your telemetry data.
  • 情况 2:你当前使用时序模型变量并且在遥测数据中同时发送整型和非整型数据类型。Case 2: You currently use Time Series Model variables and send both integral and nonintegral data types in your telemetry data.
  • 情况 3:你使用分类变量将整数值映射到类别。Case 3: You use categorical variables to map integer values to categories.
  • 情况 4:你使用 JavaScript SDK 构建自定义前端应用程序。Case 4: You use the JavaScript SDK to build a custom front-end application.
  • 情况 5:你在暖存储中已快要达到 1,000 属性名称限制,并且你同时发送整型和非整型数据。Case 5: You're nearing the 1,000-property name limit in Warm Store and send both integral and nonintegral data. 可以在 Azure 门户中将属性计数作为指标查看。The property count can be viewed as a metric in the Azure portal.

如果你符合上述任何情况,请对模型进行更改。If any of the cases apply to you, make changes to your model. 请使用建议的更改更新你的变量定义中的时序表达式 (TSX)。Update the Time Series Expression (TSX) in your variable definition with the recommended changes. 更新:Update:

  • 任何使用我们的 API 的自定义客户端Any custom client that uses our APIs

你可能看不到发送到你的 Azure 时序见解第 2 代环境的数据,具体取决于你的 IoT 解决方案和约束。Depending on your IoT solution and constraints, you might not have visibility into the data that's sent to your Azure Time Series Insights Gen2 environment. 如果你不确定你的数据都是整型的还是既有整型的又有非整型的,则你有几个选择。If you're unsure if your data is integral only or both integral and nonintegral, you have a few options:

  • 你可以等待此功能发布。You can wait for the feature to be released. 然后,在资源管理器 UI 中浏览原始事件,以了解哪些属性保存在两个单独的列中。Then, explore your raw events in the explorer UI to understand which properties are saved in two separate columns.
  • 你可以提前对所有数字标记进行建议的更改。You can preemptively make the recommended changes for all numeric tags.
  • 你可以暂时将部分事件路由到存储,以便更好地了解和探究你的架构。You can temporarily route a subset of events to storage to better understand and explore your schema.

若要存储事件,请为 Azure 事件中心开启事件捕获,或者从 IoT 中心路由到 Azure Blob 存储。To store events, turn on event capture for Azure Event Hubs, or route from your IoT Hub to Azure Blob storage.

还可以通过事件中心资源管理器事件处理器主机来观察数据。Data can also be observed through the Event Hub Explorer, or by using the Event Processor Host.

如果你使用 IoT 中心,请参阅从内置终结点读取设备到云消息以了解如何访问内置终结点。If you use IoT Hub, go to Read device-to-cloud messages from the built-in endpoint for how to access the built-in endpoint.

备注

如果未进行建议的更改,则可能会发生中断。You might experience a disruption if you don't make the recommended changes. 例如,通过查询 API 或时序见解资源管理器访问的受影响的时序见解变量将返回 null(即,不在资源管理器中显示数据)。For example, the affected Time Series Insights variables that are accessed via the query APIs or Time Series Insights explorer will return null (that is, show no data in the explorer).

情况 1:使用时序模型变量并且在遥测数据中仅发送整型数据类型Case 1: Using Time Series Model variables and sending only integral data types in telemetry data

针对情况 1 的建议更改与情况 2 相同。The recommended changes for Case 1 are the same as for Case 2. 请根据适用于情况 2 的部分中的说明进行操作。Follow the instructions in the section for Case 2.

情况 2:使用时序模型变量并在遥测数据中同时发送整型和非整型类型Case 2: Using Time Series Model variables and sending both integral and nonintegral types in telemetry data

如果你当前发送整数遥测数据,则你的数据将拆分为两列:If you currently send integer telemetry data, your data will be divided into two columns:

  • propertyValue_doublepropertyValue_double
  • propertyValue_longpropertyValue_long

整数数据写入到 propertyValue_longYour integer data writes to propertyValue_long. propertyValue_double 中以前引入的(和将来引入的)数字数据不会进行复制。Previously ingested (and future ingested) numeric data in propertyValue_double isn't copied over.

如果你要跨这两个列查询 propertyValue 属性的数据,则需要在 TSX 中使用 coalesce() 标量函数。If you want to query data across these two columns for the propertyValue property, you need to use the coalesce() scalar function in your TSX. 此函数接受相同 DataType 的参数,并返回参数列表中的第一个非 null 值。The function accepts arguments of the same DataType and returns the first non-null value in the argument list. 有关详细信息,请参阅 Azure 时序见解第 2 代数据访问概念For more information, see Azure Time Series Insights Gen2 data access concepts.

TSX 中的变量定义 - 数字Variable definition in TSX - numeric

以前的变量定义:Previous variable definition:

以前的变量定义Previous Variable Definition

新的变量定义:New variable definition:

新的变量定义New Variable Definition

还可以使用 coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) 作为自定义时序表达式You can also use coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) as the custom Time Series Expression.

使用 TSX 查询 API 的内联变量定义 - 数字Inline variable definition using TSX query APIs - numeric

以前的变量定义:Previous variable definition:

"PropertyValueVariable": {

    "kind": "numeric",

    "value": {

        "tsx": "$event.propertyValue.Double"

    },

    "filter": null,

    "aggregation": {

        "tsx": "avg($value)"
    }
}

新的变量定义:New variable definition:

"PropertyValueVariable ": {

    "kind": "numeric",

    "value": {

        "tsx": "coalesce($event.propertyValue.Long, toLong($event.propertyValue.Double))"

    },

    "filter": null,

    "aggregation": {

        "tsx": "avg($value)"
    }
}

还可以使用 coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) 作为自定义时序表达式You can also use coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) as the custom Time Series Expression.

备注

建议在可能使用这些变量的所有位置更新它们。We recommend that you update these variables in all places they might be used. 这些位置包括时序模型、已保存的查询和 Power BI 连接器查询。These places include Time Series Model, saved queries, and Power BI connector queries.

事例 3:使用类别变量将整数值映射到类别Case 3: Using categorical variables to map integer values to categories

如果你当前在使用将整数值映射到类别的类别变量,则可以使用 toLong 函数将数据从 Double 类型转换为 Long 类型。If you currently use categorical variables that map integer values to categories, you're likely using the toLong function to convert data from Double type to Long type. 与情况 1 和情况 2 一样,你需要联合 DoubleLong DataType 列。Just like Cases 1 and 2, you need to coalesce the Double and Long DataType columns.

时序资源管理器中的变量定义 - 类别Variable definition in Time Series Explorer - categorical

以前的变量定义:Previous variable definition:

以前的变量定义Previous Variable Definition

新的变量定义:New variable definition:

新的变量定义New Variable Definition

还可以使用 coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) 作为自定义时序表达式You can also use coalesce($event.propertyValue.Double, toDouble($event.propertyValue.Long)) as the custom Time Series Expression.

分类变量仍要求值为整数类型。Categorical variables still require the value to be of an integer type. 在自定义时序表达式中,coalesce() 中的所有参数的 DataType 都必须是 Long 类型。The DataType of all the arguments in coalesce() must be of type Long in the custom Time Series Expression.

使用 TSX 查询 API 的内联变量定义 - 类别Inline variable definition using TSX query APIs - categorical

以前的变量定义:Previous variable definition:

"PropertyValueVariable_Long": {

    "kind": "categorical",

    "value": {

        "tsx": "tolong($event.propertyValue.Double)"

    },

    "categories": [

    {
        "label": "Good",

        "values": [0, 1, 2 ]

    },

    {

        "label": "Bad",

        "values": [ 3, 4 ]

    } ],

    "defaultCategory": {

        "label": "Unknown"

    }
}

新的变量定义:New variable definition:

"PropertyValueVariable_Long": {

    "kind": "categorical",

    "value": {

        "tsx": "coalesce($event.propertyValue.Long, tolong($event.propertyValue.Double))"

    },

    "categories": [

    {
        "label": "Good",

        "values": [0, 1, 2 ]

    },

    {

        "label": "Bad",

        "values": [ 3, 4 ]

    } ],

    "defaultCategory": {

        "label": "Unknown"

    }
}

分类变量仍要求值为整数类型。Categorical variables still require the value to be of an integer type. 在自定义时序表达式中,coalesce() 中的所有参数的 DataType 都必须是 Long 类型。The DataType of all the arguments in coalesce() must be of type Long in the custom Time Series Expression.

备注

建议在可能使用这些变量的所有位置更新它们。We recommend that you update these variables in all places they might be used. 这些位置包括时序模型、已保存的查询和 Power BI 连接器查询。These places include Time Series Model, saved queries, and Power BI connector queries.

事例 4:使用 JavaScript SDK 构建自定义前端应用程序Case 4: Using the JavaScript SDK to build a custom front-end application

如果你受情况 1-3 影响并且构建的是自定义应用程序,则需要更新查询以使用 coalesce() 函数,如以上示例所示。If you're affected by Cases 1 through 3 and build custom applications, you need to update your queries to use the coalesce() function, as demonstrated in the previous examples.

事例 5:即将达到暖存储的 1,000 属性限制Case 5: Nearing Warm Store 1,000 property limit

如果你是具有大量属性的暖存储用户,并且认为此更改会导致你的环境超出 1,000 暖存储属性名称限制,请通过 Azure 门户提交支持票证并提及此信息。If you're a Warm Store user with a large number of properties and believe that this change would push your environment over the 1,000 Warm Store property-name limit, submit a support ticket through the Azure portal and mention this communication.

后续步骤Next steps