Question
I am migrating conditional Expectations to GX Core 1.24 and using the new Python-object syntax for row_condition.
My execution engine is Pandas.
The documentation for restricting an Expectation to specific rows explains that a row condition is:
a boolean expression built with Python objects
It shows conditions such as:
from great_expectations.expectations.row_conditions import Column
Column("tenure") > 2
Column("salary") <= 50000
Column("department") == "Sales"
It also lists ==, !=, >, <, >=, and <= as supported comparison operators.
However, all documented examples compare a column with a literal value. The page does not explicitly state whether the value on the right-hand side can be another Column.
What I need to express
I need to apply an Expectation only to rows where the value of one column is greater than the value of another column.
A simplified example is:
from great_expectations.expectations.row_conditions import Column
import great_expectations as gx
expectation = gx.expectations.ExpectColumnValuesToNotBeNull(
column="end_date",
row_condition=Column("end_date") > Column("start_date"),
)
Conceptually, the business rule is:
Validate that
end_dateis not null only for rows whereend_dateis greater thanstart_date.
Documentation ambiguity
The ComparisonCondition API reference defines the comparison as:
ComparisonCondition(
column: Column,
operator: Operator,
parameter: Any,
)
The annotation parameter: Any could suggest that another Column might be accepted. However, the description says that the condition represents “the comparison of a column with a parameter,” and there is no column-to-column example.
Questions
- Is the following expression officially supported in GX Core 1.24?
Column("end_date") > Column("start_date")
-
If it is supported, does it work consistently with the Pandas, Spark, and SQL execution engines?
-
If it is not supported, is this an intentional limitation of the new
row_conditionAPI? -
What is the recommended GX Core 1.24 approach when a conditional Expectation requires a row-by-row comparison between two columns?
I am aware of column-pair Expectations such as ExpectColumnPairValuesAToBeGreaterThanB. However, that Expectation validates the relationship between the two columns directly. My use case is slightly different: I want the column comparison to select the rows on which another Expectation is evaluated.
I reviewed the row-condition documentation and API reference, but I could not find an explicit statement confirming or excluding column-to-column comparisons.
Thank you.