mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-19 05:52:20 +00:00
added logic for modulo function for pyodbc driver (#8853)
This commit is contained in:
parent
be59a78a49
commit
d680d5d2d2
@ -58,7 +58,7 @@ def _(elements, compiler, **kwargs):
|
|||||||
@compiles(MedianFn, Dialects.MSSQL)
|
@compiles(MedianFn, Dialects.MSSQL)
|
||||||
def _(elements, compiler, **kwargs):
|
def _(elements, compiler, **kwargs):
|
||||||
"""Median computation for MSSQL"""
|
"""Median computation for MSSQL"""
|
||||||
col, _ = [compiler.process(element, **kwargs) for element in elements.clauses]
|
col = elements.clauses.clauses[0].name
|
||||||
return "percentile_cont(0.5) WITHIN GROUP (ORDER BY %s ASC) OVER()" % col
|
return "percentile_cont(0.5) WITHIN GROUP (ORDER BY %s ASC) OVER()" % col
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,3 +74,13 @@ def _(element, compiler, **kw):
|
|||||||
"""SQLite modulo function"""
|
"""SQLite modulo function"""
|
||||||
value, base = validate_and_compile(element, compiler, **kw)
|
value, base = validate_and_compile(element, compiler, **kw)
|
||||||
return f"{value} % {base}"
|
return f"{value} % {base}"
|
||||||
|
|
||||||
|
|
||||||
|
@compiles(ModuloFn, Dialects.MSSQL)
|
||||||
|
def _(element, compiler, **kw):
|
||||||
|
"""Azure SQL modulo function"""
|
||||||
|
value, base = validate_and_compile(element, compiler, **kw)
|
||||||
|
if compiler.dialect.driver == "pyodbc":
|
||||||
|
# pyodbc compiles to c++ code.
|
||||||
|
return f"{value} % {base}"
|
||||||
|
return f"{value} %% {base}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user