Skip to content

SNOW-978294: Write to VARIANT column #821

@goforgold

Description

@goforgold

I am using snowflake named parameters but it is failing with error below. I have tried different sensible DbType options but it won't work.

Error: SQL compilation error:
Expression type does not match column data type, expecting VARIANT but got VARCHAR(1301) for column MESSAGE SqlState: 22000,

C# Part

var cmd = conn.CreateCommand();

cmd.CommandText = "insert into tbl (kafka_key, message) values (:kafkaKey, :message)";

var p1 = cmd.CreateParameter();
p1.ParameterName = "kafkaKey";
p1.DbType = DbType.String;
p1.Value = szKey;

var p2 = cmd.CreateParameter() as SnowflakeDbParameter;
p2.ParameterName = "message";
p2.DbType = DbType.String;
//p2.SFDataType = SFDataType.VARIANT; this fails too.
p2.Value = jsonMessage;

cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);

var result = await cmd.ExecuteNonQueryAsync();

Create Table

create OR REPLACE TABLE tbl (
  kafka_key varchar(36),
  message variant);

Metadata

Metadata

Labels

questionIssue is a usage/other question rather than a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions