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
7c8b4915
Commit
7c8b4915
authored
Oct 19, 2018
by
Sven Klemm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix order for mysql, remove postgres specific code
parent
8ce7e113
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
54 deletions
+2
-54
public/app/plugins/datasource/mysql/mysql_query.ts
+2
-54
No files found.
public/app/plugins/datasource/mysql/mysql_query.ts
View file @
7c8b4915
...
...
@@ -152,64 +152,12 @@ export default class MysqlQuery {
const
columnName
=
_
.
find
(
column
,
(
g
:
any
)
=>
g
.
type
===
'column'
);
query
=
columnName
.
params
[
0
];
const
aggregate
=
_
.
find
(
column
,
(
g
:
any
)
=>
g
.
type
===
'aggregate'
||
g
.
type
===
'percentile'
);
const
windows
=
_
.
find
(
column
,
(
g
:
any
)
=>
g
.
type
===
'window'
||
g
.
type
===
'moving_window'
);
const
aggregate
=
_
.
find
(
column
,
(
g
:
any
)
=>
g
.
type
===
'aggregate'
);
if
(
aggregate
)
{
const
func
=
aggregate
.
params
[
0
];
switch
(
aggregate
.
type
)
{
case
'aggregate'
:
if
(
func
===
'first'
||
func
===
'last'
)
{
query
=
func
+
'('
+
query
+
','
+
this
.
target
.
timeColumn
+
')'
;
}
else
{
query
=
func
+
'('
+
query
+
')'
;
}
break
;
case
'percentile'
:
query
=
func
+
'('
+
aggregate
.
params
[
1
]
+
') WITHIN GROUP (ORDER BY '
+
query
+
')'
;
break
;
}
}
if
(
windows
)
{
const
overParts
=
[];
if
(
this
.
hasMetricColumn
())
{
overParts
.
push
(
'PARTITION BY '
+
this
.
target
.
metricColumn
);
}
overParts
.
push
(
'ORDER BY '
+
this
.
buildTimeColumn
(
false
));
const
over
=
overParts
.
join
(
' '
);
let
curr
:
string
;
let
prev
:
string
;
switch
(
windows
.
type
)
{
case
'window'
:
switch
(
windows
.
params
[
0
])
{
case
'increase'
:
curr
=
query
;
prev
=
'lag('
+
curr
+
') OVER ('
+
over
+
')'
;
query
=
'(CASE WHEN '
+
curr
+
' >= '
+
prev
+
' THEN '
+
curr
+
' - '
+
prev
+
' ELSE '
+
curr
+
' END)'
;
break
;
case
'rate'
:
let
timeColumn
=
this
.
target
.
timeColumn
;
if
(
aggregate
)
{
timeColumn
=
'min('
+
timeColumn
+
')'
;
}
curr
=
query
;
prev
=
'lag('
+
curr
+
') OVER ('
+
over
+
')'
;
query
=
'(CASE WHEN '
+
curr
+
' >= '
+
prev
+
' THEN '
+
curr
+
' - '
+
prev
+
' ELSE '
+
curr
+
' END)'
;
query
+=
'/extract(epoch from '
+
timeColumn
+
' - lag('
+
timeColumn
+
') OVER ('
+
over
+
'))'
;
break
;
default
:
query
=
windows
.
params
[
0
]
+
'('
+
query
+
') OVER ('
+
over
+
')'
;
break
;
}
break
;
case
'moving_window'
:
query
=
windows
.
params
[
0
]
+
'('
+
query
+
') OVER ('
+
over
+
' ROWS '
+
windows
.
params
[
1
]
+
' PRECEDING)'
;
break
;
}
}
const
alias
=
_
.
find
(
column
,
(
g
:
any
)
=>
g
.
type
===
'alias'
);
if
(
alias
)
{
...
...
@@ -278,7 +226,7 @@ export default class MysqlQuery {
query
+=
this
.
buildWhereClause
();
query
+=
this
.
buildGroupClause
();
query
+=
'
\
nORDER BY
1'
;
query
+=
'
\
nORDER BY
'
+
this
.
buildTimeColumn
(
false
)
;
return
query
;
}
...
...
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