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
24086c63
Unverified
Commit
24086c63
authored
Dec 02, 2020
by
Ryan McKinley
Committed by
GitHub
Dec 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arrow: toArray() on nullable values should include null values (#29520)
parent
df0ef187
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
11 deletions
+29
-11
packages/grafana-data/src/dataframe/ArrowDataFrame.ts
+23
-0
packages/grafana-data/src/dataframe/__snapshots__/ArrowDataFrame.test.ts.snap
+1
-1
packages/grafana-data/src/dataframe/processDataFrame.ts
+4
-9
packages/grafana-runtime/src/utils/queryResponse.test.ts
+1
-1
No files found.
packages/grafana-data/src/dataframe/ArrowDataFrame.ts
View file @
24086c63
...
...
@@ -55,6 +55,9 @@ export function arrowTableToDataFrame(table: Table): ArrowDataFrame {
case
ArrowType
.
Decimal
:
case
ArrowType
.
FloatingPoint
:
{
type
=
FieldType
.
number
;
if
(
col
.
nullCount
)
{
values
=
new
WrappedColumn
(
col
);
}
break
;
}
case
ArrowType
.
Int
:
{
...
...
@@ -64,6 +67,9 @@ export function arrowTableToDataFrame(table: Table): ArrowDataFrame {
}
case
ArrowType
.
Bool
:
{
type
=
FieldType
.
boolean
;
if
(
col
.
nullCount
)
{
values
=
new
WrappedColumn
(
col
);
}
break
;
}
case
ArrowType
.
Timestamp
:
{
...
...
@@ -202,3 +208,20 @@ class NumberColumn extends FunctionalVector<number> {
return
Number
(
v
);
}
}
// The `toArray()` arrow function will return a native ArrayBuffer -- this works fine
// if there are no null values, but the native arrays do not support nulls. This
// class simply wraps the vector so `toArray` creates a new array
class
WrappedColumn
extends
FunctionalVector
{
constructor
(
private
col
:
Column
)
{
super
();
}
get
length
()
{
return
this
.
col
.
length
;
}
get
(
index
:
number
):
number
{
return
this
.
col
.
get
(
index
);
}
}
packages/grafana-data/src/dataframe/__snapshots__/ArrowDataFrame.test.ts.snap
View file @
24086c63
...
...
@@ -265,7 +265,7 @@ Object {
"labels": undefined,
"name": "float32_values",
"type": "number",
"values": Array [
"values":
Float32
Array [
1.401298464324817e-45,
1.401298464324817e-45,
1,
...
...
packages/grafana-data/src/dataframe/processDataFrame.ts
View file @
24086c63
...
...
@@ -24,6 +24,7 @@ import { SortedVector } from '../vector/SortedVector';
import
{
ArrayDataFrame
}
from
'./ArrayDataFrame'
;
import
{
getFieldDisplayName
}
from
'../field/fieldState'
;
import
{
fieldIndexComparer
}
from
'../field/fieldComparers'
;
import
{
vectorToArray
}
from
'../vector/vectorToArray'
;
function
convertTableToDataFrame
(
table
:
TableData
):
DataFrame
{
const
fields
=
table
.
columns
.
map
(
c
=>
{
...
...
@@ -444,16 +445,10 @@ export function getDataFrameRow(data: DataFrame, row: number): any[] {
export
function
toDataFrameDTO
(
data
:
DataFrame
):
DataFrameDTO
{
const
fields
:
FieldDTO
[]
=
data
.
fields
.
map
(
f
=>
{
let
values
=
f
.
values
.
toArray
();
if
(
!
Array
.
isArray
(
values
))
{
// Apache arrow will pack objects into typed arrays
// Float64Array, etc
// TODO: Float64Array could be used directly
values
=
[];
for
(
let
i
=
0
;
i
<
f
.
values
.
length
;
i
++
)
{
values
.
push
(
f
.
values
.
get
(
i
));
}
// The byte buffers serialize like objects
if
(
values
instanceof
Float64Array
)
{
values
=
vectorToArray
(
f
.
values
);
}
return
{
name
:
f
.
name
,
type
:
f
.
type
,
...
...
packages/grafana-runtime/src/utils/queryResponse.test.ts
View file @
24086c63
...
...
@@ -37,7 +37,7 @@ const emptyResults = {
/* eslint-enable */
describe
(
'
GEL Utils
'
,
()
=>
{
describe
(
'
Query Response parser
'
,
()
=>
{
test
(
'should parse output with dataframe'
,
()
=>
{
const
res
=
toDataQueryResponse
(
resp
);
const
frames
=
res
.
data
;
...
...
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