# `pglast.printers.sfuncs` — Special function printers

The PostgreSQL parser translates some `SQL` constructs into function calls, for example the expression `EXTRACT(YEAR FROM date_column)` is represented the same as `pg_catalog.date_part('year', date_column)`.

This module declares some of those equivalences, implementing alternative printers that will be used when the option special_functions of the `output stream` is set to `True`.

pglast.printers.sfuncs.btrim(node, output)

  Emit function `pg_catalog.btrim(' abc ')` as `trim(BOTH FROM ' abc ')` and `pg_catalog.btrim('xxabcxx', 'x')` as `trim(BOTH 'x' FROM 'xxabcxx')`.

pglast.printers.sfuncs.extract(node, output)

  Emit function `pg_catalog.extract(field, timestamp)` as `EXTRACT(field FROM timestamp).`.

pglast.printers.sfuncs.ltrim(node, output)

  Emit function `pg_catalog.ltrim(' abc ')` as `trim(LEADING FROM ' abc ')` and `pg_catalog.ltrim('xxabcxx', 'x')` as `trim(LEADING 'x' FROM 'xxabcxx').`

pglast.printers.sfuncs.normalize(node, output)

  Emit function `pg_catalog.normalize(a)` as `normalize(x)` and function `pg_catalog.normalize('a','b')` as `normalize('a', b)`.

pglast.printers.sfuncs.overlaps(node, output)

  Emit function `pg_catalog.overlaps(a, b, c, d)` as `(a, b) OVERLAPS (c, d)`.

pglast.printers.sfuncs.overlay(node, output)

  Emit function `pg_catalog.overlay('Txxxxas','hom', 2, 4)` as `overlay('Txxxxas' PLACING 'hom' FROM 2 FOR 4)`.”

pglast.printers.sfuncs.pg_collation_for(node, output)

  Emit function `pg_catalog.pg_collation_for(x)` as `COLLATION FOR (x)`.

pglast.printers.sfuncs.position(node, output)

  Emit function `pg_catalog.position('abcd', 'a')` as `position('a' IN 'abcd')`.

pglast.printers.sfuncs.rtrim(node, output)

  Emit function `pg_catalog.rtrim(' abc ')` as `trim(TRAILING FROM ' abc ')` and `pg_catalog.rtrim('xxabcxx', 'x')` as `trim(TRAILING 'x' FROM 'xxabcxx')`

pglast.printers.sfuncs.substring(node, output)

  Emit function `pg_catalog.substring('Txxxxas', 2, 4)` as `substring('Txxxxas' FROM 2 FOR 4)` and `pg_catalog.substring('blabla', 2)` as `substring('blabla' FROM 2)`.

pglast.printers.sfuncs.timezone(node, output)

  Emit function `pg_catalog.timezone(tz, timestamp)` as `timestamp AT TIME ZONE tz`.

pglast.printers.sfuncs.xmlexists(node, output)

  Emit function `pg_catalog.xmlexists(x, y)` as `xmlexists(x PASSING BY REF y)`.