From d194a40445a18b7c20c0295af264cf45bd88522d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Rembia=C5=82kowski?= <95128697+filip-xmargin@users.noreply.github.com> Date: Fri, 13 May 2022 11:11:43 +0200 Subject: [PATCH] add cast to text before length() (#4926) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Filip RembiaƂkowski --- ingestion/src/metadata/orm_profiler/orm/functions/length.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ingestion/src/metadata/orm_profiler/orm/functions/length.py b/ingestion/src/metadata/orm_profiler/orm/functions/length.py index 89dd168be72..cab14c6f4f7 100644 --- a/ingestion/src/metadata/orm_profiler/orm/functions/length.py +++ b/ingestion/src/metadata/orm_profiler/orm/functions/length.py @@ -34,7 +34,6 @@ def _(element, compiler, **kw): @compiles(LenFn, Dialects.SQLite) @compiles(LenFn, Dialects.Vertica) @compiles(LenFn, Dialects.Hive) -@compiles(LenFn, Dialects.Postgres) @compiles(LenFn, Dialects.Databricks) @compiles(LenFn, Dialects.MySQL) @compiles(LenFn, Dialects.MariaDB) @@ -43,3 +42,8 @@ def _(element, compiler, **kw): @compiles(LenFn, Dialects.Presto) def _(element, compiler, **kw): return "LENGTH(%s)" % compiler.process(element.clauses, **kw) + + +@compiles(LenFn, Dialects.Postgres) +def _(element, compiler, **kw): + return "LENGTH(CAST(%s AS text))" % compiler.process(element.clauses, **kw)