Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
1.98k stars 1.15k forks source link

LogsTable.rows misses string[] and number[] types #30088

Open irnc opened 2 weeks ago

irnc commented 2 weeks ago

Describe the bug Cell value in results row are defined as Date | string | number | Record<string, unknown> | boolean.

https://github.com/Azure/azure-sdk-for-js/blob/9488fe4bd780306e2f00eaa1509eba20982215f4/sdk/monitor/monitor-query/src/models/publicLogsModels.ts#L164

Query with make-series creates cell value of type string[]. While series_decompose creates values of number[].

Expected behavior Cell value type should be extended to include string[] | number[], i.e.

rows: (Date | string | number | Record<string, unknown> | boolean | string[] | number[])[][];

sarangan12 commented 2 weeks ago

@irnc

What exactly is the discrepency here Even if the make-series returns string[] it is returned correctly. (Because of the [][] outside the brackets). I have written a sample program to verify this behavior:

import { DefaultAzureCredential } from "@azure/identity";
import { LogsQueryClient, LogsQueryResult, LogsQuerySuccessfulResult } from "@azure/monitor-query";

async function main() {
    const tokenCredential = new DefaultAzureCredential();
    const logsQueryClient = new LogsQueryClient(tokenCredential);
    const result: LogsQueryResult = await logsQueryClient.queryWorkspace("<YOUR_WORKSPACE_ID>",
        `Usage | limit 100 | make-series count() on TimeGenerated from ago(10d) to now() step 1h`, 
        {
        startTime: new Date(new Date().getTime() - 24 * 60 * 60 * 10000),
        endTime: new Date(),
    });
    console.log((result as LogsQuerySuccessfulResult).tables[0].rows[0][0]);//The rows[0][0] itself is an array. 
}

main();

If you face any more issues, please let me know. Else, could you give me an example of the problem, with explanation, that you are facing? Thanks.

irnc commented 2 weeks ago

What exactly is the discrepency here Even if the make-series returns string[] it is returned correctly. (Because of the [][] outside the brackets). I have written a sample program to verify this behavior:

[][] denounce the row index and column index, while inside a column value there could be another array of string or number type.

I have an issue with this because in tests we have a fixture of a response, which is passed to function parameter of type LogsQuerySuccessfulResult. This code doesn't pass type-check because fixture has string[] inside rows[0][0], while string[] is not part of rows[][] type definition.