Skip to content

Commit

Permalink
Support latest DataFrames version
Browse files Browse the repository at this point in the history
- Explicitly pull in DataArrays
- Use missing instead of NA and ismissing instead of isna
- Use new signature for sort!
- Stop testing on 0.5
  • Loading branch information
bluesmoon committed May 20, 2018
1 parent 911a64e commit 2c4aa9d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ os:
- linux
julia:
- 0.4
- 0.5
- 0.6
notifications:
email: false
Expand Down
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ LightXML
HttpCommon
HttpParser 0.2.0
JSON
DataFrames 0.7.3 0.11-
DataFrames 0.7.3
DataArrays
Formatting
23 changes: 19 additions & 4 deletions src/QueryAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
#
###################################################

using DataFrames, JSON, Formatting
using DataFrames, DataArrays, JSON, Formatting

if isdefined(:Missings) && isdefined(:missing)
const nullval = missing
elseif isdefined(:NA)
const nullval = NA
ismissing = isna
else
const nullval = nothing
ismissing(x) = (x == nothing)
ismissing(x::AbstractVector) = (x .== nothing)
end

const query_types = [
"summary",
Expand Down Expand Up @@ -564,9 +575,9 @@ function getTimersMetrics(token::AbstractString, appKey::AbstractString; filters
df[name] = history
end

df[nulls] = NA
df[nulls] = nullval

if nrow(df) > 1 && all(a -> isna(a) || a == 0, stack(df[end-1, :], names(df))[:value])
if nrow(df) > 1 && all(a -> ismissing(a) || a == 0, stack(df[end-1, :], names(df))[:value])
# mPulse bug 115785: If penultimate row is all 0s/NAs, remove it
return df[[1:end-2; end], :]
else
Expand Down Expand Up @@ -883,7 +894,11 @@ function mergeMetrics(df1::DataFrame, df2::DataFrame...; keyField::Symbol=:t_don
df = join(df, next, on=keyField, kind=joinType)
end

sort!(df, cols = [keyField])
if length(methods(sort!, [DataFrame, Any])) >= 1
sort!(df, keyField)
else
sort!(df, cols = [keyField])
end
return df
end

Expand Down
2 changes: 1 addition & 1 deletion test/query-tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DataFrames
using DataFrames, DataArrays

token = getRepositoryToken(mPulseAPITenant, mPulseAPIToken)
domain = getRepositoryDomain(token, appName="mPulse Demo")
Expand Down

0 comments on commit 2c4aa9d

Please sign in to comment.