Hello Community,
I have a strange problem that relates to FK-constraints. I am using Ontop with Dremio and therefore need to define FK-constraints. For this, I am using Lenses.
I setup a very easy example. I took the United Nations list for geographic subregions and continental regions.
I have two views in Dremio
ContinentalRegion
- id (PK)
- name
GeographicSubregions
- id (PK)
- name
- geographicalSubregionPartOfContinentalRegion (FK)
I specified this as follows
{
"name" : [
"\"lenses\"",
"\"X.Y.Z\"",
"\"GeographicalSubregion\""
],
"baseRelation" : [
"\"X.Y.Z\"",
"\"GeographicalSubregion\""
],
"filterExpression" : null,
"columns" : {
"added" : [
],
"hidden" : [
]
},
"uniqueConstraints" : {
"added" : [
{
"name" : "95114c51-d722-49aa-9460-7883da8b338b",
"determinants" : [
"\"id\""
],
"isPrimaryKey" : false
}
]
},
"otherFunctionalDependencies" : {
"added" : [
]
},
"foreignKeys" : {
"added" : [
{
"name" : "943125aa-9e2c-49fc-8efc-ee62ef175471",
"from" : [
"\"geographicalSubregionPartOfContinentalRegion\""
],
"to" : {
"relation" : [
"\"X.Y.Z\"",
"\"ContinentalRegion\""
],
"columns" : [
"\"id\""
]
}
}
]
},
"nonNullConstraints" : {
"added" : [
"\"id\""
]
},
"type" : "BasicLens"
}
{
"name" : [
"\"lenses\"",
"\"X.Y.Z\"",
"\"ContinentalRegion\""
],
"baseRelation" : [
"\"X.Y.Z\"",
"\"ContinentalRegion\""
],
"filterExpression" : null,
"columns" : {
"added" : [
],
"hidden" : [
]
},
"uniqueConstraints" : {
"added" : [
{
"name" : "2fb4ba94-b724-4997-bba6-f621fb00b4ef",
"determinants" : [
"\"id\""
],
"isPrimaryKey" : false
}
]
},
"otherFunctionalDependencies" : {
"added" : [
]
},
"foreignKeys" : {
"added" : [
]
},
"nonNullConstraints" : {
"added" : [
"\"id\""
]
},
"type" : "BasicLens"
}
When I now run my query:
PREFIX meta: <
https://ABC#>
PREFIX rdfs: <
http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <
http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT *
WHERE {
?cr rdf:type meta:ContinentalRegion .
}
I get the typical UNION ALL behaviour that happens if no FK-constraints are used.
SELECT DISTINCT v5."id0m73" AS "id0m73"
FROM ((SELECT v1."id" AS "id0m73"
FROM "X.Y.Z"."ContinentalRegion" v1
WHERE v1."id" IS NOT NULL
)
UNION ALL
(SELECT v3."geographicalSubregionPartOfContinentalRegion" AS "id0m73"
FROM "X.Y.Z"."GeographicalSubregion" v3
WHERE v3."geographicalSubregionPartOfContinentalRegion" IS NOT NULL
)) v5
I tried all kinds of things with escaping, because this was necessary in the past when worked with DB metadata file.
I am using GraphDB 10.7.1 and the corresponding Ontop instance as well as Dremio (Build: 25.1.1-202409260159070462-716c0676)
Maybe one of you has seen similar behavior when working with Dremio.
Thanks and all the best
Frank