aws / aws/amazon-redshift-odbc-driver
Requested conversion is not supported
- Dominant language
- C
- Stars
- 25
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
## Version
- Driver version: `2.1.3.0`
- Redshift version `PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.71629`
- Client Operating System: `Windows Server 2019`
## Problem description
Upon upgrading from 1.x to 2.x driver versions, most of our queries now return the following error:
> OLE DB provider "MSDASQL" for linked server "REDSHIFT" returned message "Requested conversion is not supported.".
This happens for pretty any `OPENQUERY([REDSHIFT], 'SELECT * FROM sometable')` which ends up containing a "TEXT" column in it somewhere.
This never happened on the 1.x version, presumably due to there being "[Data Type Options](https://s3.amazonaws.com/redshift-downloads/drivers/odbc/1.5.9.1011/Amazon+Redshift+ODBC+Connector+Install+Guide.pdf)" on the old version for specifying the maximum data length of LongVarChar columns:

----
Many other ODBC drivers have a history of producing similar errors. This reportedly comes from converting various types to `MaxLongVarChar`, but creating nvarchars larger than 8000 (which SQL Server does not support). All of these drivers have in time come to support a "Max LongVarChar" setting, or similar, which automatically fixes this issue, without users needing to manually wrap all columns in `CAST(column AS NVARCHAR(8000))` in all of their queries.
Here are some examples I've seen in the wild:
From [Pythian](https://www.pythian.com/blog/technical-track/fix-sql-server-to-postgresql-linked-server-error-requested-conversion-is-not-supported):

From [Snowflake](https://community.snowflake.com/s/article/Requested-conversion-is-not-supported-error-on-Microsoft-SQL-Server-when-connecting-to-a-Snowflake-linked-server):
> Please configure the workaround parameter on the remote MSSQL server's ODBC driver installation, rather than the local one (where SSMS is installed):
> Open Regedit as an Administrator (on the MSSQL host), navigate to HKEY_LOCAL_MACHINE > Software > ODBC > ODBC.INI >
> Create a new String key 'default_varchar_size' and with value 4000
From [Simba](https://stackoverflow.com/a/49272102/529618):

----
Can we add back something similar here, or are the old options still available as a registry or connection string setting?
Contributor guide
Research direction
Start by reproducing the failure with SQL Server linked-server OPENQUERY against a TEXT column using driver version 2.1.3.0, then compare the 1.x Data Type Options with the current driver's handling of LongVarChar conversions. Done means TEXT queries no longer produce “Requested conversion is not supported” and the supported configuration path is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100