Hello,
I'm encountering some strange behaviour while testing SPARQL queries (on Stardog 7.6.4). The same query will sometimes run successfully, and other times will return an error. For example, the following query runs successfully:
SELECT *
FROM virtual://tw_mockdb2
FROM virtual://aiwWHERE{
?d1 famo:indicatesType famo:Valve;
famo:indicatesHasIdentifier ?wms_id;
famo:indicatesInstallDate ?i_date;
famo:indicatesIsResponsibleForRole [
famo:hasEntityNumber ?r_enum].
?d2 famo:indicatesHasEntityNumber ?r_enum;
famo:indicatesLocatedInSpace ?s.?a famo:hasDocumentation ?rec.
?rec famo:specifies ?desc.
}
However, with the addition of one other statement:
?desc famo:indicatesHasIdentifier ?a_id.
An error is returned:
com.complexible.stardog.plan.eval.operator.OperatorException: Unable to execute virtual graph query. SQL string: SELECT "aiw_real_asset_record_tbl"."asset_id", "aiw_real_asset_record_tbl"."project_phase_uuid", "aiw_real_asset_record_tbl"."new_asset", "aiw_real_asset_record_tbl"."wms_asset_record_id", "aiw_real_asset_record_tbl"."aiw_asset_id", "aiw_real_asset_record_tbl"."asset_manufacturer_verified_n_new", "aiw_real_asset_record_tbl"."asset_model_verified_n_new", "aiw_real_asset_record_tbl"."mfr_serial_on_wms_record", "aiw_real_asset_record_tbl"."mfr_serial_verified_n_new", "aiw_real_asset_record_tbl"."asset_classification_on_wms_record", "aiw_real_asset_record_tbl"."asset_classification_verified_n_new", "aiw_real_asset_record_tbl"."existing_asset_moved", "aiw_real_asset_record_tbl"."existing_asset_decommissioned", "aiw_real_asset_record_tbl"."existing_asset_removed", "aiw_real_asset_record_tbl"."occupied_role_id_on_wms_record", "aiw_real_asset_record_tbl"."occupied_role_id_verified", "aiw_real_asset_record_tbl"."occupied_role_id_final", "aiw_capital_phase_tbl"."phase_uuid", "aiw_capital_phase_tbl"."aiw_project_uuid", "aiw_capital_phase_tbl"."project_phase_number", "aiw_capital_phase_tbl"."scope_description", "aiw_capital_phase_tbl"."consultant_company_name", "aiw_capital_phase_tbl"."contractor_company_name", "aiw_capital_phase_tbl"."start_date", "aiw_capital_phase_tbl"."commissioning_date", "aiw_capital_phase_tbl"."status", CASE WHEN "aiw_real_asset_record_tbl"."existing_asset_moved" THEN 'MoveAsset' WHEN "aiw_real_asset_record_tbl"."existing_asset_decommissioned" THEN 'DecommissionAsset' WHEN "aiw_real_asset_record_tbl"."existing_asset_removed" THEN 'RemoveAsset' ELSE NULL END AS "activity", CASE WHEN "aiw_real_asset_record_tbl"."existing_asset_decommissioned" AND "aiw_real_asset_record_tbl"."existing_asset_removed" OR "aiw_real_asset_record_tbl"."existing_asset_decommissioned" AND NOT "aiw_real_asset_record_tbl"."existing_asset_removed" THEN 'decommissioned_and_discarded' WHEN "aiw_real_asset_record_tbl"."existing_asset_moved" THEN 'operational' ELSE NULL END AS "asset_status"
FROM "public"."aiw_real_asset_record_tbl"
INNER JOIN "public"."aiw_capital_phase_tbl" ON "aiw_real_asset_record_tbl"."project_phase_uuid" = "aiw_capital_phase_tbl"."phase_uuid" AND "aiw_real_asset_record_tbl"."wms_asset_record_id" IS NOT NULL AND "aiw_capital_phase_tbl"."aiw_project_uuid" IS NOT NULL AND NOT "aiw_real_asset_record_tbl"."new_asset"
WHERE "aiw_real_asset_record_tbl"."wms_asset_record_id" = '32' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-2') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '154' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-9') OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '35' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-10') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '12' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-12')) OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '987' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-13') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '94' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-15') OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '1034' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-17') OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '2' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-2') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '8' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-9')))) OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '9' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-10') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '5' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-12') OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '11' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-13') OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = '12' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-14') OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = '13' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 'R-15'))) OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = 'WMS-Asset-6' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 5) OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = 'WMS-Asset-5' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 4) OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = 'WMS-Asset-4' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 3) OR ("aiw_real_asset_record_tbl"."wms_asset_record_id" = 'WMS-Asset-2' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 2) OR "aiw_real_asset_record_tbl"."wms_asset_record_id" = 'WMS-Asset-1' AND ("aiw_capital_phase_tbl"."aiw_project_uuid" = 'Project-UUID-1' AND "aiw_real_asset_record_tbl"."asset_id" = 1)))))
If I attempt to re-run the original query (with the additional statement removed), it no longer runs successfully, but instead returns this error:
com.complexible.stardog.plan.eval.operator.OperatorException: Unable to execute virtual graph query. SQL string: SELECT "aiw_real_role_record_tbl"."aiw_role_id", "aiw_real_role_record_tbl"."etms_role_record_id", "aiw_capital_phase_tbl"."aiw_project_uuid"
FROM "public"."aiw_real_role_record_tbl"
INNER JOIN "public"."aiw_capital_phase_tbl" ON "aiw_real_role_record_tbl"."project_phase_uuid" = "aiw_capital_phase_tbl"."phase_uuid" AND "aiw_real_role_record_tbl"."etms_role_record_id" IS NOT NULL AND "aiw_capital_phase_tbl"."aiw_project_uuid" IS NOT NULL AND NOT "aiw_real_role_record_tbl"."new_role"
It seems like there might be an issue due to the mapping specification for the virtual graph but it's not clear to me what the problem might be. In either case, it doesn't make sense that the same query works and then returns an error once some other query has been run.
Thanks and best regards,
Megan