Transforms: Add join by fields (#61322)

This commit is contained in:
Ludovic Viaud
2023-01-26 13:10:05 +01:00
committed by GitHub
parent f7d92ab841
commit bfbc8c3c4f
7 changed files with 392 additions and 354 deletions
@@ -24,7 +24,6 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1351,
"links": [],
"liveNow": false,
"panels": [
@@ -38,7 +37,7 @@
},
"id": 9,
"panels": [],
"title": "Join by time",
"title": "Input",
"type": "row"
},
{
@@ -49,37 +48,14 @@
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
"mode": "thresholds"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
"align": "auto",
"cellOptions": {
"type": "auto"
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
"inspect": false
},
"mappings": [],
"thresholds": {
@@ -99,41 +75,41 @@
},
"gridPos": {
"h": 8,
"w": 12,
"w": 8,
"x": 0,
"y": 1
},
"id": 11,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
"showHeader": true
},
"pluginVersion": "9.4.0-pre",
"targets": [
{
"datasource": {
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 4
"rawFrameContent": "[{\r\n \"name\": \"tags\",\r\n \"fields\": [\r\n { \"name\": \"tags__time\", \"values\": [100, 101, 200] },\r\n { \"name\": \"tags__name\", \"values\": [\"v1.2\", \"v1.2b\", \"v1.3\"] }\r\n ]\r\n}]",
"refId": "tags",
"scenarioId": "raw_frame"
}
],
"title": "Timeseries data",
"type": "timeseries"
"title": "tags",
"type": "table"
},
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"fieldConfig": {
"defaults": {
@@ -142,7 +118,9 @@
},
"custom": {
"align": "auto",
"displayMode": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
@@ -163,13 +141,14 @@
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"w": 8,
"x": 8,
"y": 1
},
"id": 13,
"options": {
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
@@ -178,24 +157,25 @@
},
"showHeader": true
},
"pluginVersion": "9.2.0-pre",
"pluginVersion": "9.4.0-pre",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"panelId": 11,
"refId": "A"
"rawFrameContent": "[{\r\n \"name\": \"releases\",\r\n\"fields\": [\r\n { \"name\": \"releases__time\", \"values\": [150, 250] },\r\n { \"name\": \"releases__tag\", \"values\": [\"v1.2\", \"v1.3\"] }\r\n]}]",
"refId": "releases",
"scenarioId": "raw_frame"
}
],
"title": "Same data (as a table)",
"title": "releases",
"type": "table"
},
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"fieldConfig": {
"defaults": {
@@ -204,7 +184,9 @@
},
"custom": {
"align": "auto",
"displayMode": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
@@ -224,14 +206,15 @@
"overrides": []
},
"gridPos": {
"h": 5,
"w": 24,
"x": 0,
"y": 9
"h": 8,
"w": 8,
"x": 16,
"y": 1
},
"id": 16,
"id": 19,
"options": {
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
@@ -240,24 +223,19 @@
},
"showHeader": true
},
"pluginVersion": "9.2.0-pre",
"pluginVersion": "9.4.0-pre",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"panelId": 11,
"refId": "A"
}
],
"title": "OUTER join on time (default)",
"transformations": [
{
"id": "joinByField",
"options": {}
"rawFrameContent": "[{\r\n \"name\": \"features\",\r\n\"fields\": [\r\n { \"name\": \"features__name\", \"values\": [\"A\", \"B\", \"C\", \"D\", \"E\"] },\r\n { \"name\": \"features__tag\", \"values\": [\"v1.2\", \"v1.3\", \"v1.2b\", \"v1.3\", \"v1.2\"] }\r\n]}]",
"refId": "features",
"scenarioId": "raw_frame"
}
],
"title": "features",
"type": "table"
},
{
@@ -266,11 +244,11 @@
"h": 1,
"w": 24,
"x": 0,
"y": 14
"y": 9
},
"id": 5,
"id": 21,
"panels": [],
"title": "Join by string field",
"title": "Output",
"type": "row"
},
{
@@ -285,7 +263,9 @@
},
"custom": {
"align": "auto",
"displayMode": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
@@ -308,202 +288,61 @@
"h": 8,
"w": 12,
"x": 0,
"y": 15
"y": 10
},
"id": 2,
"id": 23,
"options": {
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 0,
"showHeader": true
},
"pluginVersion": "9.2.0-pre",
"pluginVersion": "9.4.0-pre",
"targets": [
{
"csvContent": "OrderID,CustomerID,Time\n100,A,10000\n101,B,20000\n102,C,30000",
"datasource": {
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"refId": "Orders",
"scenarioId": "csv_content"
"rawFrameContent": "[{\r\n \"name\": \"tags\",\r\n \"fields\": [\r\n { \"name\": \"tags__time\", \"values\": [100, 101, 200] },\r\n { \"name\": \"tags__name\", \"values\": [\"v1.2\", \"v1.2b\", \"v1.3\"] }\r\n ]\r\n}]",
"refId": "tags",
"scenarioId": "raw_frame"
},
{
"csvContent": "CustomerID,Name,Country\nA,Customer A,USA\nB,Customer B,Germany\nC,Customer C,Spain\nD,Customer D,Canada",
"datasource": {
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"hide": false,
"refId": "Customers",
"scenarioId": "csv_content"
}
],
"title": "Orders",
"transformations": [],
"type": "table"
},
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"displayMode": "auto",
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
"rawFrameContent": "[{\r\n \"name\": \"releases\",\r\n \"fields\": [\r\n { \"name\": \"releases__time\", \"values\": [150, 250] },\r\n { \"name\": \"releases__tag\", \"values\": [\"v1.2\", \"v1.3\"] }\r\n]}]",
"refId": "releases",
"scenarioId": "raw_frame"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 15
},
"id": 3,
"options": {
"footer": {
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 1,
"showHeader": true
},
"pluginVersion": "9.2.0-pre",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"panelId": 2,
"refId": "A"
"rawFrameContent": "[{\r\n \"name\": \"features\",\r\n \"fields\": [\r\n { \"name\": \"features__name\", \"values\": [\"A\", \"B\", \"C\", \"D\", \"E\"] },\r\n { \"name\": \"features__tag\", \"values\": [\"v1.2\", \"v1.3\", \"v1.2b\", \"v1.3\", \"v1.2\"] }\r\n]}]",
"refId": "features",
"scenarioId": "raw_frame"
}
],
"title": "Customers",
"transformations": [],
"type": "table"
},
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"displayMode": "auto",
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "CustomerID"
},
"properties": [
{
"id": "custom.width",
"value": 101
}
]
},
{
"matcher": {
"id": "byName",
"options": "OrderID"
},
"properties": [
{
"id": "custom.width",
"value": 89
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 23
},
"id": 6,
"options": {
"footer": {
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 0,
"showHeader": true,
"sortBy": []
},
"pluginVersion": "9.2.0-pre",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
},
"panelId": 2,
"refId": "A"
}
],
"title": "OUTER join on CustomerID (keeps missing values)",
"title": "OUTER JOIN",
"transformations": [
{
"id": "joinByField",
"options": {
"byField": "CustomerID",
"fields": {
"A": "features__name",
"features": "features__tag",
"releases": "releases__tag",
"tags": "tags__name"
},
"mode": "outer"
}
}
@@ -512,8 +351,8 @@
},
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"fieldConfig": {
"defaults": {
@@ -522,7 +361,9 @@
},
"custom": {
"align": "auto",
"displayMode": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
@@ -539,69 +380,67 @@
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "CustomerID"
},
"properties": [
{
"id": "custom.width",
"value": 101
}
]
},
{
"matcher": {
"id": "byName",
"options": "OrderID"
},
"properties": [
{
"id": "custom.width",
"value": 89
}
]
}
]
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 23
"y": 10
},
"id": 7,
"id": 24,
"options": {
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 0,
"showHeader": true,
"sortBy": []
"showHeader": true
},
"pluginVersion": "9.2.0-pre",
"pluginVersion": "9.4.0-pre",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "-- Dashboard --"
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"panelId": 2,
"refId": "A"
"rawFrameContent": "[{\r\n \"name\": \"tags\",\r\n \"fields\": [\r\n { \"name\": \"tags__time\", \"values\": [100, 101, 200] },\r\n { \"name\": \"tags__name\", \"values\": [\"v1.2\", \"v1.2b\", \"v1.3\"] }\r\n ]\r\n}]",
"refId": "tags",
"scenarioId": "raw_frame"
},
{
"datasource": {
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"rawFrameContent": "[{\r\n \"name\": \"releases\",\r\n \"fields\": [\r\n { \"name\": \"releases__time\", \"values\": [150, 250] },\r\n { \"name\": \"releases__tag\", \"values\": [\"v1.2\", \"v1.3\"] }\r\n]}]",
"refId": "releases",
"scenarioId": "raw_frame"
},
{
"datasource": {
"type": "testdata",
"uid": "PD8C576611E62080A"
},
"rawFrameContent": "[{\r\n \"name\": \"features\",\r\n \"fields\": [\r\n { \"name\": \"features__name\", \"values\": [\"A\", \"B\", \"C\", \"D\", \"E\"] },\r\n { \"name\": \"features__tag\", \"values\": [\"v1.2\", \"v1.3\", \"v1.2b\", \"v1.3\", \"v1.2\"] }\r\n]}]",
"refId": "features",
"scenarioId": "raw_frame"
}
],
"title": "INNER join on CustomerID ",
"title": "INNER JOIN",
"transformations": [
{
"id": "joinByField",
"options": {
"byField": "CustomerID",
"fields": {
"A": "features__name",
"features": "features__tag",
"releases": "releases__tag",
"tags": "tags__name"
},
"mode": "inner"
}
}
@@ -609,7 +448,8 @@
"type": "table"
}
],
"schemaVersion": 37,
"revision": 1,
"schemaVersion": 38,
"style": "dark",
"tags": [
"gdev",
@@ -626,6 +466,6 @@
"timezone": "",
"title": "Join by field",
"uid": "gw0K4rmVz",
"version": 6,
"version": 1,
"weekStart": ""
}
}