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..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 @@ -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 Views. This must be specified only 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": "The name of the source container on which the Materialized View will be created.", + "type": "string" + }, + "definition": { + "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" + } + }, + "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..c18a3562d71a --- /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": "mvContainerName", + "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": "sourceContainerName", + "definition": "select * from ROOT" + }, + "_rid": "e9N-s+nr644=", + "_ts": 1666700363, + "_etag": "\"00004700-0000-0800-0000-6357d44b0000\"" + } + } + } + }, + "202": {} + } +}