# Replicating MySQL tables with binary columns

**URL:** <https://community.cdata.com/t/replicating-mysql-tables-with-binary-columns/826>\
**Category:** CData Virtuality \[Archived\]\
**Tags:** article, cdata-virtuality\
**Created:** [July 12, 2024, 4:16pm UTC](https://community.cdata.com/t/replicating-mysql-tables-with-binary-columns/826 "2024-07-12T16:16:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@anonymous](https://community.cdata.com/u/anonymous)\
**Post date:** [July 12, 2024, 4:16pm UTC](https://community.cdata.com/t/replicating-mysql-tables-with-binary-columns/826/1 "2024-07-12T16:16:39Z")

</div>

When replicating tables from a MySQL data source you may run into the following error message:&nbsp;_column “order\_details” is of type bytea but expression is of type bigint_.

Looking at the data type of the&nbsp;_order\_details_&nbsp;column, we can see that it contains binary data (blob).

 ![mysql_blob.png](https://us1.discourse-cdn.com/cdata/original/2X/d/dbcdc9aab8a30c95d1522ec3026816fceb01541f.png)

In order to replicate a column to your analytical storage, Data Virtuality needs to map the blob data type to a corresponding native data type in your analytical storage. This normally happens automatically without the need to manually intervene. In the case of binary data, however, Data Virtuality cannot automatically infer the right data type and you will have to manually provide this mapping by doing a type casting.

In our example case, the column contains textual data, so we can convert it to a&nbsp;_clob_&nbsp;using the&nbsp;_to\_chars_&nbsp;function and create a view with from that query:

| CREATE VIEW my\_data\_model.orders AS  
 SELECT to\_chars("order\_details", 'UTF-8')  
 FROM "MySQL.adventure.orders";; |

Now instead of replicating the raw table, we choose the view instead that has all columns correctly mapped to non-binary data types.
