dotConnect for Snowflake Documentation
On this page
    Data Type Mapping
    On this page

    The table below contains type mapping rules that are used to map Snowflake field types to .NET types.

    Provider Data Type displays the corresponding SnowflakeType enumeration value. .NET Data Type displays the type returned by GetFieldType() and GetValue(). Synonyms of Snowflake data types, for example, INT or VARCHAR, are mapped in the same way as the types they are synonyms for.

    Snowflake Native Data Type

    Provider Data Type

    .NET Data Type

    NUMBER with scale 0 (INT, INTEGER, BIGINT, SMALLINT, TINYINT, BYTEINT)IntegerInt64
    NUMBER with scale greater than 0 (DECIMAL, NUMERIC)DecimalDecimal
    FLOAT (FLOAT4, FLOAT8, DOUBLE, DOUBLE PRECISION, REAL)DoubleDouble
    VARCHAR (STRING, TEXT, CHAR, CHARACTER, NCHAR, NVARCHAR)StringString
    VARCHAR(36) when Text36AsGuid=true, VARCHAR(38) when Text38AsGuid=trueGuidGuid
    BINARY (VARBINARY)BinaryByte[]
    BOOLEANBooleanBoolean
    DATEDateDateTime
    TIMETimeTimeSpan
    TIMESTAMP_NTZ (DATETIME)DateTimeDateTime
    TIMESTAMP_LTZTimestampLTZDateTime
    TIMESTAMP_TZTimestampTZDateTimeOffset
    VARIANTVariantString
    OBJECTObjectString
    ARRAYArrayString
    GEOGRAPHY, GEOMETRYGeographyString
    VECTORArrayString (JSON array)

    The Text36AsGuid and Text38AsGuid connection string parameters are disabled by default. When you enable them, VARCHAR(36) and VARCHAR(38) columns are returned as Guid values. Use these parameters if your tables store GUIDs as text of 36 or 38 characters.

    A Snowflake data type that the provider does not recognize, for example, a type added to the server later, is read as String.

    Semi-Structured, Spatial, and Vector Data

    Values of VARIANT, OBJECT, and ARRAY columns are returned as String values that contain JSON text in the format Snowflake returns it: objects and arrays are indented and span several lines. A value extracted by a path, such as payload:name, is JSON as well, so a string value comes in double quotes; cast it with ::STRING to get the plain text. VECTOR values are returned as JSON arrays in the format Snowflake returns them: the elements of a FLOAT vector have six decimal places, for example, [1.500000,2.000000,3.000000], and the elements of an INT vector are integers, for example, [1,2,3]. For details and examples, see Working with Semi-Structured Data.

    Snowflake doesn't accept parameters of the Variant, Object, and Array types. A statement with such a parameter fails with an error such as "Unsupported data type 'VARIANT'". A String parameter can't be inserted into a VARIANT, OBJECT, or ARRAY column directly either, because Snowflake doesn't convert text to these types. Such a statement fails with the "Expression type does not match column data type, expecting VARIANT but got VARCHAR" error. To write semi-structured data, pass the JSON text in a String parameter and convert it with the PARSE_JSON function. Because Snowflake doesn't allow PARSE_JSON in the VALUES clause, use INSERT ... SELECT:

    INSERT INTO events (id, payload) SELECT :id, PARSE_JSON(:payload)

    GEOGRAPHY and GEOMETRY values are returned as text in the format set by the GEOGRAPHY_OUTPUT_FORMAT and GEOMETRY_OUTPUT_FORMAT session parameters (GeoJSON by default). To write them, pass the value as text, for example, in the WKT or GeoJSON format: parameters of the Geography type are sent to Snowflake as text.

    Date and Time Values

    The UTC Dates connection string parameter determines how DateTime values are converted:

    Note the following as well:

    Other Notes