Azure数据工厂:查询CosmosDB源中的_ts(历元)字段

Azure数据工厂:查询CosmosDB源中的_ts(历元)字段,azure,azure-cosmosdb,datetime-format,epoch,azure-data-factory,Azure,Azure Cosmosdb,Datetime Format,Epoch,Azure Data Factory,我正在尝试将数据从Azure CosmosDB复制到Azure SQL数据库中 在Azure CosmosDB源中,查询如下所示: select * from c where c.DefinitionTime >= '@{formatDateTime(pipeline().parameters.windowStart, 'yyyy-MM-ddTHH:mm:ssZ' )}' AND c.DefinitionTime < '@{formatDateTime(pipeline().para

我正在尝试将数据从Azure CosmosDB复制到Azure SQL数据库中

在Azure CosmosDB源中,查询如下所示:

select * from c where c.DefinitionTime >= '@{formatDateTime(pipeline().parameters.windowStart, 'yyyy-MM-ddTHH:mm:ssZ' )}' AND c.DefinitionTime < '@{formatDateTime(pipeline().parameters.windowEnd, 'yyyy-MM-ddTHH:mm:ssZ' )}'
select*from c,其中c.DefinitionTime>='{formatDateTime(pipeline().parameters.windowStart,'yyyy-MM-ddTHH:MM:ssZ')和c.DefinitionTime<'{formatDateTime(pipeline().parameters.windowEnd,'yyy-MM-ddTHH:MM:ssZ')
在CosmosDB中,“定义时间”存储为字符串。要运行上述查询,我必须使用范围索引更新“DefinitionTime”,这是一种可能的解决方案

另一种可能的解决方案是使用所有CosmosDB文档中可用的_ts字段_ts表示文档在纪元时间创建或上次更新的时间

所以基本上问题是如何将
pipeline().parameters.windowStart
转换为epoch time。“formatDateTime”函数中采用格式的第二个参数似乎没有一种要求使用历元格式的方法。此外,没有办法通过datetime算法手动转换为历元


IMO,由于没有内置的支持将历元转换为日期时间,因此使用“定义时间”的范围索引将是最干净的解决方案。