Skip to content

Commit

Permalink
pep8 compliance (#257)
Browse files Browse the repository at this point in the history
add pep8 check to continuous integration tests and bring codebase into compliance
  • Loading branch information
cmcarthur authored Jan 6, 2017
1 parent 2fe3758 commit 0e01064
Show file tree
Hide file tree
Showing 33 changed files with 1,376 additions and 567 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#### Changes

- add `--debug` flag, replace calls to `print()` with a global logger ([#256](https://github.com/analyst-collective/dbt/pull/256))
- add pep8 check to continuous integration tests and bring codebase into compliance ([#257](https://github.com/analyst-collective/dbt/pull/257))

## dbt release 0.6.0

Expand Down
1 change: 0 additions & 1 deletion dbt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

45 changes: 26 additions & 19 deletions dbt/archival.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from __future__ import print_function
import dbt.targets
import dbt.schema
Expand All @@ -18,41 +17,50 @@ def __init__(self, project, archive_model):
def compile(self):
source_schema = self.archive_model.source_schema
target_schema = self.archive_model.target_schema
source_table = self.archive_model.source_table
target_table = self.archive_model.target_table
unique_key = self.archive_model.unique_key
updated_at = self.archive_model.updated_at
source_table = self.archive_model.source_table
target_table = self.archive_model.target_table
unique_key = self.archive_model.unique_key
updated_at = self.archive_model.updated_at

self.schema.create_schema(target_schema)

source_columns = self.schema.get_columns_in_table(source_schema, source_table)
source_columns = self.schema.get_columns_in_table(
source_schema, source_table)

if len(source_columns) == 0:
raise RuntimeError('Source table "{}"."{}" does not exist'.format(source_schema, source_table))
raise RuntimeError(
'Source table "{}"."{}" does not '
'exist'.format(source_schema, source_table))

extra_cols = [
dbt.schema.Column("valid_from", "timestamp", None),
dbt.schema.Column("valid_to", "timestamp", None),
dbt.schema.Column("scd_id","text", None),
dbt.schema.Column("dbt_updated_at","timestamp", None)
dbt.schema.Column("scd_id", "text", None),
dbt.schema.Column("dbt_updated_at", "timestamp", None)
]

dest_columns = source_columns + extra_cols
self.schema.create_table(target_schema, target_table, dest_columns, sort=updated_at, dist=unique_key)
self.schema.create_table(
target_schema,
target_table,
dest_columns,
sort=updated_at,
dist=unique_key
)

env = jinja2.Environment()

ctx = {
"columns" : source_columns,
"updated_at" : updated_at,
"unique_key" : unique_key,
"source_schema" : source_schema,
"source_table" : source_table,
"target_schema" : target_schema,
"target_table" : target_table
"columns": source_columns,
"updated_at": updated_at,
"unique_key": unique_key,
"source_schema": source_schema,
"source_table": source_table,
"target_schema": target_schema,
"target_table": target_table
}

base_query = dbt.templates.SCDArchiveTemplate
base_query = dbt.templates.SCDArchiveTemplate
template = env.from_string(base_query, globals=ctx)
rendered = template.render(ctx)

Expand All @@ -62,4 +70,3 @@ def runtime_compile(self, compiled_model):
context = self.context.copy()
context.update(model.context())
model.compile(context)

Loading

0 comments on commit 0e01064

Please sign in to comment.