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
a43725f4
Commit
a43725f4
authored
5 years ago
by
jf-beauvais
Committed by
Cam Saul
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Spark SQL driver: read Hive database schema and partitionned tables (#9889)
parent
a52bff8f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/drivers/sparksql/src/metabase/driver/sparksql.clj
+10
-3
10 additions, 3 deletions
modules/drivers/sparksql/src/metabase/driver/sparksql.clj
with
10 additions
and
3 deletions
modules/drivers/sparksql/src/metabase/driver/sparksql.clj
+
10
−
3
View file @
a43725f4
...
...
@@ -93,11 +93,17 @@
{
:tables
(
with-open
[
conn
(
jdbc/get-connection
(
sql-jdbc.conn/db->pooled-connection-spec
database
))]
(
set
(
for
[{
:keys
[
tablename
da
tab
as
e
]}
(
jdbc/query
{
:connection
conn
}
[
"show tables"
])]
{
:name
tablename
(
for
[{
:keys
[
database
tablename
tab
_nam
e
]}
(
jdbc/query
{
:connection
conn
}
[
"show tables"
])]
{
:name
(
or
tablename
tab_name
)
; column name differs depending on server (SparkSQL, hive, Impala)
:schema
(
when
(
seq
database
)
database
)})))})
;; Hive describe table result has commented rows to distinguish partitions
(
defn-
valid-describe-table-row?
[{
:keys
[
col_name
data_type
]}]
(
every?
(
every-pred
(
complement
str/blank?
)
(
complement
#
(
str/starts-with?
%
"#"
)))
[
col_name
data_type
]))
;; workaround for SPARK-9686 Spark Thrift server doesn't return correct JDBC metadata
(
defmethod
driver/describe-table
:sparksql
[
driver
{
:keys
[
details
]
:as
database
}
{
table-name
:name,
schema
:schema,
:as
table
}]
...
...
@@ -111,7 +117,8 @@
(
dash-to-underscore
schema
)
(
dash-to-underscore
table-name
)))])]
(
set
(
for
[{
col-name
:col_name,
data-type
:data_type
}
results
]
(
for
[{
col-name
:col_name,
data-type
:data_type,
:as
result
}
results
:when
(
valid-describe-table-row?
result
)]
{
:name
col-name
:database-type
data-type
:base-type
(
sql-jdbc.sync/database-type->base-type
:hive-like
(
keyword
data-type
))}))))})
...
...
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