Skip to content

Converter Configuration

The Converter Configuration describe here is shared across all dialects and allows you to define settings for the conversion process. These settings include the output file extension, user template paths, template configurations, template tag filters, and node filters. The configuration class is designed to work with all dialects.

Configuration Fields

Field Description Default Value Localizable Environment Variable
default_output_extension Default output file extension. .out True
render_unsupported_output_as_comment If True converter will render whatever it was able to convert for unsupported source chunk as a comment. The output by definition will not be correct and may not even resemble valid code, but may be useful for creating user templates or reporting feature requests.

This is especially true for large statements/expressions where only a small part is not supported. In this case the output may be very close to a fully converted one.

Alchemist will determine a reasonable level at which to render the output. This is the same level as for render_unsupported_source_as_comment.
True True
user_template_paths List of folders with user templates to make available for conversion. Empty list False
template_configs List of template configs. TemplateConfig False
template_tag_filter Filter config for template tags to inclusion/exclusion from matching. StringFilterConfig True
node_filter Filter config for node inclusion/exclusion from rendering. NodeFilterConfig True
use_runtime If True converter will use runtime user-defined functions where appropriate.

Be aware, that setting this to False may reduce the amount of automatically converted code, since for some of the constructs there may not be a non-runtime static inline version.
True True ALC_USE_RUNTIME
custom_udf_name_mapping Custom name mapping for runtime functions.

This allows to use custom names for runtime functions. For the name of specific functions, consult target dialect documentation.
Empty dict True
conversion_comment_verbosity_level Verbosity level for conversion comments (code, todo, warning, debug).

Verbosity levels:

- code: outputs only regular code comments retained from the source or considered part of the output.

- todo: outputs code and todo comments; todo comments are used for output that has to be adjusted manually.

- warning: outputs code, todo and warning comments; warning comments are used for potentially invalid code.

- debug: outputs all comments, including developer warnings; debug comments are used for code that is unlikely to be invalid.
todo True
conversion_mode Conversion mode (normal, strict, lax).

Changes code generation and how the comment verbosity level is handled:

- NORMAL: The default mode. Balances correctness & readability,
by allowing some heuristics about the common cases when
achieving 100% match would generate overly verbose and complex
code, while still allowing short constructs that ensure
correctness.
- STRICT: Prioritizes correctness over readability, striving to
mark anything that is potentially not 100% correct in all
scenarios as a TODO item and reducing heuristics to a minimum.
- LAX: Prioritizes readability over correctness, assuming the best
case scenario and avoiding generating additiona expressions
that would be needed to handle edge cases.

In addition to that, the verbosity level of conversion comments is adjusted based on the mode: - In strict mode, the warning comment is treated as todo, and debug is treated as warning. So more todo comments are generated. - In lax mode, the todo comment is treated as warning, and warning is treated as debug. Meaning no todo comments are generated at all.
normal True
llm Configuration for GenAI base conversion. LLMConfig False

Example Configuration

Here is an example configuration in YAML format:

converter:
    default_output_extension: ".sql"
    user_template_paths:
        - /path/to/your/templates/
    template_configs:
        - inline: |
              from pyspark.sql.functions import *
              from customer.etl_framework import some_function
          match_patterns:
              - (SASMetaJob)
          output_type: sas_dbr_notebook_header
        - inline: 'ROW_NUMBER() OVER (ORDER BY 1)'
          match_patterns:
              - (SASSQLCallExpression @func_name=(@identifier="MONOTONIC"))
          output_type: snippet
          tags: ["spark_sql"]
  node_filter:
      - type: SASProgram
        exclude: ["123"]

By configuring these settings, you can customize the conversion process to better suit your specific project requirements. The General Converter Configuration enables you to define how your code is transformed, giving you greater control over the output.

Template Tag Filter Configuration

Option Description Default Value Data Type
exclude List of tags to exclude from rendering. [] list
include List of tags to include in rendering. [] list

  1. The default output extension for a given dialect may be different. Refer to dialect-specific documentation for more information.