Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order by aggregate #76

Merged
merged 4 commits into from Jul 30, 2018
Merged

Conversation

floriankramer
Copy link
Member

This pr renames has-relation to has-predicate both when parsing sparql queries as well as in the code (e.g. in HasRelationScan which is now HasPredicateScan).
All index functions that require a loaded patterns file now throw an exception if no patterns file was loaded.
Aggregate aliases can now be used inside the ORDER BY clause without having to be selected, as the sparql standard demands.

- num_cols: 1
# -num_rows: 5295 # greater than current limit
- selected: ["?place"]
- res: [["<United_States_of_America>"]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 nice trick to test for ordering, I think we really should add an order check function to queryit.py. I guess to support diferent types we could just make that explicit in the checks name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now implemented in PR #77

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After trying to use the new order checks for this I realized that the e2e testing framework doesn't actually have the data it needs to check the ordering, as that is not selected and thus never returned by the server. As a still somewhat hackish solution I also added the aggregates to the select part of the query, with a different result variable name, which the e2e testing framework can then use to check the order.

for (size_t i = 0; i < _orderBy.size(); i++) {
OrderKey& key = _orderBy[i];
if (key._key[0] == '(') {
std::string inner = key._key.substr(1, key._key.size() - 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment why - 2?

@@ -110,6 +110,14 @@ inline vector<string> split(const string& orig, const char sep);
//! Splits a string at any maximum length sequence of whitespace
inline vector<string> splitWs(const string& orig);

//! Splits a string at any maximum length sequence of whitespace, ignoring
//! whitespace withing an escaped sequence. Left char begins an escaped
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "withing"

TEST(StringUtilsTest, splitWsWithEscape) {
setlocale(LC_CTYPE, "");
string s1 = " a1 \t (this is() one) two (\t\na)()";
auto v1 = splitWsWithEscape(s1, '(', ')');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only tests the left != right case not the left == right one.

pos++;
}
// avoid adding whitespace at the back of the string
// if (!::isspace(static_cast<unsigned char>(orig[orig.size() - 1]))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

?x <Place_of_birth> ?place .
}
GROUP BY ?place
ORDER BY DESC((COUNT(?x) as ?count))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also test another aggregate like AVG?

Copy link
Member

@niklas88 niklas88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants