diff --git a/labs.yml b/labs.yml index a7442695ff..ec0b3e70fd 100644 --- a/labs.yml +++ b/labs.yml @@ -17,6 +17,8 @@ commands: description: (Optional) Name of report file to write - name: source-tech description: (Optional) Name of the Source System Technology you want to analyze + - name: generate-json + description: (Optional) Flag to indicate if a json file should be produced alongside the Excel file - name: transpile description: Transpile SQL script to Databricks SQL flags: diff --git a/src/databricks/labs/lakebridge/analyzer/lakebridge_analyzer.py b/src/databricks/labs/lakebridge/analyzer/lakebridge_analyzer.py index db5d8cb58d..250efbac86 100644 --- a/src/databricks/labs/lakebridge/analyzer/lakebridge_analyzer.py +++ b/src/databricks/labs/lakebridge/analyzer/lakebridge_analyzer.py @@ -67,7 +67,9 @@ def _run_prompt_analyzer(self): logger.info(f"Successfully Analyzed files in ${source_dir} for ${technology} and saved report to {results_dir}") - def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, technology: str | None): + def _run_arg_analyzer( + self, source_dir: str | None, results_dir: str | None, technology: str | None, generate_json: bool = False + ): """Run the analyzer: arg guided""" if source_dir is None or results_dir is None or technology is None: logger.error("All arguments (--source-directory, --report-file, --source-tech) must be provided") @@ -76,7 +78,7 @@ def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, tec if check_path(source_dir) and check_path(results_dir): tmp_dir = self._temp_xlsx_path(results_dir) technology = self._get_source_tech(technology) - self._run_binary(Path(source_dir), tmp_dir, technology, self._is_debug) + self._run_binary(Path(source_dir), tmp_dir, technology, self._is_debug, generate_json) move_tmp_file(tmp_dir, Path(results_dir)) @@ -85,11 +87,15 @@ def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, tec ) def run_analyzer( - self, source_dir: str | None = None, results_dir: str | None = None, technology: str | None = None + self, + source_dir: str | None = None, + results_dir: str | None = None, + technology: str | None = None, + generate_json: bool = False, ): """Run the analyzer.""" if not any([source_dir, results_dir, technology]): self._run_prompt_analyzer() return - self._run_arg_analyzer(source_dir, results_dir, technology) + self._run_arg_analyzer(source_dir, results_dir, technology, generate_json) \ No newline at end of file diff --git a/src/databricks/labs/lakebridge/cli.py b/src/databricks/labs/lakebridge/cli.py index 6c626f1692..504df879b0 100644 --- a/src/databricks/labs/lakebridge/cli.py +++ b/src/databricks/labs/lakebridge/cli.py @@ -651,13 +651,14 @@ def analyze( source_directory: str | None = None, report_file: str | None = None, source_tech: str | None = None, + generate_json: bool = False, ): """Run the Analyzer""" ctx = ApplicationContext(w) ctx.add_user_agent_extra("cmd", "analyze") logger.debug(f"User: {ctx.current_user}") - ctx.analyzer.run_analyzer(source_directory, report_file, source_tech) + ctx.analyzer.run_analyzer(source_directory, report_file, source_tech, generate_json) if __name__ == "__main__":