Problem
When trying to query an external table created for a generic ODBC external data source, the following error can be observed:
Message 7320, level 16, state 110, line 87
Unable to execute query "Remote Query" against OLE DB provider "MSOLEDBSQL" on link server "(null)". 105082; Generic ODBC error: OdbcBufferReader.ReadBuffer, error in OdbcReadBuffer: SqlState: IM001, NativeError: 0, 'Error calling: SQLSetDescRec(this->GetHdesc(), (SQLSMALLINT)column->idxServerCol, (SQLSMALLINT)column->odbcReadType, 0, column->valueLength, (SQLSMALLINT)column->precision, (SQLSMALLINT)column->scale, (SQLPOINTER)(pBuffer + column->valueOffset), (SQLLEN *)indPtr, (SQLLEN *)indPtr), SQL return code: -1 | SQL Error Info: Error <1>: ErrorMsg: [Microsoft][ODBC Driver Manager] The driver does not support this function. | Error calling: pReadConn->ReadBuffer(pBuffer, bufferOffset, bufferLength, pBytesRead, pRowsRead) | state: FFFF, number: 239, active connections: 9', Connection String: Dsn={DSN Name};Driver={Driver Name};uid=root;server=xxxxx;port=xxxx;database=xxxx.
Cause
PolyBase Data Movement Service is instructing the driver to call SQLSetDescRec Function - ODBC API Reference | Microsoft Docs. Just as the error indicates the driver does not support this function and returns this error as a result. This is a driver-dependent behavior and could, in principal, occur for any generic ODBC driver used for PolyBase external data source.
Resolution
SQL Server 2019 Cumulative Update 11 included a new CONNECTION_OPTION to prevent this error from occurring. To apply this workaround you need to have applied Cumulative Update 11 or later.
To resolve this issue you can add the following key-value pair to the CONNECTION_OPTIONS of the external data source used by the external table:
PolyBaseOdbcSupportsSetDescRec=false
This should force the PolyBase Data Movement to not call that SQLSetDescRec function and avoid the error.