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

BIND for Constants and variable renaming. #332

Merged
merged 4 commits into from Apr 7, 2021
Merged

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Apr 26, 2020

Implemented BIND( as ?variable) and BIND(?variable as ?otherVariable).

  • There also is a stub for BIND( + ?else as ?sum), but that is not yet fully integrated ye

@joka921 joka921 changed the title F.as BIND for Constants and variable renaming. Apr 26, 2020
@hannahbast
Copy link
Member

hannahbast commented Apr 29, 2020

I just stumbled upon the following bug. The following query crashes any backend. It does not matter what the triple is. What matters is the combination of an aggregation over a non-existing variable and a BIND, though I don't understand why that matters):

SELECT ?x WHERE {
  { SELECT ?x (COUNT(?z) AS ?count) WHERE { ?x <bla> <blu> } GROUP BY ?x }
  BIND(?x AS ?whatever)
}

The last line in the log before the crash is:

Wed Apr 29 18:11:22.766	- DEBUG: Sort result computation...

@joka921 joka921 requested review from floriankramer, niklas88 and hannahbast and removed request for floriankramer July 30, 2020 16:01
src/engine/Bind.cpp Outdated Show resolved Hide resolved
Copy link
Member

@floriankramer floriankramer left a comment

Choose a reason for hiding this comment

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

It's been a while since I worked with QLever, so I might have missed some things, but overall this looks good to me. Unit tests and a toString for the bind grapg pattern are still missing though.

src/engine/Bind.cpp Outdated Show resolved Hide resolved
src/parser/ParsedQuery.cpp Show resolved Hide resolved
@joka921 joka921 force-pushed the f.AS branch 2 times, most recently from f3cba88 to 17b7ff6 Compare March 22, 2021 12:18
- BIND(?x as ?y)
- BIND(<entity> as ?x) (entity must be contained in KB)
- BIND("literal" as ?x) literal must be contained in KB)
- BIND(42 AS ?x) (only positive integers)
- BIND (?x + ?y as ?sum) (sum of exactly two variables).

- Technically this includes a new BIND operation, as well as changes in the parser and the Query Planner to be able to use this operation.
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

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

Pass in a 1-1 code review of Hannah and Johannes. Reviewed everything in detail, except the (non-trivial) changes in QueryPlanner.cpp

src/parser/ParsedQuery.h Show resolved Hide resolved
src/parser/ParsedQuery.h Outdated Show resolved Hide resolved
src/parser/ParsedQuery.h Outdated Show resolved Hide resolved
src/parser/ParsedQuery.h Outdated Show resolved Hide resolved
src/parser/ParsedQuery.h Outdated Show resolved Hide resolved
src/engine/Bind.cpp Outdated Show resolved Hide resolved
src/parser/SparqlParser.cpp Show resolved Hide resolved
src/parser/SparqlParser.cpp Show resolved Hide resolved
src/parser/SparqlParser.cpp Show resolved Hide resolved
test/BindTest.cpp Show resolved Hide resolved
Copy link
Member Author

@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.

don't know how to cancel reviews...

Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

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

Also reviewed the missing QueryPlanner.cpp in a 1-1 with Johannes.

src/engine/Bind.cpp Show resolved Hide resolved
src/engine/Bind.h Show resolved Hide resolved
src/parser/ParsedQuery.h Outdated Show resolved Hide resolved
src/engine/QueryPlanner.cpp Outdated Show resolved Hide resolved
src/engine/QueryPlanner.cpp Outdated Show resolved Hide resolved
src/engine/QueryPlanner.cpp Show resolved Hide resolved
src/engine/QueryPlanner.cpp Outdated Show resolved Hide resolved
src/engine/QueryPlanner.cpp Outdated Show resolved Hide resolved
src/engine/QueryPlanner.cpp Outdated Show resolved Hide resolved
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

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

Looks great, thank you very much. I guess the small code duplication for the pattern trick check (QueryPlanner.cpp lines 561-568 and lines 624-631) has historical reasons and can be fixed when QueryPlanner::optimize gets a major overhaul.

@joka921 joka921 merged commit d060088 into ad-freiburg:master Apr 7, 2021
@joka921 joka921 deleted the f.AS branch April 7, 2021 15:30
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

3 participants