The following fails to produce the expected output.
(using example table from https://mariadb.com/kb/en/mariadb/oqgraph-examples/ )
CREATE TABLE oq_backing (
origid INT UNSIGNED NOT NULL,
destid INT UNSIGNED NOT NULL,
PRIMARY KEY (origid, destid),
KEY (destid)
);
INSERT INTO oq_backing(origid, destid)
VALUES (1,2), (2,3), (3,4), (4,5), (2,6), (5,6);
CREATE TABLE oq_graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
)
ENGINE=OQGRAPH
data_table='oq_backing' origid='origid' destid='destid';
select * from oq_backing;
+--------+--------+
| origid | destid |
+--------+--------+
| 1 | 2 |
| 2 | 3 |
| 2 | 6 |
| 3 | 4 |
| 4 | 5 |
| 5 | 6 |
+--------+--------+
This works:
SELECT GROUP_CONCAT(linkid ORDER BY seq) AS path FROM oq_graph WHERE latch='breadth_first' AND origid=4;
This fails:
select ob.origid, (select group_concat(pt.linkid order by pt.seq desc separator '>') from oq_graph as pt where pt.latch='breadth_first' and pt.origid=ob.origid) from oq_backing as ob;
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
| origid | (select group_concat(pt.linkid order by pt.seq desc separator '>') from oq_graph as pt where pt.latch='breadth_first' and pt.origid=ob.origid) |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | NULL |
| 2 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
+--------+------------------------------------------------------------------------------------------------------------------------------------------------+
6 rows in set (0.00 sec)
Ultimately what I'm trying to accomplish is to perform a query in a table that has a "location" field (the location is tree), I need to perform a subquery to return a "path" for each row.
Here is my "real world" query example:
select group_concat(l.Name order by pt.seq desc separator '>')
from Loc_graph as pt
join Location as l on l.id = pt.linkid
where pt.latch = 'breadth_first' and pt.origid=6;
Which returns:
However, when I embed the above as a subquery:
select loc.id,
( select group_concat(l.Name order by pt.seq desc separator '>')
from Loc_graph as pt
join Location as l on l.id = pt.linkid
where pt.latch = 'breadth_first' and pt.origid=loc.id) as path
from Location as loc;
I get the following
+----+------+
| id | path |
+----+------+
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
| 6 | NULL |
| 7 | NULL |
| 8 | NULL |
| 9 | NULL |
| 10 | NULL |
| 11 | NULL |
| 12 | NULL |
| 13 | NULL |
| 14 | NULL |
| 15 | NULL |
| 16 | NULL |
| 17 | NULL |
| 18 | NULL |
| 19 | NULL |
| 20 | NULL |
| 21 | NULL |
| 22 | NULL |
| 23 | NULL |
| 24 | NULL |
| 25 | NULL |
| 26 | NULL |
| 27 | NULL |
| 28 | NULL |
| 29 | NULL |
| 30 | NULL |
| 31 | NULL |
+----+------+
relates to
MDEV-627
LP:837496 - Empty resultset when joining OQGRAPH tables
Open
Elena Stepanova
made changes -
2017-05-01 22:55
Status
Open
[ 1
]
Confirmed
[ 10101
]
Elena Stepanova
made changes -
2017-05-01 22:55
Fix Version/s
10.1
[ 16100
]
Assignee
Andrew McDonnell
[ andymc73
]
Sergei Golubchik
made changes -
2021-12-06 21:36
Workflow
MariaDB v3
[ 80342
]
MariaDB v4
[ 143932
]
{"report":{"fcp":1328.2000002861023,"ttfb":527.9000000953674,"pageVisibility":"visible","entityId":60933,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"412df0ad-1194-4667-a384-c5ca97b3849a","navigationType":0,"readyForUser":1481.7000002861023,"redirectCount":0,"resourceLoadedEnd":1458.3000001907349,"resourceLoadedStart":545,"resourceTiming":[{"duration":81.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":545,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":545,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":626.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":81.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":545.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":545.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":626.5,"responseStart":0,"secureConnectionStart":0},{"duration":155.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":545.4000000953674,"connectEnd":545.4000000953674,"connectStart":545.4000000953674,"domainLookupEnd":545.4000000953674,"domainLookupStart":545.4000000953674,"fetchStart":545.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":545.4000000953674,"responseEnd":700.5999999046326,"responseStart":700.5999999046326,"secureConnectionStart":545.4000000953674},{"duration":280.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":545.7000002861023,"connectEnd":545.7000002861023,"connectStart":545.7000002861023,"domainLookupEnd":545.7000002861023,"domainLookupStart":545.7000002861023,"fetchStart":545.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":545.7000002861023,"responseEnd":825.8000001907349,"responseStart":825.8000001907349,"secureConnectionStart":545.7000002861023},{"duration":284.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":545.9000000953674,"connectEnd":545.9000000953674,"connectStart":545.9000000953674,"domainLookupEnd":545.9000000953674,"domainLookupStart":545.9000000953674,"fetchStart":545.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":545.9000000953674,"responseEnd":830,"responseStart":830,"secureConnectionStart":545.9000000953674},{"duration":284.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":546.0999999046326,"connectEnd":546.0999999046326,"connectStart":546.0999999046326,"domainLookupEnd":546.0999999046326,"domainLookupStart":546.0999999046326,"fetchStart":546.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":546.0999999046326,"responseEnd":830.4000000953674,"responseStart":830.4000000953674,"secureConnectionStart":546.0999999046326},{"duration":284.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":546.3000001907349,"connectEnd":546.3000001907349,"connectStart":546.3000001907349,"domainLookupEnd":546.3000001907349,"domainLookupStart":546.3000001907349,"fetchStart":546.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":546.3000001907349,"responseEnd":831.0999999046326,"responseStart":831.0999999046326,"secureConnectionStart":546.3000001907349},{"duration":307.2000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":546.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":546.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":853.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":285.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":546.5999999046326,"connectEnd":546.5999999046326,"connectStart":546.5999999046326,"domainLookupEnd":546.5999999046326,"domainLookupStart":546.5999999046326,"fetchStart":546.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":546.5999999046326,"responseEnd":831.7000002861023,"responseStart":831.7000002861023,"secureConnectionStart":546.5999999046326},{"duration":306.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":546.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":546.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":853.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":285.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":547,"connectEnd":547,"connectStart":547,"domainLookupEnd":547,"domainLookupStart":547,"fetchStart":547,"redirectEnd":0,"redirectStart":0,"requestStart":547,"responseEnd":832.3000001907349,"responseStart":832.3000001907349,"secureConnectionStart":547},{"duration":792.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":547.9000000953674,"connectEnd":547.9000000953674,"connectStart":547.9000000953674,"domainLookupEnd":547.9000000953674,"domainLookupStart":547.9000000953674,"fetchStart":547.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":547.9000000953674,"responseEnd":1340.4000000953674,"responseStart":1340.4000000953674,"secureConnectionStart":547.9000000953674},{"duration":910.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":548,"connectEnd":548,"connectStart":548,"domainLookupEnd":548,"domainLookupStart":548,"fetchStart":548,"redirectEnd":0,"redirectStart":0,"requestStart":548,"responseEnd":1458.3000001907349,"responseStart":1458.3000001907349,"secureConnectionStart":548},{"duration":475.19999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":865.8000001907349,"connectEnd":865.8000001907349,"connectStart":865.8000001907349,"domainLookupEnd":865.8000001907349,"domainLookupStart":865.8000001907349,"fetchStart":865.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":865.8000001907349,"responseEnd":1341,"responseStart":1341,"secureConnectionStart":865.8000001907349},{"duration":368.40000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1319.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1319.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1688,"responseStart":0,"secureConnectionStart":0},{"duration":261.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1560.5999999046326,"connectEnd":1560.5999999046326,"connectStart":1560.5999999046326,"domainLookupEnd":1560.5999999046326,"domainLookupStart":1560.5999999046326,"fetchStart":1560.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1560.5999999046326,"responseEnd":1821.7000002861023,"responseStart":1821.7000002861023,"secureConnectionStart":1560.5999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":344,"responseStart":528,"responseEnd":533,"domLoading":535,"domInteractive":1730,"domContentLoadedEventStart":1730,"domContentLoadedEventEnd":1809,"domComplete":2561,"loadEventStart":2561,"loadEventEnd":2561,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1706.5999999046326},{"name":"bigPipe.sidebar-id.end","time":1707.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.start","time":1707.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1710},{"name":"activityTabFullyLoaded","time":1822.4000000953674}],"measures":[],"correlationId":"73564c562dfe09","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":105,"dbReadsTimeInMs":14,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}