Skip to content

Commit ea3d850

Browse files
committed
Fixed issue with self-joins in RMLViews
1 parent d4b1416 commit ea3d850

File tree

4 files changed

+46
-32
lines changed

4 files changed

+46
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ You can easily customize your own configurations from the set of features that S
8484

8585
## Version
8686
```
87-
4.7.5.13
87+
4.7.5.13.1
8888
```
8989

9090
## RML-Test Cases

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.7.5.13
1+
4.7.5.13.1

rdfizer/rdfizer/__init__.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,8 +2112,12 @@ def mapping_parser(mapping_file):
21122112
?_object_map rml:parentTriplesMap ?object_parent_triples_map .
21132113
OPTIONAL {
21142114
?_object_map rml:joinCondition ?join_condition .
2115-
?join_condition rml:child ?child_value;
2116-
rml:parent ?parent_value.
2115+
OPTIONAL{?join_condition rml:child ?child_value.}
2116+
OPTIONAL{?join_condition rml:parent ?parent_value.}
2117+
OPTIONAL{?join_condition rml:childMap ?childMap.
2118+
OPTIONAL{?childMap rml:reference ?child_reference.}
2119+
OPTIONAL{?childMap rml:template ?child_template.}
2120+
OPTIONAL{?childMap rml:constant ?child_constant.}}
21172121
OPTIONAL{?parent_value rml:functionExecution ?executed_parent .
21182122
?executed_parent rml:function ?parent_function .}
21192123
OPTIONAL{?child_value rml:functionExecution ?executed_child .
@@ -6508,22 +6512,25 @@ def semantify_file(triples_map, triples_map_list, delimiter, output_file_descrip
65086512
if predicate_object_map.object_map.parent != None:
65096513
if (triples_map_element.triples_map_id + "_" + child_list(
65106514
predicate_object_map.object_map.child)) not in join_table:
6511-
with open(str(triples_map_element.data_source),
6512-
"r") as input_file_descriptor:
6513-
if str(triples_map_element.file_format).lower() == "csv":
6514-
parent_data = csv.DictReader(input_file_descriptor,
6515-
delimiter=delimiter)
6516-
hash_maker_list(parent_data, triples_map_element,
6517-
predicate_object_map.object_map)
6518-
else:
6519-
parent_data = json.load(input_file_descriptor)
6520-
if isinstance(parent_data, list):
6515+
if "RMLView" in triples_map_element.file_format:
6516+
hash_maker(data, triples_map_element,predicate_object_map.object_map,"", triples_map_list)
6517+
else:
6518+
with open(str(triples_map_element.data_source),
6519+
"r") as input_file_descriptor:
6520+
if str(triples_map_element.file_format).lower() == "csv":
6521+
parent_data = csv.DictReader(input_file_descriptor,
6522+
delimiter=delimiter)
65216523
hash_maker_list(parent_data, triples_map_element,
65226524
predicate_object_map.object_map)
65236525
else:
6524-
hash_maker_list(parent_data[list(parent_data.keys())[0]],
6525-
triples_map_element,
6526-
predicate_object_map.object_map)
6526+
parent_data = json.load(input_file_descriptor)
6527+
if isinstance(parent_data, list):
6528+
hash_maker_list(parent_data, triples_map_element,
6529+
predicate_object_map.object_map)
6530+
else:
6531+
hash_maker_list(parent_data[list(parent_data.keys())[0]],
6532+
triples_map_element,
6533+
predicate_object_map.object_map)
65276534
if sublist(predicate_object_map.object_map.child, row.keys()):
65286535
if child_list_value(predicate_object_map.object_map.child, row) in \
65296536
join_table[triples_map_element.triples_map_id + "_" + child_list(

rdfizer/rdfizer/semantify.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,8 +2112,12 @@ def mapping_parser(mapping_file):
21122112
?_object_map rml:parentTriplesMap ?object_parent_triples_map .
21132113
OPTIONAL {
21142114
?_object_map rml:joinCondition ?join_condition .
2115-
?join_condition rml:child ?child_value;
2116-
rml:parent ?parent_value.
2115+
OPTIONAL{?join_condition rml:child ?child_value.}
2116+
OPTIONAL{?join_condition rml:parent ?parent_value.}
2117+
OPTIONAL{?join_condition rml:childMap ?childMap.
2118+
OPTIONAL{?childMap rml:reference ?child_reference.}
2119+
OPTIONAL{?childMap rml:template ?child_template.}
2120+
OPTIONAL{?childMap rml:constant ?child_constant.}}
21172121
OPTIONAL{?parent_value rml:functionExecution ?executed_parent .
21182122
?executed_parent rml:function ?parent_function .}
21192123
OPTIONAL{?child_value rml:functionExecution ?executed_child .
@@ -6508,22 +6512,25 @@ def semantify_file(triples_map, triples_map_list, delimiter, output_file_descrip
65086512
if predicate_object_map.object_map.parent != None:
65096513
if (triples_map_element.triples_map_id + "_" + child_list(
65106514
predicate_object_map.object_map.child)) not in join_table:
6511-
with open(str(triples_map_element.data_source),
6512-
"r") as input_file_descriptor:
6513-
if str(triples_map_element.file_format).lower() == "csv":
6514-
parent_data = csv.DictReader(input_file_descriptor,
6515-
delimiter=delimiter)
6516-
hash_maker_list(parent_data, triples_map_element,
6517-
predicate_object_map.object_map)
6518-
else:
6519-
parent_data = json.load(input_file_descriptor)
6520-
if isinstance(parent_data, list):
6515+
if "RMLView" in triples_map_element.file_format:
6516+
hash_maker(data, triples_map_element,predicate_object_map.object_map,"", triples_map_list)
6517+
else:
6518+
with open(str(triples_map_element.data_source),
6519+
"r") as input_file_descriptor:
6520+
if str(triples_map_element.file_format).lower() == "csv":
6521+
parent_data = csv.DictReader(input_file_descriptor,
6522+
delimiter=delimiter)
65216523
hash_maker_list(parent_data, triples_map_element,
65226524
predicate_object_map.object_map)
65236525
else:
6524-
hash_maker_list(parent_data[list(parent_data.keys())[0]],
6525-
triples_map_element,
6526-
predicate_object_map.object_map)
6526+
parent_data = json.load(input_file_descriptor)
6527+
if isinstance(parent_data, list):
6528+
hash_maker_list(parent_data, triples_map_element,
6529+
predicate_object_map.object_map)
6530+
else:
6531+
hash_maker_list(parent_data[list(parent_data.keys())[0]],
6532+
triples_map_element,
6533+
predicate_object_map.object_map)
65276534
if sublist(predicate_object_map.object_map.child, row.keys()):
65286535
if child_list_value(predicate_object_map.object_map.child, row) in \
65296536
join_table[triples_map_element.triples_map_id + "_" + child_list(

0 commit comments

Comments
 (0)