I'm trying to migrate data from SQL DB using CosmosDB Data Migration Tool and I successfully migrated data from SQL DB but the result is all values are string
Wondering if there's a way to convert those JSON to Object during migration process?
Here's my sample Query
select
json_value(Data, '$.timestamp') as timestamp,
json_query(Data, '$.Product.detail') as [Product.detail],
json_value(Data, '$.Product.price') as [Product.price]
from myTable
nesting seperator: .
One option is to export your SQL data to a plain CSV file, do any reformatting with your favorite tool, and import the cleaned CSV or JSON file using the Cosmos migration tool.
With PowerShell, for example, the process could be:
1.create a dataflow and use SQL DB as source.
2.In source option choose Query
:
SQL:
select
json_value(Data, '$.timestamp') as timestamp,
json_query(Data, '$.Product.detail') as [Product.detail],
json_value(Data, '$.Product.price') as [Product.price]
from test3
3.create a DerivedColumn
,and change type of column.Expression of Product
:
@(detail=split(replace(replace(replace(byName('Product.detail'),'[',''),']',''),'"',''),','),
price=toDouble(byName('Product.price')))
4.choose Cosmos DB as sink and mapping like this:
5.create a pipeline and add the dataflow you created before,then click debug button or add trigger to execute it.
6.result:
{
"Product": {
"price": 300.56,
"detail": [
"eee",
"fff"
]
},
"id": "d9c66062-63ce-4b64-8bbe-95dcbdcad16d",
"timestamp": 1600329425
}
Update:
You can enable the Data flow debug button, and see the result of expression in Data preview.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.