我在 Azure Functions 上使用 DocumentDB 输入绑定。
今天,我将以下查询指定为 sqlQuery。
SELECT c.id, c.created_at FROM c
WHERE {epoch} - c.created_at_epoch >= 86400*31
AND (CEILING({epoch}/86400) - CEILING(c.created_at_epoch / 86400)) % 31 = 0
之后,我在触发函数时看到以下错误。
2017-07-04T10:31:44.873 Function started (Id=95a2ab7a-8eb8-4568-b314-2c3b04a0eadf)
2017-07-04T10:31:49.544 Function completed (Failure, Id=95a2ab7a-8eb8-4568-b314-2c3b04a0eadf, Duration=4681ms)
2017-07-04T10:31:50.106 Exception while executing function: Functions.Bonus. Microsoft.Azure.WebJobs.Host: The '%' at position 148 does not have a closing '%'.
我想在 sqlQuery 中使用调制符号。我能做什么?
此致。
2017-07-15(JST) 附录。
今天,我尝试遵循另一个查询来避免这个问题。
SELECT c.id, c.created_at FROM c
WHERE {epoch} - c.created_at_epoch >= 86400*31 AND
(CEILING({epoch}/86400) - CEILING(c.created_at_epoch / 86400)) -
(31 *
CEILING(
(CEILING({epoch}/86400) - CEILING(c.created_at_epoch / 86400))
/ 31
)
) = 0
以防万一,我尝试了在 Cosmos DB 上指定 epoch = 1499218423 的查询。
SELECT c.id, c.created_at FROM c
WHERE 1499218423 - c.created_at_epoch >= 86400*31 AND
(CEILING(1499218423/86400) - CEILING(c.created_at_epoch / 86400)) -
(31 *
CEILING(
(CEILING(1499218423/86400) - CEILING(c.created_at_epoch / 86400))
/ 31
)
) = 0
结果如下。
[
{
"id": "70251cbf-44b3-4cd9-991f-81127ad78bca",
"created_at": "2017-05-11 18:46:16"
},
{
"id": "0fa31de2-4832-49ea-a0c6-b517d64ede85",
"created_at": "2017-05-11 18:48:22"
},
{
"id": "b9959d15-92e7-41c3-8eff-718c4ab2be6e",
"created_at": "2017-05-11 19:01:43"
}
]
看起来不错。然后我将其指定为 sqlQuery 并使用以下队列数据进行测试。
{"epoch":1499218423}
该函数的代码如下。
module.exports = function (context, myQueueItem) {
context.log(context.bindings.members, myQueueItem);
context.done();
};
之后,我看到了以下结果。
2017-07-05T03:00:47.158 Function started (Id=e4d060b5-3ddc-4271-bf91-9f314e7e1148)
2017-07-05T03:00:47.408 [] { epoch: 1499871600 }
2017-07-05T03:00:47.408 Function completed (Success, Id=e4d060b5-3ddc-4271-bf91-9f314e7e1148, Duration=245ms)
它看起来绑定结果存在差异(如 context.bindings.members)。
为什么会出现这种差异呢?
相关问题:Azure Cosmos DB 查询资源管理器的结果与 Azure Functions 结果之间的差异 https://stackoverflow.com/questions/44916811/deferences-among-the-azure-cosmosdb-query-explorers-results-and-the-azure-funct