add cast to text before length() (#4926)

Co-authored-by: Filip Rembiałkowski <filip.rembialkowski@gmail.com>
This commit is contained in:
Filip Rembiałkowski 2022-05-13 11:11:43 +02:00 committed by GitHub
parent cfab77c854
commit d194a40445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)