aggregation

Camel condition on aggregate of messages

回眸只為那壹抹淺笑 提交于 2021-01-28 10:31:54
问题 I'm looking for a way to conditionally handle messages based on the aggregation of messages. I've looked into a lot of ways to do this, but it seems that Apache Camel doesn't support it. I'll explain the scenario and then the solutions I tried. Scenario: I'm trying to conditionally clean a directory. I poll from the directory every x days and fetch all the files (file://...). I route this into an aggregation, that aggregates the files into a single size (directorySize). I then check if this

How do I enforce ordering (ORDER BY) in a custom Presto Aggregation Function

筅森魡賤 提交于 2021-01-28 01:45:34
问题 I am writing a custom Presto Aggregation Function that produces the correct result if (and only if) the values are ordered in ascending order by the value that I am aggregating on. i.e. The following will work: SELECT key, MY_AGG_FUNC(value ORDER BY value ASC) FROM my_table GROUP BY key The following will yield an incorrect result: SELECT key, MY_AGG_FUNC(value) FROM my_table GROUP BY key When developing the MY_AGG_FUNC , is there a way to enforce ORDER BY value ASC internally without relying

How to retrieve each single array element from mongo pipeline?

余生长醉 提交于 2021-01-28 00:44:34
问题 Let's assume that this is how a sample document looks like in mongo-db, [ { "_id": "1", "attrib_1": "value_1", "attrib_2": "value_2", "months": { "2": { "month": "2", "year": "2008", "transactions": [ { "field_1": "val_1", "field_2": "val_2", }, { "field_1": "val_4", "field_2": "val_5", "field_3": "val_6" }, ] }, "3": { "month": "3", "year": "2018", "transactions": [ { "field_1": "val_7", "field_3": "val_9" }, { "field_1": "val_10", "field_2": "val_11", }, ] }, } } ] The desired output is

Why should not disable ONLY_FULL_GROUP_BY

安稳与你 提交于 2020-12-13 05:56:57
问题 During internet searching I see lot of questions now to disable ONLY_FULL_GROUP_BY feature, so it mean lot of developers have a trouble with writing SQL queries in this strict mode. I know it pretty simple to disable this limitation, but now I ask asking: Why shouldn't I do this? What problems or side effects will be involved by removing ONLY_FULL_GROUP_BY limitation? 回答1: Without the strictness that ONLY_FULL_GROUP_BY enforces, you may: not realize you have the wrong query; be getting some

Get all possible combinations from array in MongoDB aggregation 🚀

血红的双手。 提交于 2020-12-06 16:22:58
问题 How to do aggregation ( $group ) by the same values ​​from the array? Not all at once, but few or all, if any. I can do $group by one word, but I also need all possible variations... Collection example: {"keywords": ["gta", "distribution", "keys"]} {"keywords": ["gta", "online", "moto", "races"]} {"keywords": ["gta", "online", "samp"]} Result example: "gta" - 3 matches "online" - 2 matches "gta online" - 2 matches 回答1: You could use $reduce to extract all combinations of pairs from an array.

Get all possible combinations from array in MongoDB aggregation 🚀

此生再无相见时 提交于 2020-12-06 16:18:09
问题 How to do aggregation ( $group ) by the same values ​​from the array? Not all at once, but few or all, if any. I can do $group by one word, but I also need all possible variations... Collection example: {"keywords": ["gta", "distribution", "keys"]} {"keywords": ["gta", "online", "moto", "races"]} {"keywords": ["gta", "online", "samp"]} Result example: "gta" - 3 matches "online" - 2 matches "gta online" - 2 matches 回答1: You could use $reduce to extract all combinations of pairs from an array.

Sum amount last 6 month prior to the date of transaction

一个人想着一个人 提交于 2020-11-24 16:17:34
问题 This is my transaction data. It shows the transactions made from the accounts in from column to the accounts in to column with the date and the amount information data id from to date amount <int> <fctr> <fctr> <date> <dbl> 19521 6644 6934 2005-01-01 700.0 19524 6753 8456 2005-01-01 600.0 19523 9242 9333 2005-01-01 1000.0 … … … … … 1056317 7819 7454 2010-12-31 60.2 1056318 6164 7497 2010-12-31 107.5 1056319 7533 7492 2010-12-31 164.1 I want to calculate how much transaction amount the

Sum amount last 6 month prior to the date of transaction

微笑、不失礼 提交于 2020-11-24 16:10:58
问题 This is my transaction data. It shows the transactions made from the accounts in from column to the accounts in to column with the date and the amount information data id from to date amount <int> <fctr> <fctr> <date> <dbl> 19521 6644 6934 2005-01-01 700.0 19524 6753 8456 2005-01-01 600.0 19523 9242 9333 2005-01-01 1000.0 … … … … … 1056317 7819 7454 2010-12-31 60.2 1056318 6164 7497 2010-12-31 107.5 1056319 7533 7492 2010-12-31 164.1 I want to calculate how much transaction amount the

Sum amount last 6 month prior to the date of transaction

断了今生、忘了曾经 提交于 2020-11-24 16:10:48
问题 This is my transaction data. It shows the transactions made from the accounts in from column to the accounts in to column with the date and the amount information data id from to date amount <int> <fctr> <fctr> <date> <dbl> 19521 6644 6934 2005-01-01 700.0 19524 6753 8456 2005-01-01 600.0 19523 9242 9333 2005-01-01 1000.0 … … … … … 1056317 7819 7454 2010-12-31 60.2 1056318 6164 7497 2010-12-31 107.5 1056319 7533 7492 2010-12-31 164.1 I want to calculate how much transaction amount the

Sum amount last 6 month prior to the date of transaction

 ̄綄美尐妖づ 提交于 2020-11-24 16:10:27
问题 This is my transaction data. It shows the transactions made from the accounts in from column to the accounts in to column with the date and the amount information data id from to date amount <int> <fctr> <fctr> <date> <dbl> 19521 6644 6934 2005-01-01 700.0 19524 6753 8456 2005-01-01 600.0 19523 9242 9333 2005-01-01 1000.0 … … … … … 1056317 7819 7454 2010-12-31 60.2 1056318 6164 7497 2010-12-31 107.5 1056319 7533 7492 2010-12-31 164.1 I want to calculate how much transaction amount the