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

Correct datatype and language tag for the result of SUBSTR #1636

Merged

Conversation

DuDaAG
Copy link
Contributor

@DuDaAG DuDaAG commented Nov 22, 2024

If the input string of the SUBSTR function has a language tag, then according to the SPARQL standard the result has to preserve this language tag. Same goes if the datatype of the string is xsd:string. This PR implements this behavior (previously the language tag and datatype were always dropped) and implements all the infrastructure to implement this behavior also for other expressions that take and return strings.

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 94.92754% with 7 lines in your changes missing coverage. Please review.

Project coverage is 90.61%. Comparing base (635c288) to head (a0beee6).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/engine/ExportQueryExecutionTrees.cpp 88.88% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1636    +/-   ##
========================================
  Coverage   90.60%   90.61%            
========================================
  Files         405      405            
  Lines       39732    39903   +171     
  Branches     4488     4509    +21     
========================================
+ Hits        36001    36157   +156     
- Misses       2397     2405     +8     
- Partials     1334     1341     +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joka921
Copy link
Member

joka921 commented Nov 22, 2024

Hi, You can above click at Files changed, then you get the changed files (by default from all commits, which is fine for what you want), then you can select rows and attach comments to those. Make sure to finish your(self-review) if the comments are marked as "pending", because otherwise we cannot see them.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

A first round on everything but the tests.
Work on my comments, and contact me once you are done or are left with questions.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Another round of reviews, this is really improving.
Make sure that the continuous integration runs through (in particular no warnings in the code + formatting etc.)

@DuDaAG DuDaAG force-pushed the Correct-Datatypes-for-StringExpressions branch from 40511b3 to 7455f29 Compare January 6, 2025 11:15
Copy link

sonarqubecloud bot commented Jan 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
5.7% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Some additional comments.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

A pass on everything but the tests,
This looks really nice except for the one bug.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

I like this much better,
One and a half additional rounds or so and we can merge this.
Let me know if you have additional questions.

AD_CORRECTNESS_CHECK(iriString.ends_with('>'));
iriString[0] = '"';
iriString[iriString.size() - 1] = '"';
return iriString;
Copy link
Member

Choose a reason for hiding this comment

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

The result variable is never used.
What about taking the isiString just as a muytable reference
(void replaceAngle(string& iriString))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I implement this, I get the following error message:
error: cannot bind non-const lvalue reference of type ‘std::string&’ {aka ‘std::__cxx11::basic_string&’} to an rvalue of type ‘std::remove_reference<std::__cxx11::basic_string&>::type’ {aka ‘std::__cxx11::basic_string’}
397 | std::move(word.getIri().toStringRepresentation())));
Does this mean that the I have to work with a copy either in replaceAngle or in handleIriOrLiteral?

Copy link
Member

Choose a reason for hiding this comment

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

If an argument is a non-const lvalue-reference like std::string& you can not assign a temporary or the result of std::move() (an rvalue reference) to this parameter. It would also be pointless, because you would mutate something in place, that is then discarded. With the reference you would have to do something like

auto str = std::move(w.Iri.toStringRepr());
replaceAngles(str);
auto Iri = Iri::fromStringRepr(std::move(str))

Whichy at second glance is ugly and doesn't really save anything here, so we just leav your original version.

Copy link
Member

Choose a reason for hiding this comment

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

The mutable reference would be a better interface for the abstract interface of the class, but not for its only usage here:)

Annika Greif added 2 commits March 24, 2025 18:14
Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Thank you very much,
This looks great now.

Signed-off-by: Johannes Kalmbach <[email protected]>
@sparql-conformance
Copy link

Conformance check passed ✅

Test Status Changes 📊

Number of Tests Previous Status Current Status
2 Failed Intended

Details: https://qlever.cs.uni-freiburg.de/sparql-conformance-ui?cur=a0beee6d8fbea64eab7f8527778764107c78f53e&prev=54e9f8b562628982a1e07e418ac05070a66bffaa

@joka921 joka921 changed the title Correct datatypes for string expressions Correct datatype and language tag for the result of SUBSTR Mar 25, 2025
@joka921 joka921 merged commit 707f5e7 into ad-freiburg:master Mar 25, 2025
24 checks passed
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.

2 participants