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
633bc899
Commit
633bc899
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Make most sync output 'debug' instead of 'info' - unclutter tests
parent
12284579
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/sync.clj
+12
-12
12 additions, 12 deletions
src/metabase/driver/sync.clj
test/metabase/test/data.clj
+0
-1
0 additions, 1 deletion
test/metabase/test/data.clj
with
12 additions
and
13 deletions
src/metabase/driver/sync.clj
+
12
−
12
View file @
633bc899
...
...
@@ -66,7 +66,7 @@
(
let
[
existing-table-names
(
set
(
keys
table-name->id
))
new-table-names
(
set/difference
active-table-names
existing-table-names
)]
(
when
(
seq
new-table-names
)
(
log/
info
(
u/format-color
'blue
"Found new tables: %s"
new-table-names
))
(
log/
debug
(
u/format-color
'blue
"Found new tables: %s"
new-table-names
))
(
doseq
[
new-table-name
new-table-names
]
(
ins
Table
:db_id
(
:id
database
)
,
:active
true,
:name
new-table-name
)))))
...
...
@@ -186,7 +186,7 @@
{
:pre
[(
set?
pk-fields
)
(
every?
string?
pk-fields
)]}
(
doseq
[{
field-name
:name
field-id
:id
}
(
sel
:many
:fields
[
Field
:name
:id
]
,
:table_id
(
:id
table
)
,
:special_type
nil,
:name
[
in
pk-fields
]
,
:parent_id
nil
)]
(
log/
info
(
u/format-color
'green
"Field '%s.%s' is a primary key. Marking it as such."
(
:name
table
)
field-name
))
(
log/
debug
(
u/format-color
'green
"Field '%s.%s' is a primary key. Marking it as such."
(
:name
table
)
field-name
))
(
upd
Field
field-id
:special_type
:id
)))
(
defn-
sync-table-active-fields-and-pks!
...
...
@@ -212,7 +212,7 @@
(
let
[
existing-field-names
(
set
(
keys
existing-field-name->field
))
new-field-names
(
set/difference
(
set
(
keys
active-column-names->type
))
existing-field-names
)]
(
when
(
seq
new-field-names
)
(
log/
info
(
u/format-color
'blue
"Found new fields for table '%s': %s"
(
:name
table
)
new-field-names
)))
(
log/
debug
(
u/format-color
'blue
"Found new fields for table '%s': %s"
(
:name
table
)
new-field-names
)))
(
doseq
[[
active-field-name
active-field-type
]
active-column-names->type
]
;; If Field doesn't exist create it
(
if-not
(
contains?
existing-field-names
active-field-name
)
...
...
@@ -223,7 +223,7 @@
;; Otherwise update the Field type if needed
(
let
[{
existing-base-type
:base_type,
existing-field-id
:id
}
(
existing-field-name->field
active-field-name
)]
(
when-not
(
=
active-field-type
existing-base-type
)
(
log/
info
(
u/format-color
'blue
"Field '%s.%s' has changed from a %s to a %s."
(
:name
table
)
active-field-name
existing-base-type
active-field-type
))
(
log/
debug
(
u/format-color
'blue
"Field '%s.%s' has changed from a %s to a %s."
(
:name
table
)
active-field-name
existing-base-type
active-field-type
))
(
upd
Field
existing-field-id
:base_type
active-field-type
))))))
;; TODO - we need to add functionality to update nested Field base types as well!
...
...
@@ -262,7 +262,7 @@
(
when-let
[
fk-column-id
(
fk-name->id
fk-column-name
)]
(
when-let
[
dest-table-id
(
table-name->id
dest-table-name
)]
(
when-let
[
dest-column-id
(
sel
:one
:id
Field,
:table_id
dest-table-id,
:name
dest-column-name,
:parent_id
nil
)]
(
log/
info
(
u/format-color
'green
"Marking foreign key '%s.%s' -> '%s.%s'."
(
:name
table
)
fk-column-name
dest-table-name
dest-column-name
))
(
log/
debug
(
u/format-color
'green
"Marking foreign key '%s.%s' -> '%s.%s'."
(
:name
table
)
fk-column-name
dest-table-name
dest-column-name
))
(
ins
ForeignKey
:origin_id
fk-column-id
:destination_id
dest-column-id
...
...
@@ -329,7 +329,7 @@
[
field
]
(
when
(
nil?
(
:display_name
field
))
(
let
[
display-name
(
common/name->human-readable-name
(
:name
field
))]
(
log/
info
(
u/format-color
'green
"Field '%s.%s' has no display_name. Setting it now."
(
:name
@
(
:table
field
))
(
:name
field
)
display-name
))
(
log/
debug
(
u/format-color
'green
"Field '%s.%s' has no display_name. Setting it now."
(
:name
@
(
:table
field
))
(
:name
field
)
display-name
))
(
upd
Field
(
:id
field
)
:display_name
display-name
)
(
assoc
field
:display_name
display-name
))))
...
...
@@ -371,7 +371,7 @@
(
assert
(
>=
percent-urls
0.0
))
(
assert
(
<=
percent-urls
100.0
))
(
when
(
>
percent-urls
percent-valid-url-threshold
)
(
log/
info
(
u/format-color
'green
"Field '%s' is %d%% URLs. Marking it as a URL."
@
(
:qualified-name
field
)
(
int
(
math/round
(
*
100
percent-urls
)))))
(
log/
debug
(
u/format-color
'green
"Field '%s' is %d%% URLs. Marking it as a URL."
@
(
:qualified-name
field
)
(
int
(
math/round
(
*
100
percent-urls
)))))
(
upd
Field
(
:id
field
)
:special_type
:url
)
(
assoc
field
:special_type
:url
)))))
...
...
@@ -388,7 +388,7 @@
(
let
[
cardinality
(
queries/field-distinct-count
field
low-cardinality-threshold
)]
(
when
(
and
(
>
cardinality
0
)
(
<
cardinality
low-cardinality-threshold
))
(
log/
info
(
u/format-color
'green
"Field '%s' has %d unique values. Marking it as a category."
@
(
:qualified-name
field
)
cardinality
))
(
log/
debug
(
u/format-color
'green
"Field '%s' has %d unique values. Marking it as a category."
@
(
:qualified-name
field
)
cardinality
))
(
upd
Field
(
:id
field
)
:special_type
:category
)
(
assoc
field
:special_type
:category
))))
...
...
@@ -431,7 +431,7 @@
(
let
[
avg-len
(
field-avg-length
driver
field
)]
(
assert
(
integer?
avg-len
)
"field-avg-length should return an integer."
)
(
when
(
>
avg-len
average-length-no-preview-threshold
)
(
log/
info
(
u/format-color
'green
"Field '%s' has an average length of %d. Not displaying it in previews."
@
(
:qualified-name
field
)
avg-len
))
(
log/
debug
(
u/format-color
'green
"Field '%s' has an average length of %d. Not displaying it in previews."
@
(
:qualified-name
field
)
avg-len
))
(
upd
Field
(
:id
field
)
:preview_display
false
)
(
assoc
field
:preview_display
false
)))))
...
...
@@ -465,7 +465,7 @@
(
contains?
#
{
:CharField
:TextField
}
(
:base_type
field
))
(
values-are-valid-json?
(
->>
(
field-values-lazy-seq
driver
field
)
(
take
max-sync-lazy-seq-results
))))
(
log/
info
(
u/format-color
'green
"Field '%s' looks like it contains valid JSON objects. Setting special_type to :json."
@
(
:qualified-name
field
)))
(
log/
debug
(
u/format-color
'green
"Field '%s' looks like it contains valid JSON objects. Setting special_type to :json."
@
(
:qualified-name
field
)))
(
upd
Field
(
:id
field
)
:special_type
:json,
:preview_display
false
)
(
assoc
field
:special_type
:json,
:preview_display
false
)))
...
...
@@ -541,7 +541,7 @@
[
field
]
(
when-not
(
:special_type
field
)
(
when-let
[[
pattern
_
special-type
]
(
field->name-inferred-special-type
field
)]
(
log/
info
(
u/format-color
'green
"%s '%s' matches '%s'. Setting special_type to '%s'."
(
log/
debug
(
u/format-color
'green
"%s '%s' matches '%s'. Setting special_type to '%s'."
(
name
(
:base_type
field
))
@
(
:qualified-name
field
)
pattern
(
name
special-type
)))
(
upd
Field
(
:id
field
)
:special_type
special-type
)
(
assoc
field
:special_type
special-type
))))
...
...
@@ -564,7 +564,7 @@
;; OK, now create new Field objects for ones that came back from active-nested-field-name->type but *aren't* in existing-nested-field-name->id
(
doseq
[[
nested-field-name
nested-field-type
]
nested-field-name->type
]
(
when-not
(
contains?
(
set
(
map
keyword
(
keys
existing-nested-field-name->id
)))
(
keyword
nested-field-name
))
(
log/
info
(
u/format-color
'blue
"Found new nested field: '%s.%s'"
@
(
:qualified-name
field
)
(
name
nested-field-name
)))
(
log/
debug
(
u/format-color
'blue
"Found new nested field: '%s.%s'"
@
(
:qualified-name
field
)
(
name
nested-field-name
)))
(
let
[
nested-field
(
ins
Field,
:table_id
(
:table_id
field
)
,
:parent_id
(
:id
field
)
,
:name
(
name
nested-field-name
)
:base_type
(
name
nested-field-type
)
,
:active
true
)]
;; Now recursively sync this nested Field
;; Replace parent so deref doesn't need to do a DB call
...
...
This diff is collapsed.
Click to expand it.
test/metabase/test/data.clj
+
0
−
1
View file @
633bc899
...
...
@@ -88,7 +88,6 @@
(
or
(
metabase-instance
database-definition
engine
)
(
do
;; Create the database
(
log/info
(
format
"Creating %s database %s..."
(
name
engine
)
database-name
))
(
create-physical-db!
dataset-loader
database-definition
)
;; Load data
...
...
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