def print_start_line(node, schema, index, total): if is_type(node, NodeType.Model): dbt.ui.printer.print_model_start_line(node, schema, index, total) if is_type(node, NodeType.Test): dbt.ui.printer.print_test_start_line(node, schema, index, total) if is_type(node, NodeType.Archive): dbt.ui.printer.print_archive_start_line(node, index, total)
def print_result_line(result, schema, index, total): node = result.node if is_type(node, NodeType.Model): dbt.ui.printer.print_model_result_line(result, schema, index, total) elif is_type(node, NodeType.Test): dbt.ui.printer.print_test_result_line(result, schema, index, total) elif is_type(node, NodeType.Archive): dbt.ui.printer.print_archive_result_line(result, index, total)
def compile_node(self, node, manifest, extra_context=None): if extra_context is None: extra_context = {} logger.debug("Compiling {}".format(node.get('unique_id'))) data = node.to_dict() data.update({ 'compiled': False, 'compiled_sql': None, 'extra_ctes_injected': False, 'extra_ctes': [], 'injected_sql': None, }) compiled_node = CompiledNode(**data) context = dbt.context.runtime.generate( compiled_node, self.config, manifest) context.update(extra_context) compiled_node.compiled_sql = dbt.clients.jinja.get_rendered( node.get('raw_sql'), context, node) compiled_node.compiled = True injected_node, _ = prepend_ctes(compiled_node, manifest) should_wrap = {NodeType.Test, NodeType.Operation} if injected_node.resource_type in should_wrap: # data tests get wrapped in count(*) # TODO : move this somewhere more reasonable if 'data' in injected_node.tags and \ is_type(injected_node, NodeType.Test): injected_node.wrapped_sql = ( "select count(*) from (\n{test_sql}\n) sbq").format( test_sql=injected_node.injected_sql) else: # don't wrap schema tests or analyses. injected_node.wrapped_sql = injected_node.injected_sql elif is_type(injected_node, NodeType.Archive): # unfortunately we do everything automagically for # archives. in the future it'd be nice to generate # the SQL at the parser level. pass elif(is_type(injected_node, NodeType.Model) and get_materialization(injected_node) == 'ephemeral'): pass else: injected_node.wrapped_sql = None return injected_node
def compile_node(self, node, flat_graph): logger.debug("Compiling {}".format(node.get('unique_id'))) compiled_node = node.copy() compiled_node.update({ 'compiled': False, 'compiled_sql': None, 'extra_ctes_injected': False, 'extra_ctes': OrderedDict(), 'injected_sql': None, }) context = dbt.context.runtime.generate( compiled_node, self.project.cfg, flat_graph) compiled_node['compiled_sql'] = dbt.clients.jinja.get_rendered( node.get('raw_sql'), context, node) compiled_node['compiled'] = True injected_node, _ = prepend_ctes(compiled_node, flat_graph) if compiled_node.get('resource_type') in [NodeType.Test, NodeType.Analysis, NodeType.Operation]: # data tests get wrapped in count(*) # TODO : move this somewhere more reasonable if 'data' in injected_node['tags'] and \ is_type(injected_node, NodeType.Test): injected_node['wrapped_sql'] = ( "select count(*) from (\n{test_sql}\n) sbq").format( test_sql=injected_node['injected_sql']) else: # don't wrap schema tests or analyses. injected_node['wrapped_sql'] = injected_node.get( 'injected_sql') elif is_type(injected_node, NodeType.Archive): # unfortunately we do everything automagically for # archives. in the future it'd be nice to generate # the SQL at the parser level. pass elif(is_type(injected_node, NodeType.Model) and get_materialization(injected_node) == 'ephemeral'): pass else: injected_node['wrapped_sql'] = None return injected_node
def execute_node(self, node, flat_graph, existing, profile, adapter): result = None logger.debug("executing node %s", node.get('unique_id')) if node.get('skip') is True: return "SKIP" node = self.inject_runtime_config(node) if is_type(node, NodeType.Model): result = execute_model(profile, node, existing) elif is_type(node, NodeType.Test): result = execute_test(profile, node) elif is_type(node, NodeType.Archive): result = execute_archive(profile, node, self.node_context(node)) adapter.commit_if_has_connection(profile, node.get('name')) return node, result