Repository: dbt-labs/dbt-core

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:

Resolving patch:
diff --git a/dbt/adapters/bigquery/impl.py b/dbt/adapters/bigquery/impl.py
--- 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
--- 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
--- 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: