Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
883d7cb5
Unverified
Commit
883d7cb5
authored
Sep 09, 2020
by
Hugo Häggmark
Committed by
GitHub
Sep 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OuterJoin: Fixes transformation when data is missing field to join by (#27453)
parent
023054bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
packages/grafana-data/src/transformations/transformers/seriesToColumns.test.ts
+58
-0
packages/grafana-data/src/transformations/transformers/seriesToColumns.ts
+3
-3
No files found.
packages/grafana-data/src/transformations/transformers/seriesToColumns.test.ts
View file @
883d7cb5
...
...
@@ -288,4 +288,62 @@ describe('SeriesToColumns Transformer', () => {
expect
(
filtered
.
fields
).
toEqual
(
expected
);
});
});
it
(
'joins if fields are missing'
,
()
=>
{
const
cfg
:
DataTransformerConfig
<
SeriesToColumnsOptions
>
=
{
id
:
DataTransformerID
.
seriesToColumns
,
options
:
{
byField
:
'time'
,
},
};
const
frame1
=
toDataFrame
({
name
:
'A'
,
fields
:
[
{
name
:
'time'
,
type
:
FieldType
.
time
,
values
:
[
1
,
2
,
3
]
},
{
name
:
'temperature'
,
type
:
FieldType
.
number
,
values
:
[
10
,
11
,
12
]
},
],
});
const
frame2
=
toDataFrame
({
name
:
'B'
,
fields
:
[],
});
const
frame3
=
toDataFrame
({
name
:
'C'
,
fields
:
[
{
name
:
'time'
,
type
:
FieldType
.
time
,
values
:
[
1
,
2
,
3
]
},
{
name
:
'temperature'
,
type
:
FieldType
.
number
,
values
:
[
20
,
22
,
24
]
},
],
});
const
filtered
=
transformDataFrame
([
cfg
],
[
frame1
,
frame2
,
frame3
])[
0
];
expect
(
filtered
.
fields
).
toEqual
([
{
name
:
'time'
,
state
:
{
displayName
:
'time'
},
type
:
FieldType
.
time
,
values
:
new
ArrayVector
([
1
,
2
,
3
]),
config
:
{},
},
{
name
:
'temperature'
,
state
:
{
displayName
:
'temperature A'
},
type
:
FieldType
.
number
,
values
:
new
ArrayVector
([
10
,
11
,
12
]),
config
:
{},
labels
:
{
name
:
'A'
},
},
{
name
:
'temperature'
,
state
:
{
displayName
:
'temperature C'
},
type
:
FieldType
.
number
,
values
:
new
ArrayVector
([
20
,
22
,
24
]),
config
:
{},
labels
:
{
name
:
'C'
},
},
]);
});
});
packages/grafana-data/src/transformations/transformers/seriesToColumns.ts
View file @
883d7cb5
...
...
@@ -26,7 +26,7 @@ export const seriesToColumnsTransformer: DataTransformerInfo<SeriesToColumnsOpti
const
keyField
=
findKeyField
(
frame
,
keyFieldMatch
);
if
(
!
keyField
)
{
return
data
;
continue
;
}
for
(
let
fieldIndex
=
0
;
fieldIndex
<
frame
.
fields
.
length
;
fieldIndex
++
)
{
...
...
@@ -74,8 +74,8 @@ export const seriesToColumnsTransformer: DataTransformerInfo<SeriesToColumnsOpti
const
keyFieldTitle
=
getFieldDisplayName
(
resultFrame
.
fields
[
0
],
resultFrame
);
const
byKeyField
:
{
[
key
:
string
]:
{
[
key
:
string
]:
any
}
}
=
{};
/*
this loop creates a dictionary object that groups the key fields values
/*
this loop creates a dictionary object that groups the key fields values
{
"key field first value as string" : {
"key field name": key field first value,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment