Hi,
I’m having an error in connector postgres, since Monday:
This error is cause by a formula, that i have used for a long time:
CONCAT(MAX(CASE
WHEN capfab = ‘CORREIA’ THEN TODATE(DATETIME_ADD(P. Entrega, INTERVAL -2 DAY), “%Y%m%d”, “%d/%m”)
ELSE NULL END), (CASE
WHEN DATETIME_DIFF((MAX(CASE
WHEN capfab = ‘CORREIA’ THEN DATETIME_ADD(P. Entrega, INTERVAL -2 DAY)
ELSE NULL END)), MAX(diaatu), DAY) < 0 THEN ‘’
WHEN DATETIME_DIFF((MAX(CASE
WHEN capfab = ‘CORREIA’ THEN DATETIME_ADD(P. Entrega, INTERVAL -2 DAY)
ELSE NULL END)), MAX(diaatu), DAY) < 2 THEN ‘;’
ELSE ‘’ END), (CASE
WHEN CORREIA < 1 THEN '’
ELSE ‘..’ END))
This look like a change in connector, that is passing to the query postgres a wrong function for DATETIME_DIFF. Anyone is having this same error in the last days?
The error comes from the Postgres connector misinterpreting DATETIME_DIFF. The translation fails because Postgres doesn’t include that function. It likely worked before because the connector was rewriting it into a Postgres-compatible expression.
Using native timestamp operations is a preferable strategy. Postgres supports subtraction directly, or the AGE() function.
To keep the same logic, extract days from the interval:
SELECT EXTRACT(DAY FROM (MAX(p.entrega) - MAX(diaatu))) AS days_diff;
This avoids connector-specific functions and keeps queries stable.
In our pipelines (BigQuery → Windsor → Snowflake), we normalize these differences at the SQL layer. Windsor keeps queries portable, preventing silent failures from occurring when connectors are changed. Portability is the key defense against breakage.