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

Refactor: split out parsers #809

Merged
merged 11 commits into from
Jul 3, 2018
1 change: 0 additions & 1 deletion dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import dbt.exceptions
import dbt.flags
import dbt.loader
import dbt.parser

from dbt.clients.system import write_file
from dbt.logger import GLOBAL_LOGGER as logger
Expand Down
3 changes: 2 additions & 1 deletion dbt/context/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dbt.clients.jinja
import dbt.context.common
import dbt.flags
import dbt.parser

from dbt.logger import GLOBAL_LOGGER as logger # noqa

Expand All @@ -25,7 +26,7 @@ def do_ref(*args):
else:
dbt.exceptions.ref_invalid_args(model, args)

target_model = dbt.parser.resolve_ref(
target_model = dbt.parser.ParserUtils.resolve_ref(
flat_graph,
target_model_name,
target_model_package,
Expand Down
26 changes: 13 additions & 13 deletions dbt/loader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import dbt.exceptions
import dbt.parser

from dbt.node_types import NodeType
from dbt.contracts.graph.parsed import ParsedManifest

import dbt.parser


class GraphLoader(object):

Expand All @@ -18,7 +19,7 @@ def load_all(cls, root_project, all_projects):
nodes.update(loader.load_all(root_project, all_projects, macros))

manifest = ParsedManifest(nodes=nodes, macros=macros)
manifest = dbt.parser.process_refs(manifest, root_project)
manifest = dbt.parser.ParserUtils.process_refs(manifest, root_project)
return manifest

@classmethod
Expand Down Expand Up @@ -50,7 +51,7 @@ class MacroLoader(ResourceLoader):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_macros(
return dbt.parser.MacroParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand Down Expand Up @@ -78,7 +79,7 @@ def load_all(cls, root_project, all_projects, macros=None):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_sql(
return dbt.parser.ModelParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand All @@ -93,7 +94,7 @@ class OperationLoader(ResourceLoader):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_macros(
return dbt.parser.MacroParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand All @@ -107,7 +108,7 @@ class AnalysisLoader(ResourceLoader):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_sql(
return dbt.parser.AnalysisParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand All @@ -122,7 +123,7 @@ class SchemaTestLoader(ResourceLoader):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_yml(
return dbt.parser.SchemaParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand All @@ -136,7 +137,7 @@ class DataTestLoader(ResourceLoader):
@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_sql(
return dbt.parser.DataTestParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
Expand All @@ -157,7 +158,7 @@ def load_all(cls, root_project, all_projects, macros=None):

@classmethod
def load_project(cls, root_project, all_projects, macros):
return dbt.parser.parse_archives_from_projects(root_project,
return dbt.parser.ArchiveParser.load_and_parse(root_project,
all_projects,
macros)

Expand All @@ -170,22 +171,21 @@ def load_all(cls, root_project, all_projects, macros=None):

@classmethod
def load_project(cls, root_project, all_projects, macros):
return dbt.parser.load_and_parse_run_hooks(root_project, all_projects,
macros)
return dbt.parser.HookParser.load_and_parse(root_project, all_projects,
macros)


class SeedLoader(ResourceLoader):

@classmethod
def load_project(cls, root_project, all_projects, project, project_name,
macros):
return dbt.parser.load_and_parse_seeds(
return dbt.parser.SeedParser.load_and_parse(
package_name=project_name,
root_project=root_project,
all_projects=all_projects,
root_dir=project.get('project-root'),
relative_dirs=project.get('data-paths', []),
resource_type=NodeType.Seed,
macros=macros)


Expand Down
Loading