question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot cast value of type 'array' to type 'record'

See original GitHub issue

I am trying to integrate Azure Stream Analytics with Azure Machine Learning and getting the following error: I am getting the following error: Cannot cast value of type 'array' to type 'record' in expression 'inputArray'. At line '7' and column '18'. TRY_CAST function can be used to handle values with unexpected type.

  • steps: I have deployed an azureml model in aks and linked the model to Azure Stream Analytics image

the model input was defined as the following:

input_sample = np.array([[34.13,34.13,34.13,34.13,3.48,34.13,34.13,34.13,34.13,34.13,34.13]])
@input_schema('data', NumpyParameterType(input_sample))

in Azure Stream Analytics I created an input array

function createArray(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) {
    'use strict';
    var array = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11]
    return array;
}

and when I am trying to invoke the Azure Machine Learning UDF using the following query:

WITH 
ModelInput AS (
SELECT udf.createArray(cast(v1 as float), cast(v2 as float), cast(v3 as float), cast(v4 as float), cast(v5 as float), cast(v6 as float), cast(v7 as float), cast(v8 as float), cast(v9 as float), cast(v10 as float), cast(v11 as float)) as inputArray
FROM input
) 

SELECT udf.score(inputArray)
INTO output
FROM ModelInput
WHERE inputArray is not null

I am getting the following error: Cannot cast value of type 'array' to type 'record' in expression 'inputArray'. At line '7' and column '18'. TRY_CAST function can be used to handle values with unexpected type.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sidramadosscommented, Jun 8, 2021

When sending one input array as part of http request to the endpoint, it returns the right result: image

The problem is with how your endpoint handles multiple inputs part of the same input. If 2 arrays are sent as part of the same http request, the expectation is that there are equal number of results in the response from endpoint. I tried sending 2 arrays but got only 1 result which doesn’t make sense. image

It should’ve returned: [ 5.0, 5.0 ]

0reactions
mouhannadalicommented, Jun 8, 2021

@sidramadoss thanks for the clarification. ASA and its logic are new for me. I was thinking it should support that to predict something you might need some history.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to cast array (text[]) to record-type?
PostgreSQL has the ability to create record types. ... AS t(a); ERROR: cannot cast type text[] to census.series_id LINE 1: SELECT a::census.
Read more >
Cannot convert value of type '[Record]' to ...
records is [Record] and you are trying to casting it as single Record which is not an Array . So it is not...
Read more >
Input validation in Azure Stream Analytics queries
Input validation in Azure Stream Analytics queries ... Exception** Cannot cast value of type 'record' to type 'array' in expression 'r .
Read more >
cast() Function - Appian 23.2
The type to which the value should be cast. This may be retrieved by using typeof(x), where x is a value of the...
Read more >
Casting (and Non-Casting!) in TypeScript | by Tar Viturawong
Type casting — the act of converting the type of a value to another ... In TypeScript land, arrays and functions are subtypes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found