Skip to content

Improve the output in case of errors #1586

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

Merged
merged 3 commits into from
May 20, 2025
Merged

Improve the output in case of errors #1586

merged 3 commits into from
May 20, 2025

Conversation

vil1
Copy link
Contributor

@vil1 vil1 commented May 16, 2025

Changes

Add a header to the produced files that states from which input they were transpiled, and in case of error, summarize the errors. Errors are displayed with a position (line:column) in the output, which gets decorated with line numbers.

What does this PR do?

Relevant implementation details

Caveats/things to watch out for when reviewing:

Linked issues

Resolves #..

Functionality

  • added relevant user documentation
  • added new CLI command
  • modified existing command: databricks labs remorph ...
  • ... +add your own

Tests

  • manually tested
  • added unit tests
  • added integration tests

@vil1 vil1 requested a review from a team as a code owner May 16, 2025 09:53
Copy link

github-actions bot commented May 16, 2025

✅ 15/15 passed, 1 skipped, 10s total

Running from acceptance #727

@vil1 vil1 self-assigned this May 16, 2025
Copy link
Contributor

@jimidle jimidle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but with some corrections to the English grammar

header = f"/*\n Transpiled from {file_path}\n"
failed_producing_output = False
if errors:
header += "\n Following errors were found while transpiling:\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better English:

The following errors....

failed_producing_output = failed_producing_output or diag.kind == ErrorKind.PARSING

if failed_producing_output:
header += "\n\n Parsing errors prevented the converter to translate the input query.\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better English:

...the converter from translating the input query.

@@ -56,39 +56,76 @@ async def _process_one_file(

output_path.parent.mkdir(parents=True, exist_ok=True)

output_code = transpile_result.transpiled_code

if any(err.kind == ErrorKind.PARSING for err in error_list):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we handle ErrorKind.Internal? the example of Recursive CTE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good question. The if any(...) above detects cases where the output code is known to be incomplete (due to parse errors), which would therefore be useless to the user. In which case we display the input unchanged instead.

Other kinds of errors are dealt with the "regular" way, with the output displayed under the header. Are there other cases (apart from parsing errors) where we should display the input?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would (somewhat hypocritically) convert them to something like "Your source code relies on features not yet supported by Lakebridge. Contact support for help."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vil1 can you run the test on recursive CTEs it was a case where we are able to parse but not translate category, I m more concered about these as if we just put the same as source, people will assume code got translated

@sundarshankar89 sundarshankar89 requested review from asnare and a team May 19, 2025 03:31
Copy link
Collaborator

@sundarshankar89 sundarshankar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are non blocking

@@ -56,39 +56,76 @@ async def _process_one_file(

output_path.parent.mkdir(parents=True, exist_ok=True)

output_code = transpile_result.transpiled_code

if any(err.kind == ErrorKind.PARSING for err in error_list):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vil1 can you run the test on recursive CTEs it was a case where we are able to parse but not translate category, I m more concered about these as if we just put the same as source, people will assume code got translated

@vil1 vil1 added this pull request to the merge queue May 20, 2025
Merged via the queue into main with commit 7832680 May 20, 2025
7 checks passed
@vil1 vil1 deleted the feature/honed-output branch May 20, 2025 14:18
ericvergnaud added a commit that referenced this pull request May 22, 2025
* main: (57 commits)
  Improve the output in case of errors (#1586)
  Integrate analyzer (#1578)
  fix maven name for morpheus (#1585)
  Reduce logging noise during normal transpiler processing. (#1580)
  Improve logging during transpiler installation (#1576)
  LSP: include the client's process ID during the initialisation sequence (#1574)
  Ensure the Remorph CLI provides product information to the pluggable transpilers during initialisation. (#1568)
  Ensure test LSP server is shut down when tests fail (#1569)
  Wait for transpile capability during LSP initialisation (#1571)
  Integration Test with dedicated runner (#1573)
  Avoid adding unnecessary semicolons (#1572)
  Fix spark version detection in CI integration  (#1566)
  Add Pipeline and Step Comment Attributes (#1557)
  Log lsp server stderr (#1471)
  Constrain the Databricks SDK to a single version (#1551)
  Mark `test_execute_query_without_connection` as allowed to fail locally if ODBC isn't available (#1550)
  Fix test temporary resources (#1548)
  Patches Transpiler Output Template (#1558)
  Create a pull request template we can use in all Remorph projects (#1545)
  Pluggable transpiler documentation fixes (#1532)
  ...

# Conflicts:
#	Makefile
#	src/databricks/labs/remorph/cli.py
#	src/databricks/labs/remorph/reconcile/query_builder/hash_query.py
#	src/databricks/labs/remorph/reconcile/recon_capture.py
#	src/databricks/labs/remorph/reconcile/schema_compare.py
#	tests/unit/conftest.py
#	tests/unit/transpiler/test_execute.py
#	tests/unit/transpiler/test_lsp_engine.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants