Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
blendb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
C3SL
blendb
Commits
47edbd30
Commit
47edbd30
authored
Aug 18, 2017
by
Lucas Fernandes de Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#39
: Add MAX and MIN aggregations
Signed-off-by:
Lucas Fernandes de Oliveira
<
lfo14@inf.ufpr.br
>
parent
69a6dc23
Pipeline
#11534
passed with stage
in 41 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
35 deletions
+52
-35
config/ci_test.yaml.example
config/ci_test.yaml.example
+10
-0
src/adapter/postgres.spec.ts
src/adapter/postgres.spec.ts
+2
-0
src/adapter/postgres.ts
src/adapter/postgres.ts
+4
-0
src/common/types.ts
src/common/types.ts
+3
-1
src/core/engine.spec.ts
src/core/engine.spec.ts
+21
-26
src/util/configParser.ts
src/util/configParser.ts
+4
-0
test/postgres/fixtures/view8.json
test/postgres/fixtures/view8.json
+5
-5
test/scenario.ts
test/scenario.ts
+3
-3
No files found.
config/ci_test.yaml.example
View file @
47edbd30
...
...
@@ -93,6 +93,8 @@ schema:
- "dim:6"
metrics:
- "met:9"
- "met:10"
- "met:11"
-
alias: "view 9"
data: "test/postgres/fixtures/view9.json"
...
...
@@ -146,6 +148,14 @@ schema:
name: "met:9"
dataType: "integer"
aggregation: "count"
-
name: "met:10"
dataType: "integer"
aggregation: "max"
-
name: "met:11"
dataType: "integer"
aggregation: "min"
dimensions:
-
name: "dim:0"
...
...
src/adapter/postgres.spec.ts
View file @
47edbd30
...
...
@@ -166,6 +166,8 @@ describe("postgres adapter", () => {
expect
(
parseInt
(
result
[
0
][
"
met:0
"
],
10
)).
to
.
be
.
equal
(
15
);
expect
(
parseInt
(
result
[
0
][
"
met:1
"
],
10
)).
to
.
be
.
equal
(
3
);
expect
(
parseInt
(
result
[
0
][
"
met:6
"
],
10
)).
to
.
be
.
equal
(
5
);
expect
(
parseInt
(
result
[
0
][
"
met:10
"
],
10
)).
to
.
be
.
equal
(
5
);
expect
(
parseInt
(
result
[
0
][
"
met:11
"
],
10
)).
to
.
be
.
equal
(
1
);
done
();
});
});
...
...
src/adapter/postgres.ts
View file @
47edbd30
...
...
@@ -213,6 +213,10 @@ export class PostgresAdapter extends Adapter {
return
"
AVG
"
;
case
AggregationType
.
COUNT
:
return
(
origin
)
?
"
COUNT
"
:
"
SUM
"
;
case
AggregationType
.
MAX
:
return
"
MAX
"
;
case
AggregationType
.
MIN
:
return
"
MIN
"
;
default
:
return
""
;
}
...
...
src/common/types.ts
View file @
47edbd30
...
...
@@ -22,7 +22,9 @@ export enum AggregationType {
NONE
,
SUM
,
AVG
,
COUNT
COUNT
,
MAX
,
MIN
};
export
enum
RelationType
{
...
...
src/core/engine.spec.ts
View file @
47edbd30
...
...
@@ -22,7 +22,6 @@ import { expect } from "chai";
import
{
Engine
}
from
"
./engine
"
;
import
{
Metric
}
from
"
./metric
"
;
import
{
Dimension
}
from
"
./dimension
"
;
import
{
Filter
,
FilterOperator
}
from
"
./filter
"
;
import
{
Clause
}
from
"
./clause
"
;
import
{
View
}
from
"
./view
"
;
...
...
@@ -31,25 +30,33 @@ import { engineScenario } from "../../test/scenario";
describe
(
"
engine class
"
,
()
=>
{
const
engine
=
new
Engine
();
const
met
=
engineScenario
.
metrics
;
const
dim
=
engineScenario
.
dimensions
;
const
subdim
=
engineScenario
.
subDimensions
;
const
met
=
engineScenario
.
metrics
.
sort
((
a
,
b
)
=>
{
const
aValue
=
parseInt
(
a
.
name
.
split
(
"
:
"
)[
1
],
10
);
const
bValue
=
parseInt
(
b
.
name
.
split
(
"
:
"
)[
1
],
10
);
return
aValue
-
bValue
;
});
const
dim
=
engineScenario
.
dimensions
.
sort
((
a
,
b
)
=>
{
const
aValue
=
parseInt
(
a
.
name
.
split
(
"
:
"
)[
1
],
10
);
const
bValue
=
parseInt
(
b
.
name
.
split
(
"
:
"
)[
1
],
10
);
return
aValue
-
bValue
;
});
const
subdim
=
engineScenario
.
subDimensions
.
sort
((
a
,
b
)
=>
{
const
aValue
=
parseInt
(
a
.
name
.
split
(
"
:
"
)[
1
],
10
);
const
bValue
=
parseInt
(
b
.
name
.
split
(
"
:
"
)[
1
],
10
);
return
aValue
-
bValue
;
});
const
views
=
engineScenario
.
views
;
for
(
let
i
=
0
;
i
<
10
;
++
i
)
{
engine
.
addMetric
(
met
[
i
]);
engine
.
addDimension
(
dim
[
i
]);
if
(
i
<
5
)
{
engine
.
addDimension
(
subdim
[
i
]);
}
}
met
.
forEach
((
item
)
=>
engine
.
addMetric
(
item
));
dim
.
forEach
((
item
)
=>
engine
.
addDimension
(
item
));
subdim
.
forEach
((
item
)
=>
engine
.
addDimension
(
item
));
views
.
forEach
((
view
)
=>
engine
.
addView
(
view
));
it
(
"
should be create a fill that cover all metrics and dimensions
"
,
()
=>
{
let
query
=
{
metrics
:
met
,
dimensions
:
dim
metrics
:
met
.
slice
(
0
)
,
dimensions
:
dim
.
slice
(
0
)
};
let
optimalView
=
engine
.
query
(
query
);
expect
(
optimalView
).
to
.
be
.
an
(
"
object
"
);
...
...
@@ -59,20 +66,8 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
1
0
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
1
2
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
9
);
let
metAux
:
number
[]
=
optimalView
.
metrics
.
sort
().
map
((
item
:
Metric
)
=>
{
return
Number
(
item
.
name
.
split
(
"
:
"
)[
1
]);
});
let
dimAux
:
number
[]
=
optimalView
.
dimensions
.
sort
().
map
((
item
:
Dimension
)
=>
{
return
Number
(
item
.
name
.
split
(
"
:
"
)[
1
]);
});
for
(
let
i
:
number
=
0
;
i
<
9
;
++
i
)
{
expect
(
dimAux
[
i
]).
to
.
be
.
equal
(
i
);
expect
(
metAux
[
i
]).
to
.
be
.
equal
(
i
);
}
expect
(
metAux
[
9
]).
to
.
be
.
equal
(
9
);
});
it
(
"
should throw an exception, query with non-existent metric
"
,
()
=>
{
let
error
:
boolean
=
false
;
...
...
src/util/configParser.ts
View file @
47edbd30
...
...
@@ -271,6 +271,10 @@ export class ConfigParser {
return
AggregationType
.
AVG
;
case
"
count
"
:
return
AggregationType
.
COUNT
;
case
"
min
"
:
return
AggregationType
.
MIN
;
case
"
max
"
:
return
AggregationType
.
MAX
;
default
:
return
AggregationType
.
NONE
;
}
...
...
test/postgres/fixtures/view8.json
View file @
47edbd30
[
{
"dim:5"
:
"t"
,
"dim:6"
:
"1"
,
"met:9"
:
"1"
},
{
"dim:5"
:
"t"
,
"dim:6"
:
"2"
,
"met:9"
:
"2"
},
{
"dim:5"
:
"t"
,
"dim:6"
:
"3"
,
"met:9"
:
"3"
},
{
"dim:5"
:
"f"
,
"dim:6"
:
"4"
,
"met:9"
:
"4"
},
{
"dim:5"
:
"f"
,
"dim:6"
:
"5"
,
"met:9"
:
"5"
}
{
"dim:5"
:
"t"
,
"dim:6"
:
"1"
,
"met:9"
:
"1"
,
"met:10"
:
"1"
,
"met:11"
:
"1"
},
{
"dim:5"
:
"t"
,
"dim:6"
:
"2"
,
"met:9"
:
"2"
,
"met:10"
:
"2"
,
"met:11"
:
"2"
},
{
"dim:5"
:
"t"
,
"dim:6"
:
"3"
,
"met:9"
:
"3"
,
"met:10"
:
"3"
,
"met:11"
:
"3"
},
{
"dim:5"
:
"f"
,
"dim:6"
:
"4"
,
"met:9"
:
"4"
,
"met:10"
:
"4"
,
"met:11"
:
"4"
},
{
"dim:5"
:
"f"
,
"dim:6"
:
"5"
,
"met:9"
:
"5"
,
"met:10"
:
"5"
,
"met:11"
:
"5"
}
]
test/scenario.ts
View file @
47edbd30
...
...
@@ -127,7 +127,7 @@ const clauses: { [key: string]: Clause } = {
};
const
wrongMet
=
new
Metric
({
name
:
"
met:
1
1
"
,
name
:
"
met:
-
1
"
,
aggregation
:
AggregationType
.
COUNT
,
dataType
:
"
integer
"
});
...
...
@@ -204,11 +204,11 @@ const dateView = new View({
});
const
aggrView
=
new
View
({
metrics
:
[
mets
[
0
],
mets
[
1
],
mets
[
6
]],
metrics
:
[
mets
[
0
],
mets
[
1
],
mets
[
6
]
,
mets
[
10
],
mets
[
11
]
],
dimensions
:
[],
materialized
:
false
,
origin
:
false
,
childViews
:
[
views
[
0
],
views
[
2
],
views
[
4
]]
childViews
:
[
views
[
0
],
views
[
2
],
views
[
3
],
views
[
4
],
views
[
7
],
views
[
8
]]
});
const
clauseView
=
new
View
({
...
...
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