Forum Discussion

Sudip's avatar
Sudip
Frequent Visitor
2 years ago

graphql error message. "message": "Decimal cannot parse the given value of type `System.Single`."

I have created a table in warehouse which have data types String,Int,datetime,Real,decimal.

 

I am now trying to do a mutation create and insert some records but I have the mentioned error .

{
  "errors": [
    {
      "message": "Decimal cannot parse the given value of type `System.Single`."
    }
  ]
 
reference of my input and query variable.
mutation CreateCustomer(
  $id: Int!
$rate: Single!
  $amount: Decimal!
$date: DateTime
}
createcustomer(item:{
id:$id,
rate:$rate,
amount:$amount,
date:$date
 
Query Variable is as following:
{
"id":1,
"rate":0.5,
"amount":1005.44,
"date":"2024-08-14T12:00:00.000Z"
}
}
 
I am quite confident that the error is generated by "amount" column. When i try the amount column with value 0. it works without the error

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Sudip 

     

    This error message usually occurs when a System.Single value is being passed to a field that expects a System.Decimal value. This type mismatch can cause parsing errors. Please check the data types of the relevant fields defined in your warehouse. Make sure that the database schema matches the expected data types. 

     

    You may refer to Data types in Warehouse section in Data types - Microsoft Fabric | Microsoft Learn

     

    Best Regards,
    Jing
    If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

    • Sudip's avatar
      Sudip
      Frequent Visitor

      could you provide a example?? like what values need to pass for single or decimal datatype. as i see every positive system.single is like decimal data type. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Sudip 

         

        I haven't tested a mutation in GraphQL. I tested with SQL queries to insert some data into a warehouse table. The result is below. 

        If I don't define a precision number and scale number for DECIMAL type column when creating a table, the default scale is 0. When inserting decimal numbers to the table, it will round the numbers. If I define precision number and scale number, it will round numbers to the defined precision and scale. decimal and numeric (Transact-SQL) - SQL Server | Microsoft Learn

        May I know which data type is defined for "amount" column in your warehouse table? 

         

        Best Regards,
        Jing
        If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!