From b9c4eb1977ad8b08b97a4cb1ae998826054f0318 Mon Sep 17 00:00:00 2001 From: Sarwesh Krishnan Date: Tue, 25 Oct 2022 18:20:26 +0530 Subject: [PATCH 1/2] Initial commit for SQL MV preview --- .../preview/2022-11-15-preview/cosmos-db.json | 22 +++++ ...smosDBSqlMaterializedViewCreateUpdate.json | 83 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json index d474c49c4f45..14b535568535 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json @@ -9092,6 +9092,10 @@ "createMode": { "description": "Enum to indicate the mode of resource creation.", "$ref": "#/definitions/CreateMode" + }, + "materializedViewDefinition": { + "$ref": "#/definitions/MaterializedViewDefinition", + "description": "The configuration for defining Materialized View. This must be specified for creating a Materialized View container." } }, "required": [ @@ -9422,6 +9426,24 @@ "encryptionAlgorithm" ] }, + "MaterializedViewDefinition": { + "type": "object", + "description": "Materialized View definition for the container.", + "properties": { + "sourceCollectionId": { + "description": "Name of the Cosmos DB SQL source container", + "type": "string" + }, + "definition": { + "description": "Definition for the SQL Materialized view", + "type": "string" + } + }, + "required": [ + "sourceCollectionId", + "definition" + ] + }, "SqlStoredProcedureResource": { "type": "object", "description": "Cosmos DB SQL storedProcedure resource object", diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json new file mode 100644 index 000000000000..0886d7e4490c --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json @@ -0,0 +1,83 @@ +{ + "parameters": { + "accountName": "ddb1", + "resourceGroupName": "rg1", + "api-version": "2022-11-15-preview", + "subscriptionId": "subid", + "databaseName": "databaseName", + "containerName": "mvContainerName", + "createUpdateSqlContainerParameters": { + "location": "West US", + "tags": {}, + "properties": { + "resource": { + "id": "mvContainerName", + "partitionKey": { + "paths": [ + "/pk" + ], + "kind": "Hash" + }, + "materializedViewDefinition": { + "sourceCollectionId": "sourceContainerName", + "definition": "select * from ROOT" + } + }, + "options": {} + } + } + }, + "responses": { + "200": { + "body": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/ddb1/sqlDatabases/databaseName/containers/mvContainerName", + "name": "mvContainerName", + "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/sqlContainers", + "location": "West US", + "tags": {}, + "properties": { + "resource": { + "id": "mvContainer", + "indexingPolicy": { + "indexingMode": "consistent", + "automatic": true, + "includedPaths": [{ + "path": "/*" + } + ], + "excludedPaths": [{ + "path": "/\"_etag\"/?" + } + ] + }, + "partitionKey": { + "paths": ["/pk"], + "kind": "Hash" + }, + "defaultTtl": -1, + "uniqueKeyPolicy": { + "uniqueKeys": [] + }, + "conflictResolutionPolicy": { + "mode": "LastWriterWins", + "conflictResolutionPath": "/_ts", + "conflictResolutionProcedure": "" + }, + "geospatialConfig": { + "type": "Geography" + }, + "materializedViewDefinition": { + "sourceCollectionRid": "e9N-s6Ua-4Y=", + "sourceCollectionId": "source", + "definition": "select * from ROOT" + }, + "_rid": "e9N-s+nr644=", + "_ts": 1666700363, + "_etag": "\"00004700-0000-0800-0000-6357d44b0000\"" + } + } + } + }, + "202": {} + } +} From e4c1422c470215a858f33f036b5bec43fffa2891 Mon Sep 17 00:00:00 2001 From: Sarwesh Krishnan Date: Fri, 25 Nov 2022 11:27:46 +0530 Subject: [PATCH 2/2] Addressed PR comments --- .../preview/2022-11-15-preview/cosmos-db.json | 6 +++--- .../examples/CosmosDBSqlMaterializedViewCreateUpdate.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json index 14b535568535..f0caa56ec088 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/cosmos-db.json @@ -9095,7 +9095,7 @@ }, "materializedViewDefinition": { "$ref": "#/definitions/MaterializedViewDefinition", - "description": "The configuration for defining Materialized View. This must be specified for creating a Materialized View container." + "description": "The configuration for defining Materialized Views. This must be specified only for creating a Materialized View container." } }, "required": [ @@ -9431,11 +9431,11 @@ "description": "Materialized View definition for the container.", "properties": { "sourceCollectionId": { - "description": "Name of the Cosmos DB SQL source container", + "description": "The name of the source container on which the Materialized View will be created.", "type": "string" }, "definition": { - "description": "Definition for the SQL Materialized view", + "description": "The definition should be an SQL query which would be used to fetch data from the source container to populate into the Materialized View container.", "type": "string" } }, diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json index 0886d7e4490c..c18a3562d71a 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2022-11-15-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json @@ -37,7 +37,7 @@ "tags": {}, "properties": { "resource": { - "id": "mvContainer", + "id": "mvContainerName", "indexingPolicy": { "indexingMode": "consistent", "automatic": true, @@ -68,7 +68,7 @@ }, "materializedViewDefinition": { "sourceCollectionRid": "e9N-s6Ua-4Y=", - "sourceCollectionId": "source", + "sourceCollectionId": "sourceContainerName", "definition": "select * from ROOT" }, "_rid": "e9N-s+nr644=",