Skip to content

Commit

Permalink
small fix for the inherently wrong and troublesom id-float conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed May 8, 2020
1 parent 43e5d92 commit 5145e52
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/engine/GroupBy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,24 @@ void GroupBy::setSubtree(std::shared_ptr<QueryExecutionTree> subtree) {
}

string GroupBy::asString(size_t indent) const {
const auto varMap = getVariableColumns();
const auto varMapInput = _subtree->getVariableColumns();
std::ostringstream os;
for (size_t i = 0; i < indent; ++i) {
os << " ";
}
os << "GROUP_BY ";
for (const std::string var : _groupByVariables) {
os << var << ", ";
os << varMap.at(var) << ", ";
}
for (auto p : _aliases) {
os << p._function << ", ";

os << ParsedQuery::AggregateTypeAsString(p._type);
if (p._type == ParsedQuery::AggregateType::GROUP_CONCAT) {
os << p._delimiter;
}

os << ' ' << varMapInput.at(p._inVarName) << ' ' << varMap.at(p._outVarName);
}
os << std::endl;
os << _subtree->asString(indent);
Expand Down
2 changes: 1 addition & 1 deletion src/index/StringSortComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class LocaleManager {
int32_t i = 0;
for (i = 0; i < length && numCodepoints < prefixLength;) {
UChar32 c;
U8_NEXT(s, i, length, c)
U8_NEXT(s, i, length, c);
if (c >= 0) {
++numCodepoints;
} else {
Expand Down
26 changes: 26 additions & 0 deletions src/parser/ParsedQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../util/HashMap.h"
#include "../util/StringUtils.h"
#include "ParseException.h"
#include "../util/Exception.h"

using std::string;
using std::vector;
Expand Down Expand Up @@ -263,6 +264,31 @@ class ParsedQuery {
AVG
};

static std::string AggregateTypeAsString(AggregateType t) {
switch(t) {
case AggregateType::COUNT:
return "COUNT";
case AggregateType::GROUP_CONCAT:
return "GROUP_CONCAT";
case AggregateType::FIRST:
return "FIRST";
case AggregateType::LAST:
return "LAST";
case AggregateType::SAMPLE:
return "SAMPLE";
case AggregateType::MIN:
return "MIN";
case AggregateType::MAX:
return "MAX";
case AggregateType::SUM:
return "SUM";
case AggregateType::AVG:
return "AVG";
default:
AD_THROW(ad_semsearch::Exception::CHECK_FAILED, "Illegal/unimplemented enum value in AggregateTyppeAsString. Should never happen, please report this");
}
}

struct Alias {
AggregateType _type;
string _inVarName;
Expand Down

0 comments on commit 5145e52

Please sign in to comment.