(cherry picked from commit adfbbf1433)
Adapted: also lifts a small infrastructure slice from #37311 (commit
87bbd54d0a) — namely the source_engine
parameter and source_dialect logic on transpile_to_dialect, plus its
three accompanying unit tests. #37311 itself is a feature PR
(import-time virtual-dataset transpilation) that is not desired on
6.0-release; only the plumbing this fix relies on is included.
The source_engine plumbing is required because #39521's call site
passes source_engine=engine to make validate() idempotent on its
second pass: the second invocation re-parses already-transpiled output
that may contain dialect-specific quoting (e.g. MySQL/BigQuery
backticks) which the generic Dialect cannot handle. Without it, the
fix would introduce a new regression on those engines.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>