mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 11:09:14 +00:00
cast to bigint to avoid overflow when summing (#8655)
* cast to bigint to avoid overflow when summing fixes #8430 * Update ingestion/src/metadata/orm_profiler/orm/functions/sum.py Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
This commit is contained in:
parent
86c3ae30f1
commit
6ba5f7ec90
@ -31,9 +31,9 @@ class SumFn(GenericFunction):
|
||||
|
||||
@compiles(SumFn)
|
||||
def _(element, compiler, **kw):
|
||||
"""Handle case for empty table. If empty, clickhouse returns NaN"""
|
||||
"""Cast to BIGINT to address overflow error from summing 32-bit int in most database dialects, #8430"""
|
||||
proc = compiler.process(element.clauses, **kw)
|
||||
return f"SUM({proc})"
|
||||
return f"SUM(CAST({proc} AS BIGINT))"
|
||||
|
||||
|
||||
@compiles(SumFn, Dialects.BigQuery)
|
||||
@ -41,3 +41,11 @@ def _(element, compiler, **kw):
|
||||
"""Handle case where column type is INTEGER but SUM returns a NUMBER"""
|
||||
proc = compiler.process(element.clauses, **kw)
|
||||
return f"SUM(CAST({proc} AS NUMERIC))"
|
||||
|
||||
|
||||
@compiles(SumFn, Dialects.Snowflake)
|
||||
@compiles(SumFn, Dialects.Vertica)
|
||||
def _(element, compiler, **kw):
|
||||
"""These database types have all int types as alias for int64 so don't need a cast"""
|
||||
proc = compiler.process(element.clauses, **kw)
|
||||
return f"SUM({proc})"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user