Skip to content

Commit

Permalink
mssql: Implement mean operator
Browse files Browse the repository at this point in the history
  • Loading branch information
NMAC427 committed Jul 19, 2023
1 parent 506ff0c commit 42bb190
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pydiverse/transform/lazy/sql_table/dialects/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sqlalchemy as sa

from pydiverse.transform.core import ops
from pydiverse.transform.core.util import OrderingDescriptor
from pydiverse.transform.lazy.sql_table.sql_table import SQLTableImpl

Expand All @@ -25,3 +26,10 @@ def _order_col(

order_by_expressions.append(col.asc() if ordering.asc else col.desc())
return order_by_expressions


with MSSqlTableImpl.op(ops.Mean()) as op:

@op.auto
def _mean(x):
return sa.func.AVG(sa.cast(x, sa.Float()))

0 comments on commit 42bb190

Please sign in to comment.