Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AmendsenProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaik Janipasha
AmendsenProject
Commits
67e7495c
Commit
67e7495c
authored
Oct 20, 2019
by
samshuster
Committed by
Tao Feng
Oct 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding sample source data and loader (lyft/amundsen#130) (#151)
parent
4d69b6af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
sample_source.csv
example/sample_data/sample_source.csv
+2
-0
sample_data_loader.py
example/scripts/sample_data_loader.py
+33
-0
No files found.
example/sample_data/sample_source.csv
0 → 100644
View file @
67e7495c
db_name,cluster,schema_name,table_name,source,source_type
hive,gold,test_schema,test_table1,"https://github.com/lyft/amundsen/",github
example/scripts/sample_data_loader.py
View file @
67e7495c
...
@@ -205,6 +205,33 @@ def load_application_data_from_csv(file_name):
...
@@ -205,6 +205,33 @@ def load_application_data_from_csv(file_name):
conn
.
commit
()
conn
.
commit
()
def
load_source_data_from_csv
(
file_name
):
conn
=
create_connection
(
DB_FILE
)
if
conn
:
cur
=
conn
.
cursor
()
cur
.
execute
(
'drop table if exists test_source_metadata'
)
cur
.
execute
(
'create table if not exists test_source_metadata '
'(db_name VARCHAR(64) NOT NULL , '
'cluster VARCHAR(64) NOT NULL , '
'schema_name VARCHAR(64) NOT NULL, '
'table_name VARCHAR(64) NOT NULL, '
'source VARCHAR(64) NOT NULL , '
'source_type VARCHAR(32) NOT NULL)'
)
file_loc
=
'example/sample_data/'
+
file_name
with
open
(
file_loc
,
'r'
)
as
fin
:
dr
=
csv
.
DictReader
(
fin
)
to_db
=
[(
i
[
'db_name'
],
i
[
'cluster'
],
i
[
'schema_name'
],
i
[
'table_name'
],
i
[
'source'
],
i
[
'source_type'
])
for
i
in
dr
]
cur
.
executemany
(
"INSERT INTO test_source_metadata (db_name, cluster, "
"schema_name, table_name, source, source_type) VALUES (?, ?, ?, ?, ?, ?);"
,
to_db
)
conn
.
commit
()
# todo: Add a second model
# todo: Add a second model
def
create_sample_job
(
table_name
,
model_name
,
transformer
=
NoopTransformer
()):
def
create_sample_job
(
table_name
,
model_name
,
transformer
=
NoopTransformer
()):
sql
=
textwrap
.
dedent
(
"""
sql
=
textwrap
.
dedent
(
"""
...
@@ -394,6 +421,7 @@ if __name__ == "__main__":
...
@@ -394,6 +421,7 @@ if __name__ == "__main__":
load_usage_data_from_csv
(
'sample_column_usage.csv'
)
load_usage_data_from_csv
(
'sample_column_usage.csv'
)
load_user_data_from_csv
(
'sample_user.csv'
)
load_user_data_from_csv
(
'sample_user.csv'
)
load_application_data_from_csv
(
'sample_application.csv'
)
load_application_data_from_csv
(
'sample_application.csv'
)
load_source_data_from_csv
(
'sample_source.csv'
)
if
create_connection
(
DB_FILE
):
if
create_connection
(
DB_FILE
):
# start table job
# start table job
...
@@ -426,6 +454,11 @@ if __name__ == "__main__":
...
@@ -426,6 +454,11 @@ if __name__ == "__main__":
'databuilder.models.application.Application'
)
'databuilder.models.application.Application'
)
job_app
.
launch
()
job_app
.
launch
()
# start job_source job
job_source
=
create_sample_job
(
'test_source_metadata'
,
'databuilder.models.table_source.TableSource'
)
job_source
.
launch
()
# start last updated job
# start last updated job
job_lastupdated
=
create_last_updated_job
()
job_lastupdated
=
create_last_updated_job
()
job_lastupdated
.
launch
()
job_lastupdated
.
launch
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment