Azure / Azure/azure-functions-host
NodeJs Table Storage Output Edm.DataType support
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Hi,
I have an Azure function which outputs data to Table Storage. When rows are written to the table each fields type gets inferred based on its contents. For the same column the data type is being inferred differently, a row where field A is 1.2 is stored as a double, but a row where field A is 1.00 is stored as a string. This causes problems later on when trying to import that data into Azure ML as it expects consistency.
I have made attempts to coerce the data into a double, for example
`function forceFloat(value){
if(value != null && value != undefined && value != 0)
{
return value % 1 == 0 ? parseFloat(value).toFixed(2) : value;
}
return null;
}`
I've also taken inspiration from examples which explain how to specifically enforce the type.
Enforcing the type by creating a separate metadata field
`"FieldName@odata.type": "Edm.Double",`
Enforcing the type by inserting the metadata alongside the value of the field
`return { '_': value, '$': 'Edm.Double' };`
My last attempt was to use the 'azure-storage' npm library which [I think just provides a wrapper around my second approach using the entityGenerator API](https://azure.github.io/azure-storage-node/index.html#toc5__anchor) in the 'azure-storage' npm library.
Despite using this library when my function runs I get the following output in my table

Is there something I need to do with the binding or is the Azure Function binding for Table Storage output not respecting the presence of '$': 'Edm.Double' in the object?
Contributor guide
Research direction
Start with the Azure Functions Table Storage output binding and compare its handling of the entityGenerator API from the azure-storage npm library. Reproduce the reported case with a field such as 1.00, then verify that the '$': 'Edm.Double' metadata is preserved and the stored rows use a consistent type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, node.js
- Domain
- backend, cloud, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100