rinsed-org / rb-snowflake-client

pure ruby snowflake (REST API) client
MIT License
9 stars 11 forks source link

Receive 422s from SF when attempting to use bind variables #57

Open clajiness-cp opened 3 months ago

clajiness-cp commented 3 months ago

Hi, all.

Whenever I attempt to use bind variables, I receive a 422 from Snowflake. I even tested this with your example code, and a bunch of other permutations. Is anyone else seeing this behavior?

RubySnowflake::BadResponseError (Bad response! Got code: 422, w/ message {
  "code" : "002040",
  "message" : "SQL compilation error:\nUnsupported data type 'null'.",
  "sqlState" : "42601",
  "statementHandle" : "01b68b2b-0308-1315-0026-658704ef8e0a"
}):

I'd provide sample code, but it's literally the same as in your example.

json_string = '{"valid": "json"}'
query = "insert into BIGTABLE(data) select parse_json(?)"
bindings = {
  "1": {
    "type": "TEXT",
    "value": json_string
  }
}
client.query(query, bindings: bindings)

Thanks much!

mhais22 commented 1 month ago

Using a hash worked for me:

    bindings = {
      "1" => {
        "type" => "TEXT",
        "value" => "Other Event"
      }
    }