Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
69da1097
Commit
69da1097
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
convert some more tests to be Mongo + H2
parent
2f32181f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/metabase/driver/generic_sql/query_processor_test.clj
+0
-38
0 additions, 38 deletions
test/metabase/driver/generic_sql/query_processor_test.clj
test/metabase/driver/query_processor_test.clj
+45
-3
45 additions, 3 deletions
test/metabase/driver/query_processor_test.clj
with
45 additions
and
41 deletions
test/metabase/driver/generic_sql/query_processor_test.clj
+
0
−
38
View file @
69da1097
...
...
@@ -16,44 +16,6 @@
{
:extra_info
{}
:special_type
nil,
:base_type
:TextField,
:description
nil,
:name
"NAME"
,
:table_id
(
table->id
:venues
)
,
:id
(
field->id
:venues
:name
)}]))
;; ## "SUM" AGGREGATION
(
expect
{
:status
:completed
:row_count
1
:data
{
:rows
[[
203
]]
:columns
[
"sum"
]
:cols
[{
:base_type
:IntegerField
:special_type
:category
:name
"sum"
:id
nil
:table_id
nil
:description
nil
}]}}
(
driver/process-query
{
:type
:query
:database
@
db-id
:query
{
:source_table
(
table->id
:venues
)
:filter
[
nil
nil
]
:aggregation
[
"sum"
(
field->id
:venues
:price
)]
:breakout
[
nil
]
:limit
nil
}}))
;; ## "DISTINCT COUNT" AGGREGATION
(
expect
{
:status
:completed
:row_count
1
:data
{
:rows
[[
15
]]
:columns
[
"count"
]
:cols
[{
:base_type
:IntegerField
:special_type
:number
:name
"count"
:id
nil
:table_id
nil
:description
nil
}]}}
(
driver/process-query
{
:type
:query
:database
@
db-id
:query
{
:source_table
(
table->id
:checkins
)
:filter
[
nil
nil
]
:aggregation
[
"distinct"
(
field->id
:checkins
:user_id
)]
:breakout
[
nil
]
:limit
nil
}}))
;; ## "AVG" AGGREGATION
;; TODO - try this with an integer field. (Should the average of an integer field be a float or an int?)
(
expect
{
:status
:completed,
...
...
This diff is collapsed.
Click to expand it.
test/metabase/driver/query_processor_test.clj
+
45
−
3
View file @
69da1097
...
...
@@ -17,21 +17,26 @@
(
db
[
this
]
"Return `Database` containing test data for this driver."
)
(
table-name->table
[
this
table-name
]
"Given a TABLE-NAME keyword like `:venues`, *fetch* the corresponding `Table`."
))
"Given a TABLE-NAME keyword like `:venues`, *fetch* the corresponding `Table`."
)
(
field-name->id
[
this
table-name
field-name
]))
(
deftype
MongoDriverData
[]
DriverData
(
db
[
_
]
@
mongo-data/mongo-test-db
)
(
table-name->table
[
_
table-name
]
(
mongo-data/table-name->table
table-name
)))
(
mongo-data/table-name->table
table-name
))
(
field-name->id
[
_
table-name
field-name
]
(
mongo-data/field-name->id
table-name
field-name
)))
(
deftype
GenericSqlDriverData
[]
DriverData
(
db
[
_
]
@
generic-sql-data/test-db
)
(
table-name->table
[
_
table-name
]
(
generic-sql-data/table-name->table
table-name
)))
(
generic-sql-data/table-name->table
table-name
))
(
field-name->id
[
_
table-name
field-name
]
(
generic-sql-data/field->id
table-name
field-name
)))
(
def
driver-name->driver-data
{
:mongo
(
MongoDriverData.
)
...
...
@@ -94,6 +99,11 @@
;; {:pre [(integer? *db-id*)]}
;; (-table-name->id *db-id* table-name))))
(
defn
->field-id
[
table-name
field-name
]
{
:pre
[
*driver-data*
]
:post
[(
integer?
%
)]}
(
field-name->id
*driver-data*
table-name
field-name
))
;; ## Driver-Independent QP Tests
...
...
@@ -123,3 +133,35 @@
:aggregation
[
"count"
]
:breakout
[
nil
]
:limit
nil
})
;; ### "SUM" AGGREGATION
(
qp-expect-with-all-drivers
{
:rows
[[
203
]]
:columns
[
"sum"
]
:cols
[{
:base_type
:IntegerField
:special_type
:category
:name
"sum"
:id
nil
:table_id
nil
:description
nil
}]}
{
:source_table
(
->table-id
:venues
)
:filter
[
nil
nil
]
:aggregation
[
"sum"
(
->field-id
:venues
:price
)]
:breakout
[
nil
]
:limit
nil
})
;; ### "DISTINCT COUNT" AGGREGATION
(
qp-expect-with-all-drivers
{
:rows
[[
15
]]
:columns
[
"count"
]
:cols
[{
:base_type
:IntegerField
:special_type
:number
:name
"count"
:id
nil
:table_id
nil
:description
nil
}]}
{
:source_table
(
->table-id
:checkins
)
:filter
[
nil
nil
]
:aggregation
[
"distinct"
(
->field-id
:checkins
:user_id
)]
:breakout
[
nil
]
:limit
nil
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment