Skip to content

Instantly share code, notes, and snippets.

@bgogul
Created April 6, 2022 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgogul/9d737fe5d6de987c04754c988a11c85c to your computer and use it in GitHub Desktop.
Save bgogul/9d737fe5d6de987c04754c988a11c85c to your computer and use it in GitHub Desktop.
val timestampWindow =
withPattern("(?a - ?b) < 1000")
.whenInput("a", Timestamp)
.whenInput("b", Timestamp)
.thenAddLabel(TimestampWindow)
mayHaveTag(result, "TimestampWindow") :-
TagTransform(result, "timestampwindow", [op1, op2])
hasIntegrity(op1, "TimeStamp"),
hasIntegrity(op2, "TimeStamp").
@markww
Copy link

markww commented Apr 6, 2022

.type Precondition = [name, operand]
.type PreconditionList = [precondition, next]
.decl tagTransform(result, ruleName, preconditionList: PreconditionList)

tagTransformToIndividualPreconditions(result, ruleName, precondition) :- tagTransform(rule, ruleName, [precondition, tail])

mayHaveTag(result, "TimestampWindow") :-
TagTransform(result, "timestampwindow", _),
tagTransformToIndividualPreconditions(result, "timestampwindow", ["a", op1]),
tagTransformToIndividualPreconditions(result, "timestampwindow", ["b", op2,]),
hasIntegrity(op1, "TimeStamp"),
hasIntegrity(op2, "TimeStamp").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment