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
1ad09f5d
Unverified
Commit
1ad09f5d
authored
7 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Just use default impl of table-rows-sample for Druid [ci drivers]
parent
7a46cfcb
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
src/metabase/driver.clj
+13
-8
13 additions, 8 deletions
src/metabase/driver.clj
src/metabase/driver/druid.clj
+1
-20
1 addition, 20 deletions
src/metabase/driver/druid.clj
with
14 additions
and
28 deletions
src/metabase/driver.clj
+
13
−
8
View file @
1ad09f5d
...
...
@@ -194,20 +194,25 @@
;; TODO - Not 100% sure we need this method since it seems like we could just use an MBQL query to fetch this info.
(
table-rows-sample
^
clojure.lang.Sequential
[
this,
^
TableInstance
table,
fields
]
"Return a sample of rows in TABLE with the specified FIELDS. This is used to implement some methods of the
"
*OPTIONAL*.
Return a sample of rows in TABLE with the specified FIELDS. This is used to implement some methods of the
database sync process which require rows of data during execution. At this time, this should just return a basic
sequence of rows in the fastest way possible, with no special sorting or any sort of randomization done to ensure
a good sample. (Improved sampling is something we plan to add in the future.)
The sample should return up to `max-sample-rows` rows, which is currently `10000`."
))
(
defn-
table-rows-sample-via-qp
[
_
table
fields
]
(
let
[
results
((
resolve
'metabase.query-processor/process-query
)
{
:database
(
:db_id
table
)
:type
:query
:query
{
:source-table
(
u/get-id
table
)
:fields
(
vec
(
for
[
field
fields
]
[
:field-id
(
u/get-id
field
)]))
:limit
max-sample-rows
}})]
(
defn-
table-rows-sample-via-qp
"Default implementation of `table-rows-sample` that just runs a basic MBQL query to fetch values for a Table.
Prefer this to writing your own implementation of `table-rows-sample`; those are around for purely historical
reasons and may be removed in the future."
[
_
table
fields
]
(
let
[
results
((
resolve
'metabase.query-processor/process-query
)
{
:database
(
:db_id
table
)
:type
:query
:query
{
:source-table
(
u/get-id
table
)
:fields
(
vec
(
for
[
field
fields
]
[
:field-id
(
u/get-id
field
)]))
:limit
max-sample-rows
}})]
(
get-in
results
[
:data
:rows
])))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/druid.clj
+
1
−
20
View file @
1ad09f5d
...
...
@@ -63,7 +63,6 @@
(
let
[
message
(
or
(
u/ignore-exceptions
(
:error
(
json/parse-string
(
:body
(
:object
(
ex-data
e
)))
keyword
)))
(
.getMessage
e
))]
(
log/error
(
u/format-color
'red
"Error running query:\n%s"
message
))
;; Re-throw a new exception with `message` set to the extracted message
(
throw
(
Exception.
message
e
)))))))
...
...
@@ -100,23 +99,6 @@
{
:schema
nil,
:name
table-name
}))})))
;;; ### table-rows-sample
(
defn-
table-rows-sample
[
table
fields
]
(
let
[
db-details
(
db/select-one-field
:details
Database
:id
(
:db_id
table
))
[
results
]
(
do-query
db-details
{
:queryType
:select
:dataSource
(
:name
table
)
:intervals
[
"1900-01-01/2100-01-01"
]
:granularity
:all
:dimensions
(
map
:name
fields
)
:metrics
[]
:pagingSpec
{
:threshold
driver/max-sample-rows
}})]
;; Unnest the values
(
for
[
event
(
get-in
results
[
:result
:events
])]
(
for
[
field
fields
]
(
get-in
event
[
:event
(
keyword
(
:name
field
))])))))
;;; ### DruidrDriver Class Definition
(
defrecord
DruidDriver
[]
...
...
@@ -139,10 +121,9 @@
:default
8082
}]))
:execute-query
(
fn
[
_
query
]
(
qp/execute-query
do-query
query
))
:features
(
constantly
#
{
:basic-aggregations
:set-timezone
:expression-aggregations
})
:table-rows-sample
(
u/drop-first-arg
table-rows-sample
)
:mbql->native
(
u/drop-first-arg
qp/mbql->native
)}))
(
defn
-init-driver
"Register the druid driver
1
"
"Register the druid driver
.
"
[]
(
driver/register-driver!
:druid
(
DruidDriver.
)))
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