我正在 SQL Server 2019 中针对 Azure CosmosDB (MongoDB API) 设置 Polybase,但我无法创建外部表。
我在 Cosmos DB 中创建了一个示例文档,定义如下:
{
"_id" : ObjectId("5ecc3fcd7791b617982fefa0"),
"id" : "1",
"products" : "2009",
"item" : "Car",
"type" : "Racecar"
}
当我运行以下语句时:
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,我将收到一条消息,表明表不存在。