Skip to content

Conversation

@chris-fei-rokt
Copy link
Collaborator

@chris-fei-rokt chris-fei-rokt commented Jun 4, 2025

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Rename Expression to Condition
  • Rename Operand to Expression
  • Remove what were previously Expressions that didn't cleanly fit. For example DateExpression, "Represents an expression that evaluates to a date or date-based condition". Fairly certain these are not being used
  • Renamed group_by to group_by_model per prior discussions

Testing Plan

  • Was this tested locally? If not, explain why.
  • {explain how this has been tested, and what, if any, additional testing should be done}

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@chris-fei-rokt chris-fei-rokt force-pushed the refactor/expression-rename branch from 8f5350c to 9023ebf Compare June 4, 2025 15:51
* { date: { relative: { offset: 0, unit: "month", boundary: "start" } } }
*/
export type DateOperand =
export type DateExpression =
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's rename the parent folder to be expression

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes, I was leaving the folder rename for later to minimize diffs

{ model: string, expression: Expression }
| // unary expression
{ operator: UnaryOperator, operand: Operand }
{ operator: UnaryOperator, operand: Expression|Expression[] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we rename operand to expression?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I think it's ok

export type Audience = {
schema_version: Version,
audience: Expression
audience: Condition
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels a bit semantically awkward in my brain. I wonder if we should rename the attribute something like filter: Condition?

Copy link
Collaborator

Choose a reason for hiding this comment

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

condition: Condition ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't bother me. The root audience key is the entry point into defining the criteria for an audience, which is a Condition

@olegk-rokt olegk-rokt self-requested a review June 4, 2025 16:29
olegk-rokt
olegk-rokt previously approved these changes Jun 4, 2025
Comment on lines -58 to +44
"expressions": [
"conditions": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be expression still? In my mind, condition is a filter operation. Likely only relevant to aggregate operations. I would say:

  • Expression == thing the operator is acting on
  • Condition == expression that determines which things are operated on (aka, filters the input)

Copy link
Collaborator

Choose a reason for hiding this comment

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

My vote is to leave it as is. In my mind logical condition can only contain conditions and Condition == expression that returns boolean

Copy link
Collaborator Author

@chris-fei-rokt chris-fei-rokt Jun 4, 2025

Choose a reason for hiding this comment

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

No, Condition applies everywhere, not just aggregate operations. The root expression for an audience evaluates to a boolean to determine membership, e.g.

{
  "operator": "and",
  "conditions": [
    { .. condition 1 .. },
    { .. condition 2 .. },
  ]
}

is itself a Condition

Copy link
Collaborator

Choose a reason for hiding this comment

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

The root expression for an audience evaluates to a boolean to determine membership

I didn't notice this was directly on the audience, but I agree the top level should be a condition. Not a fan of the current syntax, honestly - I would do:

"audience" : {
    "condition": { some bool expression },
}

That way the top level isn't forced to follow the expression syntax, which is more flexible for the future.

I think the other expressions should only use condition as a filter though - so any nested and/or would NOT use condition since they aren't checking a condition, just evaluating an expression. Condition implies check to me, but there are only two checks currently, on aggregates and at the base query.

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.

5 participants