Skip to content

Commit

Permalink
add description of sparql function translation
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetran committed Jun 12, 2024
1 parent 26c7ac6 commit 968aedd
Showing 1 changed file with 57 additions and 52 deletions.
109 changes: 57 additions & 52 deletions test/fluree/db/query/sparql_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@
{"@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
(testing "function calls"
(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
WHERE {BIND (ABS(1*4*3/-2*(-4/2)) AS ?abs)
BIND (BNODE(?foobar) AS ?bnode)
BIND (BOUND(?abs) AS ?bound)
Expand Down Expand Up @@ -328,57 +333,57 @@
BIND (isURI(?uri) AS ?isUri)
BIND (sameTerm(?str, ?str) AS ?sameTerm)
?person person:age ?age.}"
{:keys [where]} (sparql/->fql query)]
(is (= [[:bind "?abs" "(abs \"(* (/ (* (* 1 4) 3) -2) (/ -4 2))\")"]
[:bind "?bnode" "(bnode ?foobar)"]
[:bind "?bound" "(bound ?abs)"]
[:bind "?ceil" "(ceil \"1.8\")"]
[:bind "?coalesce" "(coalesce ?num1 \"2\")"]
[:bind "?concat" "(concat \"foo\" \"bar\")"]
[:bind "?contains" "(contains \"foobar\" \"foo\")"]
[:bind "?datatype" "(datatype \"foobar\")"]
[:bind "?day" "(day \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?encodeForUri" "(encodeForUri \"Los Angeles\")"]
[:bind "?floor" "(floor \"1.8\")"]
[:bind "?hours" "(hours \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?if" "(if \"true\" \"yes\" \"no\")"]
[:bind "?iri" "(iri \"http://example.com\")"]
[:bind "?lang" "(lang \"Robert\"\"@en\")"]
[:bind "?langMatches" "(langMatches ?lang \"FR\")"]
[:bind "?lcase" "(lcase \"FOO\")"]
[:bind "?md5" "(md5 \"abc\")"]
[:bind "?minutes" "(minutes \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?month" "(month \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?now" "(now)"]
[:bind "?rand" "(rand)"]
[:bind "?round" "(round \"1.8\")"]
[:bind "?seconds" "(seconds \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?sha1" "(sha1 \"abc\")"]
[:bind "?sha256" "(sha256 \"abc\")"]
[:bind "?sha512" "(sha512 \"abc\")"]
[:bind "?str" "(str \"foobar\")"]
[:bind "?strAfter" "(strAfter \"abc\" \"b\")"]
[:bind "?strBefore" "(strBefore \"abc\" \"b\")"]
[:bind "?strDt" "(strDt \"iiii\" \"http://example.com/romanNumeral\")"]
[:bind "?strEnds" "(strEnds \"foobar\" \"bar\")"]
[:bind "?strLang" "(strLang \"chat\" \"en\")"]
[:bind "?strLen" "(strLen \"chat\")"]
[:bind "?strStarts" "(strStarts \"foobar\" \"foo\")"]
[:bind "?struuid" "(struuid)"]
[:bind "?timezone" "(timezone \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?tz" "(tz \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?ucase" "(ucase \"foobar\")"]
[:bind "?uri" "(uri \"http://example.com\")"]
[:bind "?uuid" "(uuid)"]
[:bind "?year" "(year \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?isBlank" "(isBlank ?bnode)"]
[:bind "?isIri" "(isIri ?iri)"]
[:bind "?isLiteral" "(isLiteral \"foobar\")"]
[:bind "?isNumeric" "(isNumeric \"5\")"]
[:bind "?isUri" "(isUri ?uri)"]
[:bind "?sameTerm" "(sameTerm ?str ?str)"]
{"@id" "?person", "person:age" "?age"}]
where)))))
{:keys [where]} (sparql/->fql query)]
(is (= [[:bind "?abs" "(abs \"(* (/ (* (* 1 4) 3) -2) (/ -4 2))\")"]
[:bind "?bnode" "(bnode ?foobar)"]
[:bind "?bound" "(bound ?abs)"]
[:bind "?ceil" "(ceil \"1.8\")"]
[:bind "?coalesce" "(coalesce ?num1 \"2\")"]
[:bind "?concat" "(concat \"foo\" \"bar\")"]
[:bind "?contains" "(contains \"foobar\" \"foo\")"]
[:bind "?datatype" "(datatype \"foobar\")"]
[:bind "?day" "(day \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?encodeForUri" "(encodeForUri \"Los Angeles\")"]
[:bind "?floor" "(floor \"1.8\")"]
[:bind "?hours" "(hours \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?if" "(if \"true\" \"yes\" \"no\")"]
[:bind "?iri" "(iri \"http://example.com\")"]
[:bind "?lang" "(lang \"Robert\"\"@en\")"]
[:bind "?langMatches" "(langMatches ?lang \"FR\")"]
[:bind "?lcase" "(lcase \"FOO\")"]
[:bind "?md5" "(md5 \"abc\")"]
[:bind "?minutes" "(minutes \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?month" "(month \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?now" "(now)"]
[:bind "?rand" "(rand)"]
[:bind "?round" "(round \"1.8\")"]
[:bind "?seconds" "(seconds \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?sha1" "(sha1 \"abc\")"]
[:bind "?sha256" "(sha256 \"abc\")"]
[:bind "?sha512" "(sha512 \"abc\")"]
[:bind "?str" "(str \"foobar\")"]
[:bind "?strAfter" "(strAfter \"abc\" \"b\")"]
[:bind "?strBefore" "(strBefore \"abc\" \"b\")"]
[:bind "?strDt" "(strDt \"iiii\" \"http://example.com/romanNumeral\")"]
[:bind "?strEnds" "(strEnds \"foobar\" \"bar\")"]
[:bind "?strLang" "(strLang \"chat\" \"en\")"]
[:bind "?strLen" "(strLen \"chat\")"]
[:bind "?strStarts" "(strStarts \"foobar\" \"foo\")"]
[:bind "?struuid" "(struuid)"]
[:bind "?timezone" "(timezone \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?tz" "(tz \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?ucase" "(ucase \"foobar\")"]
[:bind "?uri" "(uri \"http://example.com\")"]
[:bind "?uuid" "(uuid)"]
[:bind "?year" "(year \"2024-4-1T14:45:13.815-05:00\")"]
[:bind "?isBlank" "(isBlank ?bnode)"]
[:bind "?isIri" "(isIri ?iri)"]
[:bind "?isLiteral" "(isLiteral \"foobar\")"]
[:bind "?isNumeric" "(isNumeric \"5\")"]
[:bind "?isUri" "(isUri ?uri)"]
[:bind "?sameTerm" "(sameTerm ?str ?str)"]
{"@id" "?person", "person:age" "?age"}]
where))))))

(deftest parse-prefixes
(testing "PREFIX"
Expand Down

0 comments on commit 968aedd

Please sign in to comment.