Repository navigation
Decision: compare query constants as RDF terms and check them before binding #21
CharmingGroot
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Background
A SPARQL constant has to reach PostgreSQL somehow, and the two obvious ways both go wrong in different places.
$1,'99999999999'fails with "out of range" and'7.0'with "invalid input syntax", and'007'or'+7'are accepted as 7, none of which is SPARQL behaviour.Comparing with Ontop on the same mapping and data (10 queries) also showed three gaps in the first implementation: literal datatypes were not checked (
"4"and"4"^^xsd:decimalmatched an integer column), one unmatchable constant emptied the whole query including unrelated UNION branches, and for date, timestamp, uuid, bytea and interval columns PostgreSQL parsed the constant (invalid values raised errors, non-canonical forms such as2024-2-29matched).Decision
7.0,"7"and"7"^^xsd:decimaldo not match an integer column holding 7;<…/asset/007>does not match the templateasset/{id}. This matches Ontop's results.1.10→1.1).One-Time Filter: false); if every branch is empty, no SQL is sent.col::text = $n, the same conversion used to build their result terms.id = 7.0andid::text = '7'lose the index whileid = '7'::int4keeps it.References
배경
SPARQL 상수는 어떤 식으로든 PostgreSQL에 전달해야 하는데, 흔한 두 방법은 서로 다른 곳에서 문제가 생긴다.
$1에'99999999999'는 "out of range",'7.0'은 "invalid input syntax" 오류가 나고,'007','+7'은 7로 받아들인다. 모두 SPARQL의 동작이 아니다.같은 매핑과 데이터로 Ontop과 비교한 결과(질의 10개), 첫 구현에는 문제가 세 가지 더 있었다. 리터럴 datatype을 검사하지 않아
"4"와"4"^^xsd:decimal이 integer 컬럼과 일치했고, 일치할 수 없는 상수 하나가 상관없는 UNION 가지까지 질의 전체를 비웠고, date, timestamp, uuid, bytea, interval 컬럼에서는 PostgreSQL이 상수를 해석해 잘못된 값은 오류가,2024-2-29같은 비정규 표기는 일치가 났다.결정
7.0,"7","7"^^xsd:decimal과 일치하지 않고,<…/asset/007>은 템플릿asset/{id}와 일치하지 않는다. Ontop의 결과와 같다.1.10→1.1).One-Time Filter: false), 모든 가지가 비면 SQL을 보내지 않는다.col::text = $n으로 비교한다.id = 7.0과id::text = '7'은 인덱스를 못 쓰고id = '7'::int4는 쓰기 때문이다.참고
All reactions