(sorry for the stupid question, but I’m lost in the documentation)
I have these two tables:
cr> show create table processors;
+-----------------------------------------------------+
| SHOW CREATE TABLE doc.processors |
+-----------------------------------------------------+
| CREATE TABLE IF NOT EXISTS "doc"."processors" ( |
| "identifier" TEXT NOT NULL, |
| "name" TEXT INDEX USING FULLTEXT WITH ( |
| analyzer = 'english' |
| ), |
| "definition" TEXT INDEX USING FULLTEXT WITH ( |
| analyzer = 'english' |
| ), |
| "properties" OBJECT(DYNAMIC) AS ( |
| "brand" TEXT, |
| "cores_theads" TEXT, |
| "socket" TEXT |
| ), |
| "attachments" ARRAY(TEXT), |
| PRIMARY KEY ("identifier") |
| ) |
...
cr> show create table attachments_meta;
+-------------------------------------------------------+
| SHOW CREATE TABLE doc.attachments_meta |
+-------------------------------------------------------+
| CREATE TABLE IF NOT EXISTS "doc"."attachments_meta" ( |
| "digest" TEXT NOT NULL, |
| "name" TEXT INDEX USING FULLTEXT WITH ( |
| analyzer = 'english' |
| ), |
| "description" TEXT INDEX USING FULLTEXT WITH ( |
| analyzer = 'english' |
| ), |
| "filename" TEXT, |
| PRIMARY KEY ("digest") |
| ) |
...
The tables contain:
cr> select * from processors;
[
{
"identifier": "AMD_R9_7950X",
"name": "Ryzen 9 7950X",
"definition": "AMD Ryzen 9 7950X 16-Core, 32-Thread Unlocked Desktop Processor",
"properties": {
"cores_theads": "16/32",
"socket": "AM5",
"brand": "AMD"
},
"attachments": [
"acfa51b963b5a1fb9eecaf7954ae39c9bea736cc",
"9a3993e2ecbbb3b1ea1435650cedd7fec2454e73",
"135b6d193c9acba8ea180dea7424b863ce52858b"
]
},
{
"identifier": "AMD_R7_5700G",
"name": "Ryzen 7 5700G",
"definition": "Processore AMD Ryzen 7 5700G (scheda grafica integrata Radeon, 8 C/16 T, 65W TDP, AM4 Socket, 20MB cache, Boost di Frequenza fino a 4.6 Ghz max, dissipatore ad aria \"Wraith stealth cooler\"",
"properties": {
"cores_theads": "8/16",
"socket": "AM4",
"brand": "AMD"
},
"attachments": [
"9a3993e2ecbbb3b1ea1435650cedd7fec2454e73",
"135b6d193c9acba8ea180dea7424b863ce52858b"
]
},
{
"identifier": "INT_i9_14900KS",
"name": "Core i9 14900KS",
"definition": "Intel\u00ae Core\u2122 i9 processor 14900KS (36M Cache- up to 6.20 GHz)",
"properties": {
"cores_theads": "8+16/32",
"socket": "FCLGA1700",
"brand": "Intel"
},
"attachments": []
}
]
SELECT 3 rows in set (0.810 sec)
cr>
cr> select * from attachments_meta;
[
{
"digest": "135b6d193c9acba8ea180dea7424b863ce52858b",
"name": "Insert CPU IN motherboard socket",
"description": "Short video ON how TO INSERT a CPU IN the motherboard socket",
"filename": "11537353-hd_1920_1080_30fps.mp4"
},
{
"digest": "f83be20cb0439e5008242ec7a01cf1fe168f413b",
"name": "Impress Guide v. 24.2",
"description": "LibreOffice Impress Guide version 24.2. A manual FOR creating presentations",
"filename": "IG24-ImpressGuide.pdf"
},
{
"digest": "acfa51b963b5a1fb9eecaf7954ae39c9bea736cc",
"name": "ROG Maximus Z790 Hero BTF - Quick START guide",
"description": "The quick START guide FOR the Asus Republic Of Gamers Maximus Z790 Hero BTF motherboard",
"filename": "Q23155_ROG_MAXIMUS_Z790_HERO_BTF_QSG_WEB.pdf"
},
{
"digest": "9a3993e2ecbbb3b1ea1435650cedd7fec2454e73",
"name": "Top VIEW of ROG CROSSHAIR X670E HERO",
"description": "The top VIEW image of the Asus Republic Of Gamers CROSSHAIR X670E HERO motherboard",
"filename": "ROG_CROSSHAIR_X670E_HERO_h732.png"
}
]
SELECT 4 rows in set (0.017 sec)
cr>
Now I need to get all the processors rows with the data from the attachments_meta table where any item in the processors “attachments” field (text_array) is equal to the “digest” field in the attachments meta table.
The “attachment” field can contain zero or more items.
The two syntax I used give different errors
cr> SELECT * FROM processors p LEFT JOIN attachments_meta a ON p.attachments = a.digest;
UnsupportedFunctionException[Unknown function: (p.attachments = a.digest), no overload found for matching argument types: (text_array, text). Possible candidates: op_=(E, E):boolean]
cr> SELECT * FROM processors p LEFT JOIN attachments_meta a WHERE p.attachments = a.digest;
SQLParseException[line 1:57: no viable alternative at input 'SELECT * FROM processors p LEFT JOIN attachments_meta a WHERE']
So my question: what is the syntax for a left join where the field of comparison is a text_array ?