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
443da22c
Unverified
Commit
443da22c
authored
7 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Fix sync type inference for MongoDB completely null fields
parent
a3936976
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/mongo.clj
+2
-2
2 additions, 2 deletions
src/metabase/driver/mongo.clj
test/metabase/driver/mongo_test.clj
+12
-0
12 additions, 0 deletions
test/metabase/driver/mongo_test.clj
with
14 additions
and
2 deletions
src/metabase/driver/mongo.clj
+
2
−
2
View file @
443da22c
...
...
@@ -106,12 +106,12 @@
(
find-nested-fields
field-value
nested-fields
)
nested-fields
)))))
(
s/defn
^
:private
most-common-object-type
:-
Class
(
s/defn
^
:private
^
Class
most-common-object-type
:-
(
s/maybe
Class
)
"Given a sequence of tuples like [Class <number-of-occurances>] return the Class with the highest number of
occurances. The basic idea here is to take a sample of values for a Field and then determine the most common type
for its values, and use that as the Metabase base type. For example if we have a Field called `zip_code` and it's a
number 90% of the time and a string the other 10%, we'll just call it a `:type/Number`."
[
field-types
:-
[(
s/pair
Class
"Class"
,
s/Int
"Int"
)]]
[
field-types
:-
[(
s/pair
(
s/maybe
Class
)
"Class"
,
s/Int
"Int"
)]]
(
->>
field-types
(
sort-by
second
)
last
...
...
This diff is collapsed.
Click to expand it.
test/metabase/driver/mongo_test.clj
+
12
−
0
View file @
443da22c
...
...
@@ -6,6 +6,7 @@
[
driver
:as
driver
]
[
query-processor
:as
qp
]
[
query-processor-test
:refer
[
rows
]]]
[
metabase.driver.mongo
:as
mongo
]
[
metabase.driver.mongo.query-processor
:as
mongo-qp
]
[
metabase.models
[
field
:refer
[
Field
]]
...
...
@@ -237,3 +238,14 @@
:collection
"venues"
}
:type
:native
:database
(
data/id
)}))))
;; tests for `most-common-object-type`
(
expect
String
(
#
'mongo/most-common-object-type
[[
Float
20
]
[
Integer
10
]
[
String
30
]]))
;; make sure it handles `nil` types correctly as well (#6880)
(
expect
nil
(
#
'mongo/most-common-object-type
[[
Float
20
]
[
nil
40
]
[
Integer
10
]
[
String
30
]]))
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