Skip to content

Commit a0299fb

Browse files
Qingyu Zheng (Shanghai Wicresoft Co Ltd)Qingyu Zheng (Shanghai Wicresoft Co Ltd)
authored andcommitted
Upgrade MongoDB linked service
1 parent 53e29ad commit a0299fb

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

articles/data-factory/connector-mongodb.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: data-factory
88
ms.subservice: data-movement
99
ms.topic: conceptual
1010
ms.custom: synapse, ignite-2022
11-
ms.date: 10/25/2022
11+
ms.date: 07/24/2023
1212
---
1313

1414
# Copy data from or to MongoDB using Azure Data Factory or Synapse Analytics
@@ -251,6 +251,36 @@ To achieve such schema-agnostic copy, skip the "structure" (also called *schema*
251251

252252
To copy data from MongoDB to tabular sink or reversed, refer to [schema mapping](copy-activity-schema-and-type-mapping.md#schema-mapping).
253253

254+
## Upgrade the MongoDB linked service to the latest version
255+
256+
Here are steps that help you upgrade your linked service and related queries:
257+
258+
1. Create a new MongoDB linked service and configure it by referring to [Linked service properties](#linked-service-properties).
259+
1. If you use SQL queries in your pipelines that refer to the old MongoDB linked service, replace them with the equivalent MongoDB queries. See the following table for the replacement rules:
260+
261+
| SQL query | Equivalent MongoDB query |
262+
|:--- |:--- |
263+
| *Query pattern*||
264+
| SQL multiple joins queries |MongoDB aggregate queries with multiple `$lookup`|
265+
| `SELECT FROM` | Use `find` with projection <br>e.g: `db.users.find({}, { name: 1, email: 1 })` |
266+
| `SELECT FROM JOIN` |`$lookup` (aggregation) |
267+
| `EMPTY` | `db.table.find({})`|
268+
| `SELECT * FROM` |`db.table.find({})` |
269+
| *Keywords* ||
270+
| `CASE WHEN` |`$switch` aggregation |
271+
| `CONCAT` |`$concat` |
272+
| `AS` | `$project` |
273+
| SQL queries of datetime related functions | MongoDB queries of datetime related functions |
274+
275+
Here are some query examples that help you transfer from SQL query to MongoDB query.
276+
277+
| SQL Query | Equivalent MongoDB query |
278+
|:--- |:--- |
279+
| `SELECT * FROM users` | `db.users.find({})` |
280+
| `SELECT username, age FROM users` |`db.users.find({}, {username: 1, age: 1})` |
281+
| `SELECT username AS User, age AS Age, statusNumber AS Status, CASE WHEN Status = 0 THEN "Pending" CASE WHEN Status = 1 THEN "Finished" ELSE "Unknown" END AS statusEnum LastUpdatedTime + interval '2' hour AS NewLastUpdatedTime FROM users` | `db.users.aggregate([{ $project: { _id: 0, User: "$username", Age: "$age", Status: "$statusNumber", statusEnum: { $switch: { branches: [ { case: { $eq: ["$Status", 0] }, then: "Pending" }, { case: { $eq: ["$Status", 1] }, then: "Finished" } ], default: "Unknown" } }, NewLastUpdatedTime: { $add: ["$LastUpdatedTime", 2 * 60 * 60 * 1000] } } }])`|
282+
| `SELECT employees.name, departments.name AS department_name FROM employees LEFT JOIN departments ON employees.department_id = departments.id;`|`db.employees.aggregate([ { $lookup: { from: "departments", localField: "department_id", foreignField: "_id", as: "department" } }, { $unwind: "$department" }, { $project: { _id: 0, name: 1, department_name: "$department.name" } } ])` |
283+
254284

255285
## Next steps
256286
For a list of data stores supported as sources and sinks by the copy activity, see [supported data stores](copy-activity-overview.md#supported-data-stores-and-formats).

articles/data-factory/connector-troubleshoot-mongodb.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: jianleishen
66
ms.service: data-factory
77
ms.subservice: data-movement
88
ms.topic: troubleshooting
9-
ms.date: 12/02/2022
9+
ms.date: 07/24/2023
1010
ms.author: jianleishen
1111
ms.custom: has-adal-ref, synapse
1212
---
@@ -28,6 +28,17 @@ This article provides suggestions to troubleshoot common problems with the Mongo
2828

2929
- **Resolution**: In the MongoDB connection string, add the *uuidRepresentation=standard* option. For more information, see [MongoDB connection string](connector-mongodb.md#linked-service-properties).
3030

31+
## Error code: DeprecatedMongoDbOdbcConnector
32+
33+
- **Message**:
34+
`The MongoDB ODBC connector has been deprecated. To ensure continued functionality, please create a new MongoDB linked service. Detailed instructions can be found in this official Microsoft Azure guide: https://learn.microsoft.com/en-us/azure/data-factory/connector-mongodb?tabs=data-factory`
35+
36+
- **Cause**:
37+
If you meet this error message, you need to migrate to a new version of MongoDB linked service.
38+
39+
- **Resolution**:
40+
Refer to this [article](connector-mongodb.md#upgrade-the-mongoDB-linked-service-to-the-latest-version) to upgrade your MongoDB linked service to the latest version.
41+
3142
## Next steps
3243

3344
For more troubleshooting help, try these resources:

0 commit comments

Comments
 (0)