Repository: dbt-labs/dbt-core (Python)

Issue:
0.12.0-alpha regression: if no target is specified, dbt should use a target called "default"
## Issue

A regression in the 0.12.0 alpha no longer uses the `default` target if a `target:` is not specified.

### Issue description

Given a profile like:
```
{
    default: {
        outputs: {
            default: {
                type: 'postgres',
                threads: 1,
                host: 'localhost',
                port: 5432,
                user: 'root',
                pass: 'password',
                dbname: 'test',
                schema: 'test'
            }
        }
    }
}
```

(Note: There is no `target` specified here). Previous versions would use the `"default"` target if no `target` was listed explicitly. It looks like the alpha instead fails with:

```
Encountered an error while reading profiles:
  ERROR Runtime Error
  target not specified in profile 'default'
```


### System information
The output of `dbt --version`:
```
0.12.0-a1
```

The operating system you're running on:
3.7




Discussion:

Patch:
diff --git a/dbt/adapters/bigquery/impl.py b/dbt/adapters/bigquery/impl.py
index 0fe2f409292..6aa5d6823ad 100644
--- a/dbt/adapters/bigquery/impl.py
+++ b/dbt/adapters/bigquery/impl.py
@@ -278,7 +278,9 @@ def poll_until_job_completes(cls, job, timeout):
             raise dbt.exceptions.RuntimeException("BigQuery Timeout Exceeded")
 
         elif job.error_result:
-            message = '\n'.join(error['message'].strip() for error in job.errors)
+            message = '\n'.join(
+                error['message'].strip() for error in job.errors
+            )
             raise dbt.exceptions.RuntimeException(message)
 
     def make_date_partitioned_table(self, dataset_name, identifier,
diff --git a/dbt/config.py b/dbt/config.py
index 02228d296ac..46b7e8d3866 100644
--- a/dbt/config.py
+++ b/dbt/config.py
@@ -606,8 +606,10 @@ def _render_profile(cls, raw_profile, profile_name, target_override,
             # render the target if it was parsed from yaml
             target_name = renderer.render_value(raw_profile['target'])
         else:
-            raise DbtProfileError(
-                "target not specified in profile '{}'".format(profile_name)
+            target_name = 'default'
+            logger.debug(
+                "target not specified in profile '{}', using '{}'"
+                .format(profile_name, target_name)
             )
 
         raw_profile_data = cls._get_profile_data(


Test patch:
diff --git a/test/unit/test_config.py b/test/unit/test_config.py
index 9d6de944ccb..649fbb2380c 100644
--- a/test/unit/test_config.py
+++ b/test/unit/test_config.py
@@ -319,12 +319,14 @@ def test_invalid_credentials(self):
         self.assertIn('postgres', str(exc.exception))
         self.assertIn('default', str(exc.exception))
 
-    def test_target_missing(self):
-        del self.default_profile_data['default']['target']
-        with self.assertRaises(dbt.exceptions.DbtProfileError) as exc:
-            self.from_raw_profiles()
-        self.assertIn('target not specified in profile', str(exc.exception))
-        self.assertIn('default', str(exc.exception))
+    def test_missing_target(self):
+        profile = self.default_profile_data['default']
+        del profile['target']
+        profile['outputs']['default'] = profile['outputs']['postgres']
+        profile = self.from_raw_profiles()
+        self.assertEqual(profile.profile_name, 'default')
+        self.assertEqual(profile.target_name, 'default')
+        self.assertEqual(profile.credentials.type, 'postgres')
 
     def test_profile_invalid_project(self):
         with self.assertRaises(dbt.exceptions.DbtProjectError) as exc: