Repository navigation
Decision: resolve relative IRIs against a configured base IRI, with no default #48
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 term map with
rr:termType rr:IRIcan produce a relative IRI: a column holdingCarlos, a template{"Name"}overBob, orperson/{id}. The engine reported every such value as a data error, so the W3C test R2RMLTC0020a differed from Ontop and R2RMLTC0019a was skipped (#33).What the specifications say:
?or#, and should end in/. The term generation rules use simple string concatenation, not the resolution algorithm of RFC 3986 §5.2, so that the database value can be reconstructed from the IRI; the two agree only when the base has no?/#and ends in/, and the relative IRI does not start with/and has no.or..segments.rr:IRI: take the natural RDF lexical form; if it is a valid absolute IRI, that is the IRI; otherwise prepend the base IRI, and if the result is a valid absolute IRI, that is the IRI; otherwise raise a data error.iunreservedpercent-encoded as UTF-8) before any of this, soBob/CharlesgivesBob%2FCharles.rr:IRIthat generates an invalid IRI is a data error; an operation that has to return such a term must fail.<http://example.com/base/>". R2RMLTC0019a expects<http://example.com/ns#Jhon>and<http://example.com/base/Carlos>from a column; R2RMLTC0020a expects<http://example.com/base/Bob%2FCharles>,<http://example.com/base/path%2F..%2FDanny>and<http://example.com/base/http%3A%2F%2Fexample.com%2Fcompany%2FAlice>from{"Name"}.Ontop 5.5.0 (from its bytecode and runs in testenv):
R2RMLToSQLPPTriplesMapConverteruses the constanthttp://example.com/base/. When the text of a template before its first{is not an absolute IRI, that constant is put in front of the template while the mapping is loaded. Column values are not resolved, so R2RMLTC0019a fails with HTTP 500 (Not a valid (absolute) IRI: Carlos). The propertymapping.baseIriis declared inOntopMappingSettingsbut nothing reads it; setting it does not change the output.Decision
[mapping] base_iri,V12N_BASE_IRI, and--base-irionquery,explainandserve. It must be an absolute IRI. Without it a relative IRI stays a data error, and the message names the setting. To review: the alternative was a default such as Ontop'shttp://example.com/base/or a reservedhttp://v12n.invalid/. A default would make every relative value look like a real IRI in a namespace the data does not belong to, and changing it later would change every result. A deployment that has relative IRIs in its data has to decide what they mean, so it has to set the namespace.http://example.com/base/,../xbecomeshttp://example.com/base/../xand?qbecomeshttp://example.com/base/?q.ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ":", RFC 3987). A fragment does not make a value relative, which matches R2RMLTC0019a: RFC 3987'sabsolute-IRIproduction has no fragment, but the test expectshttp://example.com/ns#Jhonas is. Deviation to review: a value with a scheme that is not a valid IRI is a data error; R2RML would first try the base in front of it. The two only differ for values likehttp://host:port/with a non-numeric port, where R2RML giveshttp://example.com/base/http://host:port/. One rule that SQL can test with a regular expression keeps joins and constant lookups consistent with the terms built from rows.{name},person/{id}) gets the base in front of it when the mapping is loaded (Mapping::with_base_iri). Decomposition then works as before:<http://example.com/base/Bob%2FCharles>becomes"Name" = $1withBob/Charles.col IN ($1, $2)with the IRI and the relative rest (left out when the rest has a scheme, because such a value is kept as it is). PostgreSQL uses the index (Index Cond: (iri = ANY (...))). Each alternative is round-trip checked before binding like any constant (Discussion Decision: compare query constants as RDF terms and check them before binding #21); one that cannot match is bound to NULL and drops only itself, and the branch is skipped only when all of them are NULL.{scheme}:{rest}whose scheme depends on the values, compare the generated IRIs in SQL:CASE WHEN s ~ '^[A-Za-z][-+.0-9A-Za-z]*:' THEN s ELSE $base || s END. No index on the column serves this.aandhttp://example.com/base/a) count as two solutions. For the same reasonSELECT DISTINCTover a variable whose IRIs are resolved per value is rejected as unsupported when a base IRI is set.base_iri = "http://example.com/base/"incase.toml, as the test suite states. R2RMLTC0020a now matches Ontop. R2RMLTC0019a is included and recorded as an Ontop error (Record Ontop's value matching for uuid and errors on ill-typed dates #26), with v12n returning the two W3C triples.References
배경
rr:termType rr:IRI인 term map은 상대 IRI를 만들 수 있다.Carlos를 담은 컬럼,Bob에 대한 템플릿{"Name"},person/{id}같은 경우다. 엔진은 이런 값을 모두 데이터 오류로 보고했다. 그래서 W3C 테스트 R2RMLTC0020a는 Ontop과 달랐고 R2RMLTC0019a는 건너뛰었다(#33).명세 내용:
?나#를 담지 않는 것이 좋으며/로 끝나는 것이 좋다. term 생성 규칙은 RFC 3986 §5.2의 해석 알고리즘이 아니라 단순 문자열 이어 붙이기를 쓴다. 그래야 IRI에서 DB 값을 되살릴 수 있다. 두 방식은 base에?/#가 없고/로 끝나며, 상대 IRI가/로 시작하지 않고.,..세그먼트가 없을 때만 같다.rr:IRI의 term 생성 규칙: natural RDF lexical form을 얻는다. 올바른 절대 IRI면 그것이 IRI다. 아니면 앞에 base IRI를 붙이고, 결과가 올바른 절대 IRI면 그것이 IRI다. 아니면 데이터 오류다.iunreserved밖의 문자를 UTF-8로 퍼센트 인코딩)로 바꾼다. 그래서Bob/Charles는Bob%2FCharles가 된다.rr:IRI인 term map이 잘못된 IRI를 만들면 데이터 오류다. 그런 term을 돌려줘야 하는 작업은 실패해야 한다.<http://example.com/base/>를 쓴다". R2RMLTC0019a는 컬럼에서<http://example.com/ns#Jhon>과<http://example.com/base/Carlos>를, R2RMLTC0020a는{"Name"}에서<http://example.com/base/Bob%2FCharles>,<http://example.com/base/path%2F..%2FDanny>,<http://example.com/base/http%3A%2F%2Fexample.com%2Fcompany%2FAlice>를 기대한다.Ontop 5.5.0(바이트코드와 testenv 실행으로 확인):
R2RMLToSQLPPTriplesMapConverter는 상수http://example.com/base/를 쓴다. 템플릿의 첫{앞 텍스트가 절대 IRI가 아니면 매핑을 읽을 때 그 상수를 템플릿 앞에 붙인다. 컬럼 값은 해석하지 않아서 R2RMLTC0019a는 HTTP 500(Not a valid (absolute) IRI: Carlos)으로 실패한다.mapping.baseIri속성은OntopMappingSettings에 선언돼 있지만 읽는 곳이 없어서, 설정해도 결과가 바뀌지 않는다.결정
[mapping] base_iri,V12N_BASE_IRI,query·explain·serve의--base-iri. 절대 IRI여야 한다. 설정이 없으면 상대 IRI는 계속 데이터 오류이고, 오류 메시지가 설정 이름을 알려준다. 검토할 결정: 다른 안은 Ontop의http://example.com/base/나 예약된http://v12n.invalid/같은 기본값이었다. 기본값이 있으면 모든 상대 값이 데이터와 상관없는 네임스페이스의 진짜 IRI처럼 보이고, 나중에 기본값을 바꾸면 모든 결과가 바뀐다. 데이터에 상대 IRI가 있는 배포라면 그것이 무엇을 뜻하는지 정해야 하므로, 네임스페이스도 직접 정해야 한다.http://example.com/base/이면../x는http://example.com/base/../x,?q는http://example.com/base/?q가 된다.ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ":", RFC 3987). fragment가 있다고 상대 IRI가 되지는 않는다. 이는 R2RMLTC0019a와 맞는다. RFC 3987의absolute-IRI문법에는 fragment가 없지만, 테스트는http://example.com/ns#Jhon을 그대로 기대한다. 검토할 차이: scheme은 있지만 올바른 IRI가 아닌 값은 데이터 오류다. R2RML은 이때도 먼저 앞에 base를 붙여 본다. 두 방식은 포트가 숫자가 아닌http://host:port/같은 값에서만 다르고, R2RML대로면http://example.com/base/http://host:port/가 나온다. SQL이 정규식으로 검사할 수 있는 규칙 하나를 쓰면 조인과 상수 조회가 행에서 만든 term과 어긋나지 않는다.{name},person/{id})은 매핑을 읽을 때 앞에 base를 붙인다(Mapping::with_base_iri). 그러면 분해가 이전처럼 동작한다.<http://example.com/base/Bob%2FCharles>는Bob/Charles를 바인딩한"Name" = $1이 된다.col IN ($1, $2)가 된다(나머지에 scheme이 있으면 그 값은 그대로 쓰이므로 뺀다). PostgreSQL은 인덱스를 쓴다(Index Cond: (iri = ANY (...))). 각 후보는 다른 상수처럼 바인딩 전에 왕복 검사를 거친다(Discussion Decision: compare query constants as RDF terms and check them before binding #21). 일치할 수 없는 후보는 NULL로 바인딩되어 자기만 빠지고, 가지는 모든 후보가 NULL일 때만 건너뛴다.{scheme}:{rest}처럼 값에 따라 scheme이 생기는 템플릿은 SQL에서 생성 IRI를 비교한다:CASE WHEN s ~ '^[A-Za-z][-+.0-9A-Za-z]*:' THEN s ELSE $base || s END. 컬럼 인덱스는 이 비교에 쓰이지 않는다.a와http://example.com/base/a)는 solution 둘로 센다. 같은 이유로 base IRI가 있을 때 값마다 해석되는 IRI 변수에 대한SELECT DISTINCT는 미지원으로 거절한다.case.toml에 테스트 모음이 밝힌 대로base_iri = "http://example.com/base/"를 넣었다. R2RMLTC0020a는 이제 Ontop과 같다. R2RMLTC0019a를 포함했고, v12n이 W3C 트리플 두 개를 돌려주는 Ontop 오류(Record Ontop's value matching for uuid and errors on ill-typed dates #26)로 기록했다.참고
All reactions