Error converting data type VARCHAR to DECIMAL

HSever 141 Reputation points
2023-01-09T06:07:58.73+00:00

I run an export from an Oracle table to csv file and have the csv on data lake. I scripted the Synapse destination table columns datatypes so they are correct. While loading with copy data from lake to Synapse I get:
PolybaseOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error happened when loading data into SQL Data Warehouse. Operation: 'Polybase operation'.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=HdfsBridge::recordReaderFillBuffer - Unexpected error encountered filling record reader buffer: HadoopSqlException: Error converting data type VARCHAR to DECIMAL.,Source=.Net SqlClient Data Provider,SqlErrorNumber=107090,Class=16,ErrorCode=-2146232060,State=1,Errors=[{Class=16,Number=107090,State=1,Message=HdfsBridge::recordReaderFillBuffer - Unexpected error encountered filling record reader buffer: HadoopSqlException: Error converting data type VARCHAR to DECIMAL.,},],'"

  1. There is no reference in the output log regarding the column that fails. How do I know which column fails?
  2. As per (https://learn.microsoft.com/en-us/azure/data-factory/connector-azure-sql-data-warehouse?tabs=synapse-analytics#staged-copy-by-using-polybase), if I use staging it should fix if the source data is not natively compatible with Polybase. Is there any way to still use “Copy data”, or I should better chance to data flow (and add derived columns decimal for any datatype transformation)
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
{count} votes

2 answers

Sort by: Most helpful
  1. HSever 141 Reputation points
    2023-01-25T01:43:59.41+00:00

    Hi @KranthiPakala-MSFT , most likely your solution would have covered the majority of cases. However, it was not solving my particular case, since the file was gzip compressed and in Synapse it needed to be unzipped on staging and then load. However the loading failed. this was a large table (1 bil records, approx 180 GB). Really the way to fix, I used below:

    1. scripted Synapse stage table by change all decimal columns with varchar (like 256) , larger length.
    2. just used copy command which worked on this staging table.
    3. than I could test this table for any row null, not decimal, etc in SQL and CTAS to final table. Strangely I did not find any column that would have failed conversion from varchar to decimal, just think that the file was too large (approx 200 GB, over 1 bil records). but applying the previous method, the time decreased, and did not have to use staging too.

    Thank you,

    1 person found this answer helpful.

  2. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2023-01-09T22:20:58.943+00:00

    Hello @HSever ,

    Thanks for the question and using MS Q&A platform.

    For logging incompatible rows:

    Workaround to overcome the error:

    • After logging the incompatible rows please validate if the source data column (varchar) is having empty values which were trying to load to Synapse Decimal type column. This error usually occurs when trying to load empty values to a Decimal type of column in Synapse. To overcome such issues, the solution is to unselect Use type default option (as false) in copy activity sink -> PolyBase settings. USE_TYPE_DEFAULT is a PolyBase native configuration, which specifies how to handle missing values in delimited text files when PolyBase retrieves data.

    277623-image.png

    Here is the reference document: Azure Synapse PolyBase Troubleshooting - Loading to Decimal column

    Hope this info helps.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.