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

Feature/sparql func #778

Merged
merged 74 commits into from
Jun 17, 2024
Merged

Feature/sparql func #778

merged 74 commits into from
Jun 17, 2024

Conversation

dpetran
Copy link
Contributor

@dpetran dpetran commented May 20, 2024

No description provided.

@dpetran dpetran marked this pull request as ready for review May 21, 2024 20:00
@dpetran dpetran requested a review from a team May 21, 2024 20:00
@dpetran
Copy link
Contributor Author

dpetran commented May 31, 2024

Rebased on #769

This was referenced May 31, 2024
Copy link
Member

@cap10morgan cap10morgan left a comment

Choose a reason for hiding this comment

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

Looks good overall. I have some test organization and description suggestions.

"person:birthday"
{"@value" "2011-01-10T14:45:13.815-05:00", "@type" "xsd:dateTime"}}]
where)
"datatype literal")))
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to move these into their own descriptive testing form. They're moving away from "simple triple" :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "simple triple" refers more to the grammar classification of this type of expression. These test cases just confirm that all the different types of RDF literal terms are translated correctly.

@@ -333,6 +457,14 @@
{:keys [groupBy]} (sparql/->fql query)]
(is (= ["?person" "?handle"]
groupBy))))
(testing "mutiple HAVING constraints"
Copy link
Member

Choose a reason for hiding this comment

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

missing the first "l" in "multiple"

@@ -254,11 +268,109 @@
[:bind "?num1" "(* (/ (* (* ?age 4) 3) -2) (/ -4 2))"]
{"@id" "?person", "person:handle" "?handle"}
{"@id" "?person", "person:age" "?age"}]
where)))
(let [query "SELECT ?person ?abs ?bnode ?bound ?ceil ?coalesce ?concat ?contains ?datatype ?day ?encodeForUri ?floor ?hours ?if ?iri ?lang ?langMatches ?lcase ?md5 ?minutes ?month ?now ?rand ?round ?seconds ?sha1 ?sha256 ?sha512 ?str ?strAfter ?strBefore ?strDt ?strEnds ?strLang ?strLen ?strStarts ?struuid ?timezone ?tz ?ucase ?uri ?uuid ?year ?isBlank ?isIri ?isLiteral ?isNumeric ?isUri ?sameTerm
Copy link
Member

Choose a reason for hiding this comment

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

Would this benefit from a testing form w/ a description? Or is it just "test lots of binds"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is testing that the grammar and translation for all the different SPARQL functions works correctly. I'll add a testing expression for it : )

dpetran and others added 19 commits June 12, 2024 15:40
The tricky part is deciding when to `literal-quote` one or more of the args. Since that
information does not exist in the parse tree at the point where :Func needs parsing, we
need to figure out whether to quote based on the signature of the function, according to
the SPARQL spec: https://www.w3.org/TR/sparql11-query/#SparqlOps and the SPARQL grammar.

This way is more repetitive but more robust. Once we've got all the functions covered we
can search for abstractions to reduce verbosity.
I'm not sure where the LANGTAG regex came from, but it didn't match the one in the spec
- it required the hyphen (-) between two-part lang tags of the style `@en-us`, but
disallowed the simple verson `@en`. Now it correctly accepts both.
JaceRockman and others added 21 commits June 12, 2024 16:53
The grammar wasn't expecting whitespace between the 'a' and the prev/next term.
Semantics and syntax from SPARQL IN expression.
It's not sparql-specific, so no need to qualify it.
The :Expression parser was turning everything into a string, which works in some cases
but introduces unwanted quoting in others. By deferring stringification until values
need to be incorporated into an actual string expression we avoid the unwanted quoting.

Do note that all the numeric functions now correctly expect numeric values instead of
strings.
abs expects only a single expression as an argument, and that argument does not need to
be quoted.
translate SPARQL IN/NOT IN expresssions into FQL
translate SPARQL EXISTS/NOT EXISTS filters into FQL
@dpetran dpetran merged commit dee6c88 into feature/sparql-values Jun 17, 2024
3 of 6 checks passed
@dpetran dpetran deleted the feature/sparql-func branch June 17, 2024 17:43
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