<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to send BINARY parameters using the REST Sql API? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-send-binary-parameters-using-the-rest-sql-api/m-p/100806#M40428</link>
    <description>&lt;P&gt;We are trying to send a SQL query to the REST API including a BINARY parameter, EX:&lt;/P&gt;&lt;P&gt;"INSERT INTO MyTable (BinaryField) VALUES(:binaryData)"&lt;/P&gt;&lt;P&gt;We tried to encode the parameter as base64 and specify that is a BINARY type but it throws a mapping error, if we send it as STRING base64 encoded it inserts the literal string.&lt;/P&gt;&lt;P&gt;It is possible to use "unbase64" in each query but we would like to avoid this as we want to automate the process.&lt;/P&gt;&lt;P&gt;What would be the way to properly encode the parameter in order to send it?&lt;/P&gt;</description>
    <pubDate>Tue, 03 Dec 2024 17:07:04 GMT</pubDate>
    <dc:creator>Gusman</dc:creator>
    <dc:date>2024-12-03T17:07:04Z</dc:date>
    <item>
      <title>How to send BINARY parameters using the REST Sql API?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-send-binary-parameters-using-the-rest-sql-api/m-p/100806#M40428</link>
      <description>&lt;P&gt;We are trying to send a SQL query to the REST API including a BINARY parameter, EX:&lt;/P&gt;&lt;P&gt;"INSERT INTO MyTable (BinaryField) VALUES(:binaryData)"&lt;/P&gt;&lt;P&gt;We tried to encode the parameter as base64 and specify that is a BINARY type but it throws a mapping error, if we send it as STRING base64 encoded it inserts the literal string.&lt;/P&gt;&lt;P&gt;It is possible to use "unbase64" in each query but we would like to avoid this as we want to automate the process.&lt;/P&gt;&lt;P&gt;What would be the way to properly encode the parameter in order to send it?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 17:07:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-send-binary-parameters-using-the-rest-sql-api/m-p/100806#M40428</guid>
      <dc:creator>Gusman</dc:creator>
      <dc:date>2024-12-03T17:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to send BINARY parameters using the REST Sql API?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-send-binary-parameters-using-the-rest-sql-api/m-p/101157#M40566</link>
      <description>&lt;P&gt;Trying to serialize as binary can be pretty challenging, here's a way to do this with base64 - the trick is to serialize as base64 string and insert as binary with&amp;nbsp;unbase64.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;databricks api post /api/2.0/sql/statements --json '{
  "warehouse_id": "warehouse-id",
  "catalog": "catalog",
  "schema": "schema", 
  "statement": "INSERT INTO binary (bin) VALUES (unbase64(:bin))",
  "parameters": [
    {"name": "bin", "value": "$(cat ~/pixel.png | base64)", "type": "STRING"}
  ]
}'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 05:32:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-send-binary-parameters-using-the-rest-sql-api/m-p/101157#M40566</guid>
      <dc:creator>cgrant</dc:creator>
      <dc:date>2024-12-06T05:32:44Z</dc:date>
    </item>
  </channel>
</rss>

