Skip to content

PG->Fabric (T-SQL): PostgreSQL format() printf function mis-mapped to T-SQL FORMAT #302

Description

@VaibhaveS

Found while transpiling PostgreSQL -> Microsoft Fabric (T-SQL) with polyglot-sql 0.5.15 (main 43a4458, latest release tag). Scope: SELECT queries only. Every "Actual" value was captured directly from transpile(sql, DialectType::PostgreSQL, DialectType::Fabric). Unless the table notes otherwise, each case also reproduces under Dialect::get(PostgreSQL).transpile_with(sql, Fabric, TranspileOptions::strict()). Cross-checked against the existing PostgreSQL->Fabric issue series (#257-#286) to avoid duplicates.

Failing SELECT query

Input (PostgreSQL) Actual (invalid) Expected (approx.)
SELECT format('%s-%s', a, b) FROM t SELECT FORMAT('%s-%s', a, b) FROM t SELECT CONCAT(a, '-', b) FROM t

Defect: PG format(fmt, args…) is printf-style; T-SQL FORMAT(value, format[, culture])
takes a value first. FORMAT('%s-%s', a, b) is nonsensical (3 args, string first) and doesn't
interpolate.

Root cause: the same TO_CHAR/DATE_FORMATFORMAT renaming path (tsql.rs:1725+) collides
with PG's unrelated format().

Fix: translate format() with %s/%I/%L specifiers into CONCAT/quoting; do not route it
through T-SQL FORMAT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions