-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1328 from fishtown-analytics/feature/operations-a…
…ctually Feature/operations actually
- Loading branch information
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from dbt.logger import GLOBAL_LOGGER as logger | ||
|
||
from dbt.task.base_task import BaseTask | ||
from dbt.adapters.factory import get_adapter | ||
from dbt.loader import GraphLoader | ||
|
||
import dbt | ||
import dbt.utils | ||
import dbt.exceptions | ||
|
||
|
||
class RunOperationTask(BaseTask): | ||
def _get_macro_parts(self): | ||
macro_name = self.args.macro | ||
if '.' in macro_name: | ||
package_name, macro_name = macro_name.split(".", 1) | ||
else: | ||
package_name = None | ||
|
||
return package_name, macro_name | ||
|
||
def _get_kwargs(self): | ||
return dbt.utils.parse_cli_vars(self.args.args) | ||
|
||
def run(self): | ||
manifest = GraphLoader.load_all(self.config) | ||
adapter = get_adapter(self.config) | ||
|
||
package_name, macro_name = self._get_macro_parts() | ||
macro_kwargs = self._get_kwargs() | ||
|
||
res = adapter.execute_macro( | ||
macro_name, | ||
project=package_name, | ||
kwargs=macro_kwargs, | ||
manifest=manifest, | ||
connection_name="macro_{}".format(macro_name) | ||
) | ||
|
||
return res |