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

Fix/do not create schemas #2528

Merged
merged 5 commits into from
Jun 11, 2020
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
3 changes: 2 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.17.0
current_version = 0.17.1a1
parse = (?P<major>\d+)
\.(?P<minor>\d+)
\.(?P<patch>\d+)
Expand Down Expand Up @@ -41,3 +41,4 @@ first_value = 1
[bumpversion:file:plugins/snowflake/dbt/adapters/snowflake/__version__.py]

[bumpversion:file:plugins/bigquery/dbt/adapters/bigquery/__version__.py]

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## dbt 0.17.1 (Release TBD)

### Fixes
- dbt compile and ls no longer create schemas if they don't already exist ([#2525](https://github.com/fishtown-analytics/dbt/issues/2525), [#2528](https://github.com/fishtown-analytics/dbt/pull/2528))


## dbt 0.17.0 (June 08, 2020)

### Fixes
Expand Down
26 changes: 11 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@ jobs:
dependsOn: UnitTest

steps:
- pwsh: echo "True"
displayName: Skip everything
- pwsh: |
choco install postgresql --params '/Password:password' --params-global --version 10.6
Set-Content "c:\program files\postgresql\10\data\pg_hba.conf" "host all all ::1/128 trust"
Add-Content "c:\program files\postgresql\10\data\pg_hba.conf" "host all all 127.0.0.1/32 trust"
# the service name is "postgresql-x64-10", conveniently it's both the display name and the actual name
Restart-Service postgresql-x64-10

& "C:\program files\postgresql\10\bin\createdb.exe" -U postgres dbt
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "CREATE ROLE root WITH PASSWORD 'password';"
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "ALTER ROLE root WITH LOGIN;"
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "CREATE ROLE noaccess WITH PASSWORD 'password' NOSUPERUSER;"
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "ALTER ROLE noaccess WITH LOGIN;"
& "C:\program files\postgresql\10\bin\psql.exe" -U postgres -c "GRANT CONNECT ON DATABASE dbt TO noaccess;"
$serviceName = Get-Service -Name postgresql*
Set-Service -InputObject $serviceName -StartupType Automatic
Start-Service -InputObject $serviceName

createdb.exe -U postgres dbt
psql.exe -U postgres -c "CREATE ROLE root WITH PASSWORD 'password';"
psql.exe -U postgres -c "ALTER ROLE root WITH LOGIN;"
psql.exe -U postgres -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"
psql.exe -U postgres -c "CREATE ROLE noaccess WITH PASSWORD 'password' NOSUPERUSER;"
psql.exe -U postgres -c "ALTER ROLE noaccess WITH LOGIN;"
psql.exe -U postgres -c "GRANT CONNECT ON DATABASE dbt TO noaccess;"
displayName: Install postgresql and set up database

- task: UsePythonVersion@0
Expand Down
3 changes: 2 additions & 1 deletion core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ def print_results_line(self, results, execution_time):
.format(stat_line=stat_line, execution=execution))

def before_run(self, adapter, selected_uids):
super().before_run(adapter, selected_uids)
with adapter.connection_named('master'):
self.create_schemas(adapter, selected_uids)
self.populate_adapter_cache(adapter)
self.safe_run_hooks(adapter, RunHookType.Start, {})

def after_run(self, adapter, results):
Expand Down
1 change: 0 additions & 1 deletion core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def before_hooks(self, adapter):

def before_run(self, adapter, selected_uids):
with adapter.connection_named('master'):
self.create_schemas(adapter, selected_uids)
self.populate_adapter_cache(adapter)

def after_run(self, adapter, results):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ def _get_dbt_plugins_info():
yield plugin_name, mod.version


__version__ = '0.17.0'
__version__ = '0.17.1a1'
installed = get_installed_version()
2 changes: 1 addition & 1 deletion core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def read(fname):


package_name = "dbt-core"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """dbt (data build tool) is a command line tool that helps \
analysts and engineers transform data in their warehouse more effectively"""

Expand Down
2 changes: 1 addition & 1 deletion plugins/bigquery/dbt/adapters/bigquery/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.17.0'
version = '0.17.1a1'
2 changes: 1 addition & 1 deletion plugins/bigquery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


package_name = "dbt-bigquery"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """The bigquery adapter plugin for dbt (data build tool)"""

this_directory = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion plugins/postgres/dbt/adapters/postgres/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.17.0'
version = '0.17.1a1'
2 changes: 1 addition & 1 deletion plugins/postgres/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _dbt_psycopg2_name():


package_name = "dbt-postgres"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """The postgres adpter plugin for dbt (data build tool)"""

this_directory = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion plugins/redshift/dbt/adapters/redshift/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.17.0'
version = '0.17.1a1'
2 changes: 1 addition & 1 deletion plugins/redshift/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


package_name = "dbt-redshift"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """The redshift adapter plugin for dbt (data build tool)"""

this_directory = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion plugins/snowflake/dbt/adapters/snowflake/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.17.0'
version = '0.17.1a1'
2 changes: 1 addition & 1 deletion plugins/snowflake/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


package_name = "dbt-snowflake"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """The snowflake adapter plugin for dbt (data build tool)"""

this_directory = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


package_name = "dbt"
package_version = "0.17.0"
package_version = "0.17.1a1"
description = """With dbt, data analysts and engineers can build analytics \
the way engineers build applications."""

Expand Down
29 changes: 24 additions & 5 deletions test/integration/024_custom_schema_test/test_custom_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,36 @@ def project_config(self):
},
}

def _list_schemas(self):
with self.get_connection():
return set(self.adapter.list_schemas(self.default_database))

def assert_schemas_created(self, expected):
assert self._list_schemas().intersection(expected) == expected

def assert_schemas_not_created(self, expected):
assert not self._list_schemas().intersection(expected)

@use_profile('postgres')
def test__postgres__custom_schema_with_prefix(self):
schema = self.unique_schema()
v1_schema = f"{schema}_dbt_test"
v2_schema = f"{schema}_custom"
xf_schema = f"{schema}_test"
new_schemas = {v1_schema, v2_schema, xf_schema}

self.assert_schemas_not_created(new_schemas)

self.run_sql_file("seed.sql")

self.run_dbt(['ls'])
self.assert_schemas_not_created(new_schemas)
self.run_dbt(['compile'])
self.assert_schemas_not_created(new_schemas)

results = self.run_dbt()
self.assertEqual(len(results), 3)

schema = self.unique_schema()
v1_schema = "{}_dbt_test".format(schema)
v2_schema = "{}_custom".format(schema)
xf_schema = "{}_test".format(schema)
self.assert_schemas_created(new_schemas)

self.assertTablesEqual("seed", "view_1", schema, v1_schema)
self.assertTablesEqual("seed", "view_2", schema, v2_schema)
Expand Down