Skip to main content

Failed to convert to datatype: 'string'. The original datatype of the column is: 'int'.

  • 19 September 2023
  • 0 replies
  • 51 views

If you encounter this error message while working with one of our connectors for dynamic or semi-dynamic drivers, it indicates that you are facing challenges when attempting to convert a column's data from its original datatype which can be ('int') to a string datatype ('string'). This problem primarily may be related to datatype detection issues. 

 

Possible Causes 

Before we explore solutions, let's understand the potential causes of this: 

 

1. Datatype Detection: Our connectors use datatype detection to determine the appropriate datatypes for columns in data sources. If the detection process fails, it may result in columns being incorrectly classified, leading to this conversion error. 

 

2. Insufficient Data Sampling: Our connectors, by default, sample a limited number of rows to detect column datatypes. If your dataset contains data types not revealed within this limited sample, it can lead to datatype mismatch issues. 

 

Now, let's explore three potential solutions to resolve this issue: 

 

Possible Solutions 

 

1. Set the RowScanDepth Connection Property 

 

To address datatype detection issues related to insufficient data sampling, you can adjust the RowScanDepth connection property in our connectors. This property determines how many rows should be scanned to heuristically determine data types. 

 

  • Increase RowScanDepth: Set the RowScanDepth to a higher value, such as 1000, especially when using dynamic or semi-dynamic data sources. By increasing the number of rows scanned, you improve the chances of correctly classifying data types. This is particularly helpful if your dataset contains data types that are not revealed in the default value. 

 

 

 

 

 2. Set the TypeDetectionScheme Connection Property 

 

The TypeDetectionScheme connection property determines how our connector classifies column datatypes. It has two possible values: None and RowScan. 

 

  • Set TypeDetectionScheme to NONE: Changing the TypeDetectionScheme to 'None' can be a solution when you want to ensure that all columns are treated as string types. When set to 'None', our connector will consider all columns as strings, regardless of their actual content. 

It should be noted that the TypeDetectionScheme is not available in every connector. Some of the connectors might make use of a different option for metadata discovery and type detection. 

3. Set the IgnoreTypes Connection Property 

 

If you encounter issues with specific datatypes failing to be converted, you can utilize the IgnoreTypes connection property. This property allows you to specify the datatypes that should be treated as normal strings. 

 

  • Set IgnoreTypes: Configure the IgnoreTypes property to include the datatypes that are failing to be converted. This forces the driver to treat those values as plain strings, avoiding conversion issues. 

It should be noted that the IgnoreTypes Connection property is not visible and should be set in the Other connection property of the connector (Other=IgnoreTypes=integer,datetime). You can add as many datatypes as you wish to be treated using a comma-separated list like below: 

 

 

By applying these solutions, you can address datatype conversion challenges encountered in our connectors and ensure smoother data transformations within your packages. Remember to adjust these properties based on your specific data source and requirements. 

 

Please reach out to [email protected] if this does not help you.