From 7e970d6b2bb13854fd8966c8be77e3744c7894a9 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 2 Jul 2024 18:59:18 +0200 Subject: [PATCH 1/2] use dedicated advice message for unsupported sql --- src/databricks/labs/ucx/source_code/linters/dbfs.py | 2 +- src/databricks/labs/ucx/source_code/queries.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/databricks/labs/ucx/source_code/linters/dbfs.py b/src/databricks/labs/ucx/source_code/linters/dbfs.py index c92fff5d33..99d894fc4b 100644 --- a/src/databricks/labs/ucx/source_code/linters/dbfs.py +++ b/src/databricks/labs/ucx/source_code/linters/dbfs.py @@ -104,7 +104,7 @@ def lint(self, code: str) -> Iterable[Advice]: except SqlParseError as e: logger.debug(f"Failed to parse SQL: {code}", exc_info=e) yield Failure( - code='dbfs-query', + code='unsupported-sql', message=f"SQL query is not supported yet: {code}", # SQLGlot does not propagate tokens yet. See https://github.com/tobymao/sqlglot/issues/3159 start_line=0, diff --git a/src/databricks/labs/ucx/source_code/queries.py b/src/databricks/labs/ucx/source_code/queries.py index 51786afbac..72d528635f 100644 --- a/src/databricks/labs/ucx/source_code/queries.py +++ b/src/databricks/labs/ucx/source_code/queries.py @@ -52,7 +52,7 @@ def lint(self, code: str) -> Iterable[Advice]: except SqlParseError as e: logger.debug(f"Failed to parse SQL: {code}", exc_info=e) yield Failure( - code='table-migrate', + code='unsupported-sql', message=f"SQL query is not supported yet: {code}", # SQLGlot does not propagate tokens yet. See https://github.com/tobymao/sqlglot/issues/3159 start_line=0, From 47fb7f87ed95cca8fb3d0389d219fc2d90d68b00 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Tue, 2 Jul 2024 19:31:09 +0200 Subject: [PATCH 2/2] fix failing test + formatting --- src/databricks/labs/ucx/source_code/linters/dbfs.py | 2 +- src/databricks/labs/ucx/source_code/queries.py | 2 +- tests/unit/source_code/linters/test_dbfs.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/databricks/labs/ucx/source_code/linters/dbfs.py b/src/databricks/labs/ucx/source_code/linters/dbfs.py index 99d894fc4b..b33c25698a 100644 --- a/src/databricks/labs/ucx/source_code/linters/dbfs.py +++ b/src/databricks/labs/ucx/source_code/linters/dbfs.py @@ -104,7 +104,7 @@ def lint(self, code: str) -> Iterable[Advice]: except SqlParseError as e: logger.debug(f"Failed to parse SQL: {code}", exc_info=e) yield Failure( - code='unsupported-sql', + code='dbfs-query-unsupported-sql', message=f"SQL query is not supported yet: {code}", # SQLGlot does not propagate tokens yet. See https://github.com/tobymao/sqlglot/issues/3159 start_line=0, diff --git a/src/databricks/labs/ucx/source_code/queries.py b/src/databricks/labs/ucx/source_code/queries.py index 72d528635f..621d620936 100644 --- a/src/databricks/labs/ucx/source_code/queries.py +++ b/src/databricks/labs/ucx/source_code/queries.py @@ -52,7 +52,7 @@ def lint(self, code: str) -> Iterable[Advice]: except SqlParseError as e: logger.debug(f"Failed to parse SQL: {code}", exc_info=e) yield Failure( - code='unsupported-sql', + code='sql-query-unsupported-sql', message=f"SQL query is not supported yet: {code}", # SQLGlot does not propagate tokens yet. See https://github.com/tobymao/sqlglot/issues/3159 start_line=0, diff --git a/tests/unit/source_code/linters/test_dbfs.py b/tests/unit/source_code/linters/test_dbfs.py index 54721dca7f..1e67d63cb2 100644 --- a/tests/unit/source_code/linters/test_dbfs.py +++ b/tests/unit/source_code/linters/test_dbfs.py @@ -115,7 +115,7 @@ def test_dbfs_queries_failure(query: str): actual = list(ftf.lint(query)) assert actual == [ Failure( - code='dbfs-query', + code='dbfs-query-unsupported-sql', message=f'SQL query is not supported yet: {query}', start_line=0, start_col=0,