How to use get_database_parts method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

osmosis.py

Source:osmosis.py Github

copy

Full Screen

...745 else:746 raise InvalidOsmosisConfig(f"Invalid dbt-osmosis config for model: {node.fqn}")747 return Path(node.root_path, node.original_file_path).parent / Path(f"{schema}.yml")748 @staticmethod749 def get_database_parts(node: ManifestNode) -> Tuple[str, str, str]:750 return node.database, node.schema, getattr(node, "alias", node.name)751 def get_base_model(self, node: ManifestNode) -> Dict[str, Any]:752 """Construct a base model object with model name, column names populated from database"""753 columns = self.get_columns(node)754 return {755 "name": node.alias or node.name,756 "columns": [{"name": column_name} for column_name in columns],757 }758 def bootstrap_existing_model(759 self, model_documentation: Dict[str, Any], node: ManifestNode760 ) -> Dict[str, Any]:761 """Injects columns from database into existing model if not found"""762 model_columns: List[str] = [763 c["name"].lower() for c in model_documentation.get("columns", [])764 ]765 database_columns = self.get_columns(node)766 for column in database_columns:767 if column.lower() not in model_columns:768 logger().info(":syringe: Injecting column %s into dbt schema", column)769 model_documentation.setdefault("columns", []).append({"name": column})770 return model_documentation771 def get_columns(self, node: ManifestNode) -> List[str]:772 """Get all columns in a list for a model"""773 parts = self.get_database_parts(node)774 table = self.adapter.get_relation(*parts)775 columns = []776 if not table:777 logger().info(778 ":cross_mark: Relation %s.%s.%s does not exist in target database, cannot resolve columns",779 *parts,780 )781 return columns782 try:783 columns = [c.name for c in self.adapter.get_columns_in_relation(table)]784 except CompilationException as error:785 logger().info(786 ":cross_mark: Could not resolve relation %s.%s.%s against database active tables during introspective query: %s",787 *parts,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful