mkql_block_agg_factory.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "mkql_block_agg_factory.h"
  2. #include "mkql_block_agg_count.h"
  3. #include "mkql_block_agg_sum.h"
  4. #include "mkql_block_agg_minmax.h"
  5. #include "mkql_block_agg_some.h"
  6. #include <yql/essentials/parser/pg_wrapper/interface/arrow.h>
  7. namespace NKikimr {
  8. namespace NMiniKQL {
  9. struct TAggregatorFactories {
  10. THashMap<TString, std::unique_ptr<IBlockAggregatorFactory>> Factories;
  11. TAggregatorFactories()
  12. {
  13. Factories["count_all"] = MakeBlockCountAllFactory();
  14. Factories["count"] = MakeBlockCountFactory();
  15. Factories["sum"] = MakeBlockSumFactory();
  16. Factories["avg"] = MakeBlockAvgFactory();
  17. Factories["min"] = MakeBlockMinFactory();
  18. Factories["max"] = MakeBlockMaxFactory();
  19. Factories["some"] = MakeBlockSomeFactory();
  20. RegisterPgBlockAggs(Factories);
  21. }
  22. };
  23. const IBlockAggregatorFactory& GetBlockAggregatorFactory(TStringBuf name) {
  24. const auto& f = Singleton<TAggregatorFactories>()->Factories;
  25. TStringBuf left, right;
  26. if (name.TrySplit('#', left, right)) {
  27. name = left;
  28. }
  29. auto it = f.find(name);
  30. if (it == f.end()) {
  31. throw yexception() << "Unsupported block aggregation function: " << name;
  32. }
  33. return *it->second;
  34. }
  35. }
  36. }