Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Provides a default value if field is null.
:samp:`Coalesce("{FIELD_NAME}", {DEFAULT_VALUE})`
"""
database_func = functions.Coalesce
class Lower(Function):
"""
Converts text to lower case.
:samp:`Lower("{FIELD_NAME}")`
"""
database_func = functions.Lower
class Upper(Function):
"""
Converts text to upper case.
:samp:`Upper("{FIELD_NAME}")`
"""
database_func = functions.Upper
##############################################################################
# Aggregate functions
##############################################################################
:samp:`Sum("{FIELD_NAME}")`
"""
database_func = functions.Sum
populate_field_object = True
class Max(Aggregate):
"""
Returns largest value in the column.
:samp:`Max("{FIELD_NAME}")`
"""
database_func = functions.Max
populate_field_object = True
class Min(Aggregate):
"""
Returns smallest value in the column.
:samp:`Min("{FIELD_NAME}")`
"""
database_func = functions.Min
populate_field_object = True
class Avg(Aggregate):
"""
Returns lenth of text/blob.
:samp:`Length("{FIELD_NAME}")`
"""
database_func = functions.Length
class Coalesce(Function):
"""
Provides a default value if field is null.
:samp:`Coalesce("{FIELD_NAME}", {DEFAULT_VALUE})`
"""
database_func = functions.Coalesce
class Lower(Function):
"""
Converts text to lower case.
:samp:`Lower("{FIELD_NAME}")`
"""
database_func = functions.Lower
class Upper(Function):
"""
Converts text to upper case.
def _default_metric_definition(self, key):
return fn.Sum(self.slicer.table.field(key))
def mysql_insensitive_ends_with(field: Term, value: str) -> Criterion:
return Like(
functions.Upper(functions.Cast(field, SqlTypes.CHAR)),
functions.Upper(StrWrapper(f"%{escape_like(value)}")),
escape="",
)
return lambda metric: (original_field(metric) - ref_field(metric)) * (
100 / fn.NullIf(ref_field(metric), 0)
)
def date_add(self, field, date_part, interval):
return fn.TimestampAdd(str(date_part), interval, field)
def date_add(self, field, date_part, interval):
return fn.DateAdd(str(date_part), interval, field)