Repository navigation
Decision: emit XSD 1.1 canonical lexical forms #35
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
R2RML lets an implementation choose how a non-string SQL value becomes the lexical form of its natural RDF literal: the canonical XSD representation SHOULD be chosen (Natural Mapping of SQL Values), but "this is not a strict requirement" (Non-String Columns in String Contexts). RDF compares literals by lexical form, so
"12.50"^^xsd:decimaland"12.5"^^xsd:decimalare different terms, and IRIs built from12.50and12.5are different resources.The differential tests (#23) show the engines differ:
CAST(x AS TEXT)):12.50,3.00, and"30"for a double."3.0E1"for xsd:double).3.0). R2RML references XSD 1.1, whosedecimalCanonicalMapwrites an integral value without a decimal point (3).Decision
3.0→3.trim_scale(x)::text(PostgreSQL 13+), which yields the XSD 1.1 canonical decimal.Why not follow Ontop
Following the database's text output would avoid SQL-side canonical expressions, but it still needs per-type conversions (PostgreSQL prints timestamps with a space, booleans as
t/f, bytea as\x..). A query for"12.5"would also miss rows stored as12.50, and results would change with the database. Canonical output keeps results stable and matches the W3C expected outputs, and the remaining SQL-side work is limited to the rare cross-type cases above.References
배경
R2RML은 문자열이 아닌 SQL 값을 natural RDF 리터럴의 lexical form으로 바꾸는 방법을 구현에 맡긴다. canonical XSD 표기를 고르도록 권고(SHOULD)하지만(Natural Mapping of SQL Values), "엄격한 요구 사항은 아니다"라고 밝힌다(Non-String Columns in String Contexts). RDF는 리터럴을 lexical form으로 비교하므로
"12.50"^^xsd:decimal과"12.5"^^xsd:decimal은 다른 term이고,12.50과12.5로 만든 IRI는 서로 다른 자원이다.차등 테스트(#23)에서 엔진마다 결과가 달랐다.
CAST(x AS TEXT))을 쓴다:12.50,3.00, double은"30"."3.0E1").3.0)을 썼다. R2RML이 참조하는 XSD 1.1의decimalCanonicalMap은 정수 값을 소수점 없이(3) 쓴다.결정
3.0→3.trim_scale(x)::text(PostgreSQL 13 이상)를 쓴다.Ontop 방식을 따르지 않는 이유
DB의 text 출력을 따르면 SQL 쪽 canonical 식은 필요 없지만, 타입별 변환은 여전히 필요하다(PostgreSQL은 timestamp를 공백으로, boolean을
t/f로, bytea를\x..로 출력). 또"12.5"로 질의하면12.50으로 저장된 행이 빠지고, DB가 바뀌면 결과도 바뀐다. canonical 출력은 결과를 안정적으로 유지하고 W3C 기대 출력과도 맞으며, 남은 SQL 쪽 작업은 위의 드문 타입 간 비교로 한정된다.참고
All reactions