Skip to content

fix: apply column expression on freshness check correctly#2607

Merged
m1n0 merged 1 commit intomainfrom
dtl-1657-support-structured-data-and-type-casting
Feb 26, 2026
Merged

fix: apply column expression on freshness check correctly#2607
m1n0 merged 1 commit intomainfrom
dtl-1657-support-structured-data-and-type-casting

Conversation

@m1n0
Copy link
Contributor

@m1n0 m1n0 commented Feb 26, 2026

Description

Checklist

  • I added a test to verify the new functionality.
  • I verified this PR does not break soda-extensions.

@m1n0 m1n0 requested a review from Copilot February 26, 2026 14:19
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes freshness checks to correctly honor column_expression (and only default to the configured column when no expression is provided), aligning freshness behavior with other check types that already support column-expression overrides.

Changes:

  • Update FreshnessCheckImpl.column_expression to prefer the base check’s resolved column_expression and fall back to COLUMN(check_yaml.column) when absent.
  • Adjust the column-expression feature test to ensure freshness actually requires the expression (by extracting the timestamp from JSON metadata).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
soda-tests/tests/feature/test_column_expression.py Updates test data + contract YAML to validate freshness uses column_expression (JSON extract) rather than the raw column value.
soda-core/src/soda_core/contracts/impl/check_types/freshness_check.py Fixes freshness check column-expression resolution by using the standard check-level expression mechanism with a safe fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +101 to +102
column: metadata
column_expression: '${{var.metadata_col_expr}}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid in a contract? Thinking about it I would see these as conflicting, so perhaps we should reject it in JSON schema validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you referring to having both column and column_expression present? Yeah this is valid, at least for now. We didn't want to do a breaking change of removing column which may potentially become obsolete. Not allowing both is an option, but no particular reason to do it. This still allows us to associate the check with a column.

Comment on lines +165 to +166
if not expression:
expression = COLUMN(self.check_yaml.column)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to check whether self.check_yaml.column is set? What if neither is available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah self.check_yaml is FreshnessCheckYaml type which does mandatory column read self.column: str = check_yaml_object.read_string("column")

@m1n0 m1n0 merged commit 76993a5 into main Feb 26, 2026
38 of 39 checks passed
@m1n0 m1n0 deleted the dtl-1657-support-structured-data-and-type-casting branch February 26, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants