Home > database >  Snowflake data type error. The integer value mapping as decimal in the response
Snowflake data type error. The integer value mapping as decimal in the response

Time:08-30

I am running this query in snowflake and it supposed to return the datatype as integer but returning as decimal.

Query: select null::integer as int_testing

response:

{
     "name": "INT_TESTING",
     "attribute_number": 0,
     "data_type": "decimal",
     "type_modifier": null,
     "length": 38,
     "precision": 38,
     "scale": 0
}

CodePudding user response:

Check the data types since INT is a synonym of NUMBER:

https://docs.snowflake.com/en/sql-reference/data-types-numeric.html#int-integer-bigint-smallint-tinyint-byteint

CodePudding user response:

Be careful with casting NULL values, as the value is intended to be UNDEFINED and you might have some unanticipated behavior in your code. Suggest using functions such as NVL() to convert NULL to a designated value.

select nvl(NULL,0)::INTEGER as int_test

  • Related