Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first pass at pep8 compliance #257

Merged
merged 10 commits into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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