Skip to content

Allow --destination_dialect=bigquery in convert_file#1997

Open
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234:fix/convert-file-missing-bigquery-dest-dialect
Open

Allow --destination_dialect=bigquery in convert_file#1997
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234:fix/convert-file-missing-bigquery-dest-dialect

Conversation

@Chessing234
Copy link
Copy Markdown

Bug

The convert_file subcommand of mimic_utils rejects
--destination_dialect bigquery at argparse time, even though the
pipeline underneath supports bigquery as a destination. The
convert_folder subcommand accepts it.

$ python -m mimic_utils convert_file in.sql out.sql --destination_dialect bigquery
usage: python -m mimic_utils convert_file ...
python -m mimic_utils convert_file: error: argument --destination_dialect:
    invalid choice: 'bigquery' (choose from 'postgres', 'duckdb')

Root cause

In src/mimic_utils/__main__.py:

file_parser.add_argument("--destination_dialect",
    choices=["postgres", "duckdb"], default='postgres', ...)
...
folder_parser.add_argument("--destination_dialect",
    choices=["bigquery", "postgres", "duckdb"], default="postgres", ...)

file_parser is missing "bigquery" from its choices. Both subparsers
ultimately dispatch into transpile_file / transpile_folder, which
both call transpile_query(..., destination_dialect=...). That function
validates the dialect via _FUNCTION_MAPPING, which contains
{'bigquery': {}, 'postgres': {...}, 'duckdb': {...}} — so bigquery is
a supported destination; the CLI choice list is the only thing blocking
it.

Why the fix is correct

  • The two subcommands call the same transpilation code; their
    destination choices should match.
  • The underlying transpile_query / _FUNCTION_MAPPING already
    accepts bigquery as a destination dialect.
  • Adds exactly one value to the choices list; default, help text, and
    dispatch remain unchanged.

Change

src/mimic_utils/__main__.py: add "bigquery" to the file_parser
--destination_dialect choices.

The convert_folder subcommand accepts
  --destination_dialect {bigquery,postgres,duckdb}
but convert_file's matching argument is restricted to
  --destination_dialect {postgres,duckdb},
so `mimic_utils convert_file --destination_dialect bigquery ...` fails at
argparse time even though the underlying transpile_file /
transpile_query pipeline supports bigquery as a destination (it is in
_FUNCTION_MAPPING in transpile.py, alongside postgres and duckdb). The
two subcommands should have the same set of destination dialects since
they call the same transpilation code. Add "bigquery" to the file parser's
choices to mirror the folder parser.
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.

1 participant