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

support string or list for sort key #397

Merged
merged 1 commit into from
May 2, 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
2 changes: 1 addition & 1 deletion dbt/contracts/graph/parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Optional('unique_key'): basestring,

# adapter optional fields
Optional('sort'): basestring,
Optional('sort'): Any(basestring, list),
Optional('dist'): basestring,
}

Expand Down
41 changes: 40 additions & 1 deletion test/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ def test__other_project_config(self):
'enabled': False,
'views': {
'materialized': 'view',
'multi_sort': {
'enabled': True,
'materialized': 'table'
}
}
}
}
Expand All @@ -741,7 +745,10 @@ def test__other_project_config(self):
'enabled': False,
'views': {
'materialized': 'table',
'sort': 'timestamp'
'sort': 'timestamp',
'multi_sort': {
'sort': ['timestamp', 'id'],
}
}
}
}
Expand Down Expand Up @@ -783,6 +790,13 @@ def test__other_project_config(self):
'path': get_os_path('views/package.sql'),
'root_path': get_os_path('/usr/src/app'),
'raw_sql': ("select * from events"),
}, {
'name': 'multi_sort',
'resource_type': 'model',
'package_name': 'snowplow',
'path': get_os_path('views/multi_sort.sql'),
'root_path': get_os_path('/usr/src/app'),
'raw_sql': ("select * from events"),
}]

self.model_config.update({
Expand Down Expand Up @@ -812,6 +826,12 @@ def test__other_project_config(self):
'sort': 'timestamp',
})

multi_sort_config = self.model_config.copy()
multi_sort_config.update({
'materialized': 'table',
'sort': ['timestamp', 'id']
})

self.assertEquals(
dbt.parser.parse_sql_nodes(
models,
Expand Down Expand Up @@ -913,6 +933,25 @@ def test__other_project_config(self):
'tags': set(),
'raw_sql': self.find_input_by_name(
models, 'package').get('raw_sql')
},
'model.snowplow.multi_sort': {
'name': 'multi_sort',
'resource_type': 'model',
'unique_id': 'model.snowplow.multi_sort',
'fqn': ['snowplow', 'views', 'multi_sort'],
'empty': False,
'package_name': 'snowplow',
'refs': [],
'depends_on': {
'nodes': [],
'macros': []
},
'path': get_os_path('views/multi_sort.sql'),
'root_path': get_os_path('/usr/src/app'),
'config': multi_sort_config,
'tags': set(),
'raw_sql': self.find_input_by_name(
models, 'multi_sort').get('raw_sql')
}
}
)
Expand Down