Polyglot SQL API Documentation - v0.2.0
    Preparing search index...

    Function transpile

    • Transpile SQL from one dialect to another.

      Parameters

      • sql: string

        The SQL string to transpile

      • read: Dialect

        Source dialect to parse the SQL with

      • write: Dialect

        Target dialect to generate SQL for

      Returns TranspileResult

      The transpiled SQL statements

      Per-dialect builds: When using a per-dialect sub-path import (e.g., @polyglot-sql/sdk/clickhouse), only same-dialect transpilation and conversion to/from Dialect.Generic are supported. Cross-dialect transpilation (e.g., ClickHouse → PostgreSQL) will return { success: false, error: "Cross-dialect transpilation not available in this build" }. Use getDialects to check which dialects are available at runtime.

      const result = transpile(
      "SELECT IFNULL(a, b)",
      Dialect.MySQL,
      Dialect.PostgreSQL,
      );
      // result.sql[0] = "SELECT COALESCE(a, b)"