Author a new rule function

Compose a transform the deployed catalog does not have, see what it does, and open it for review

Back to the rule builder

Compose the transform as an ordered list of operations, see it run on your own sample values, then open it for review.

What you are composing

An ordered list of operations, applied left to right to one value. Operation 1 takes the piped value — for a rule, the source column it binds; each operation after that takes the result of the one before it.

There is no SQL field here

You are not writing a function body. This surface accepts no SQL, and the file it produces carries none — the statement is rendered from these operations by the rules-engine pipeline after a merge.

A transform this list cannot express is hand-written by an engineer in rules-engine, under that repository's review.

What the function is

Upper case letters, digits and underscores, at least three characters. Bare name only — the service adds the catalog's qualifier.

Checking the definition also checks this name against the function files on rules-engine's main branch and against other proposals waiting in the studio. It does not check Snowflake.

At least eight characters. It is the only prose a reviewer gets about intent, and it lands in Git permanently, so no patient data.

Whether the catalog should have this function, rather than whether the logic is right. Permanent and org-visible.

By name, so a reviewer can find it. Advisory — the dependency that blocks a deploy is declared on the rule.

What it takes

Position 1 is the value piped in — every function has one and no rule ever supplies it. Positions 2 and after are configuration each rule supplies when it calls this function.

Parameter 1 — value

The key a rule's parameter binding looks up. A key, never a value.

A date-typed parameter rejects an unreadable value with an error rather than resolving it to nothing.

Follows from the position, not chosen: position 1 is the piped value, everything after it is configuration.

The piped value

Position 1 cannot be removed: a function with no input has nothing to transform.

What it does, step by step

Each stage is one operation. The fields under it are the operands that operation takes, so they change with the operation.

Adds Trim surrounding spaces as step 1, so the stages below start at stage 2 and nothing moves above it. A Trim that reaches step 1 becomes this box. Untick it to put another stage first. There is no option to trim the result: add a Trim stage where you want one.

Stage 2

Chosen from the closed list. There is no free-text operation and no way to name one that is not here.

An ordered list of operations, applied left to right to one value. Operation 1 takes the piped value — for a rule, the source column it binds; each operation after that takes the result of the one before it.

The input value, trimmed

A pipeline needs at least one stage.

What kind of change does this function make?

Only a pipeline with a Map values step can change the vocabulary

Case, spacing, dates, number types, units, placeholders turned into nothing, punctuation, and validity checks within the same code system.

The result is a code from a different code system from the input, through a small fixed crosswalk. Larger or changing crosswalks belong in a governed value map, not a function.

This pipeline, in order

Trim surrounding spaces

Sample values to try it on

These samples are shown to the reviewer and included in the pull request. No patient data.

Typed by hand. Nothing here reads a column: this function has nothing bound to it yet. Leave the box empty and the reviewer sees synthetic samples, labelled as such.

Up to 20 values.

Values for this function's own parameters

This function declares no configuration parameters, so there is nothing to supply for the preview.

What it gives back

Determined by the last operation, not chosen. It decides the datatype of the _XFR column every rule bound to this function writes.

Choose the operations above and the return type follows from the last one.

Derived from the operations. A pipeline that compares against today's date depends on when it runs, and the deployed function has to say so.

Same input, same result, always
More about the datatype

There is no datatype picker here or in the rule builder. Where a function returns text no numeric target is offered — a fax number's leading zero, extension or + prefix is a real value a numeric column would destroy.

The catalog's FUNCTION_OUTPUT_TYPE says SCALAR for every registered function. That is scalar-versus-table, not a datatype; the datatype lives in the deployed function's return clause.

The result can always be nothing: every operation in the list can resolve a value to nothing.

What a rule will have to supply

The three numbers that must agree.

Arguments the catalog will record
1
Parameters the deployed function will declare
1
Arguments each rule step must bind
0

One fewer than the total: position 1 is the piped column value and no rule supplies it.

Reported by the service when the definition is checked.

This pipeline, in order

3 fields must be resolved before this definition can be checked.

{
  "form": "SCALAR_EXPRESSION_PIPELINE",
  "language": "SNOWFLAKE_SQL_EXPRESSION",
  "null_input_behavior": "RETURNS_NULL_ON_NULL_INPUT",
  "pipeline": [
    {
      "op": "TRIM",
      "sequence": 1
    }
  ],
  "signature": {
    "parameters": [
      {
        "name": "value",
        "position": 1,
        "role": "INPUT",
        "sql_type": "VARCHAR"
      }
    ]
  }
}

Check it and see what it does

Checks the definition and shows what it does to your sample values. It runs inside the service — no warehouse statement, no function created. Asking twice is free.

The definition is not complete yet, so there is nothing to check. The field messages above say what is missing.

The definition has not been checked yet.

Submit it for review

Records this definition as a proposal awaiting approval. It creates no function anywhere.

Submitting is blocked: the definition is not complete yet.

Approval

This commits one file — the function's definition, with no SQL text in it — on a new branch and opens one pull request against the rules-engine repository.

It creates no function, in any environment. It executes no statement against any warehouse, applies nothing, promotes nothing and deploys nothing. The studio holds no privilege to do any of those things, in any account.

The studio cannot merge it. Merging needs an approving review under rules-engine's branch protection, which the studio cannot see or check. The function comes into existence when that repository's pipeline applies the merged file — separately in each environment.

There is no merge, promote, deploy or apply action on this screen, and none is shown greyed out. The studio holds no permission to merge and must not imply that it does.

There is nothing to approve yet. A definition can be approved only after it has been submitted.