compare_length

calista.core.functions.compare_length(col_name: str, operator: str, length: int) ConditionExpression

Create a condition to compare the length of the column values.

Args:

col_name (str): The name of the column. operator (str): A comparison operator : “=”, “!=”, “<”, “<=”, “>”, “>=” length (int): The length to compare against.

Returns:

ConditionExpression: The condition to compare the length of the column values.

Example

>>> from calista import CalistaEngine
>>> from calista.core.functions import compare_length
>>>
>>> calista_table = CalistaEngine(engine = "spark").load_from_dict({"PLANETE": ["mars", None, "jupiter", "terre"]})
>>> my_rule = compare_length(col_name="PLANETE", operator=">=", length=5)
>>> print(calista_table.analyze(rule_name="My Rule Name", condition=my_rule))
rule_name : My Rule Name
total_row_count : 4
valid_row_count : 2
valid_row_count_pct : 50.0
timestamp : 2024-01-01 00:00:00.000000