0

我正在 SQL Server 2019 中针对 Azure CosmosDB (MongoDB API) 设置 Polybase,但我无法创建外部表。

我在 Cosmos DB 中创建了一个示例文档,定义如下:

{
    "_id" : ObjectId("5ecc3fcd7791b617982fefa0"),
    "id" : "1",
    "products" : "2009",
    "item" : "Car",
    "type" : "Racecar"
}

从 Azure 门户截取样本收集

当我运行以下语句时:

CREATE EXTERNAL TABLE mongodb.Products 
( 
[_id] NVARCHAR(24) COLLATE Latin1_General_CI_AS NOT NULL,  
[id] NVARCHAR(10) COLLATE Latin1_General_CI_AS,
[products] NVARCHAR(10) COLLATE Latin1_General_CI_AS,
[item] NVARCHAR(10) COLLATE Latin1_General_CI_AS,
[type] NVARCHAR(10) COLLATE Latin1_General_CI_AS
) 
WITH ( 
LOCATION='Sales.Products', 
DATA_SOURCE= CosmosDB  
); 

我收到一条消息:

Msg 105083, Level 16, State 1, Line 1
105083;The following columns in the user defined schema are incompatible with the external table schema for table 'Products': user defined column: 'id' was not found in the external table, user defined column: 'products' was not found in the external table, user defined column: 'item' was not found in the external table, user defined column: 'type' was not found in the external table. The detected external table schema is: ([_id] NVARCHAR(24) COLLATE Latin1_General_100_CI_AS NOT NULL).

连接似乎很好。如果我更改 Sales.Product,我将收到一条消息,表明表不存在。

4

1 回答 1

0

我终于能够解决这个问题。如果您尝试连接到 Azure CosmosDB Mongo DB API,您似乎需要在 SQL Server 中编辑一个文件。

您需要找到 C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\Polybase\ODBC Drivers\PolyBase ODBC Driver for MongoDb.ini

并更改两行

从(不起作用):Driver=MongoDb\2.3.8\MongoDBODBCsb64.dll 的 Driver=PolyBase ODBC 驱动程序=MongoDb\2.3.8\MongoDBODBCsb64.dll 的 PolyBase ODBC 驱动程序

To (works) Driver=PolyBase ODBC Driver for MongoDb\MongoDBODBCsb64.dll Setup=PolyBase ODBC Driver for MongoDb\MongoDBODBCsb64.dll

这是 Microsoft 支持团队提供的解决方案。

于 2020-06-11T13:05:12.983 回答