Skip to content

Update documentation for EDIT_DISTANCE function - #10255

Closed
Simon Sabin (simonsabin) wants to merge 3 commits into
MicrosoftDocs:livefrom
simonsabin:patch-13
Closed

Update documentation for EDIT_DISTANCE function#10255
Simon Sabin (simonsabin) wants to merge 3 commits into
MicrosoftDocs:livefrom
simonsabin:patch-13

Conversation

@simonsabin

Copy link
Copy Markdown
Contributor

Clarified the definition and behavior of the EDIT_DISTANCE function, including details on maximum distance computation and return values.

Clarified the definition and behavior of the EDIT_DISTANCE function, including details on maximum distance computation and return values.
@prmerger-automator

Copy link
Copy Markdown
Contributor

Simon Sabin (@simonsabin) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit b1e42c1:

✅ Validation status: passed

File Status Preview URL Details
docs/t-sql/functions/edit-distance-transact-sql.md ✅Succeeded

For more details, please refer to the build report.

@ktoliver

Copy link
Copy Markdown
Contributor

Mike Ray (@MikeRayMSFT)

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the documentation for the EDIT_DISTANCE function to provide clearer explanations of its behavior and parameters. The changes focus on improving the description of how the function calculates edit distance and how the maximum_distance parameter affects computation.

Key changes:

  • Clarified the function's purpose to emphasize it calculates "distance" as the number of transformations
  • Improved explanation of the maximum_distance parameter behavior
  • Reorganized the Return value and Remarks sections for better clarity
  • Added a second example demonstrating the maximum_distance parameter usage

Comment thread docs/t-sql/functions/edit-distance-transact-sql.md
Comment thread docs/t-sql/functions/edit-distance-transact-sql.md Outdated
Comment thread docs/t-sql/functions/edit-distance-transact-sql.md Outdated
@prmerger-automator prmerger-automator Bot added the aq-pr-triaged tracking label for the PR review team label Dec 19, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 9973739:

✅ Validation status: passed

File Status Preview URL Details
docs/t-sql/functions/edit-distance-transact-sql.md ✅Succeeded

For more details, please refer to the build report.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit b697f0c:

✅ Validation status: passed

File Status Preview URL Details
docs/t-sql/functions/edit-distance-transact-sql.md ✅Succeeded

For more details, please refer to the build report.

@rwestMSFT

Copy link
Copy Markdown
Contributor

#assign:rwestMSFT

@rwestMSFT

Copy link
Copy Markdown
Contributor

Simon Sabin (@simonsabin) Since this edit removes a lot of existing information from maximum_distance, we'll need to confirm the change with the product owner, and it's tricker at the start of a new year with vacations.

There's an internal PR that takes your suggestions into consideration, which is in review. When that merges, this one will close automatically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added my comments.

#### *maximum_distance*

The maximum distance that should be computed. *maximum_distance* is an integer. If greater than or equal to zero, then the function returns the actual distance value or a distance value that is greater than *maxiumum_distance* value. If the actual distance is greater than *maximum_distance*, then the function might return a value greater than or equal to *maximum_distance*. If the parameter isn't specified or if *maximum_distance* is negative, then the function returns the actual number of transformations needed. If the value is NULL, then the function returns NULL.
The maximum distance that should be computed. *maximum_distance* is an integer. If greater than or equal to zero, then the function stops calculating the distance when the *maximum_distance* is reached.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
The maximum distance that should be computed. *maximum_distance* is an integer. If greater than or equal to zero, then the function stops calculating the distance when the *maximum_distance* is reached.
An optional integer that specifies the maximum edit distance to calculate. When *maximum_distance* is greater than or equal to `0`, the function may stop processing once it determines that the edit distance exceeds the specified value.
If the actual edit distance is less than or equal to *maximum_distance*, the function returns the actual distance. Otherwise, the function returns *maximum_distance* + `1`.
If *maximum_distance* isn't specified, or if it's negative, the function returns the actual edit distance. If *maximum_distance* is `NULL`, the function returns `NULL`.

## Remarks

This function implements the Damerau-Levenshtein algorithm. If any of the inputs is `NULL` then the function returns a `NULL` value. Otherwise, the function returns an integer value from 0 to the number of transformations or *maximum_distance* value.
If the actual distance is greater than *maximum_distance*, then the function might return a value greater than or equal to *maximum_distance*.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not required here since we have clarified this in the maximum_distance definition.


**int**

Returns the distance between the two *character_expressions* using Damerau-Levenshtein algorithm, or *maximum_distance* value if that is smaller.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would like to clarify further on the library details.

Returns the distance between the two *character_expressions* using Damerau-Levenshtein (Optimal String Alignment) algorithm, or *maximum_distance* value if that is smaller.

Randolph West MSFT (@rwestMSFT) You can take the call, as per the docs standard whether to have this under "Return value* or under Remarks? Also the library name - Damerau-Levenshtein (Optimal String Alignment) should be updated on the EDIT_DISTANCE_SIMILARITY page as well.

```output
Source Target ActualDistance LimitedDistance
--------- --------- -------------- ---------------
Chocolate Sweets 8 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Result should be as below -
Source Target ActualDistance LimitedDistance
Chocolate Sweets 8 3

@rwestMSFT

Copy link
Copy Markdown
Contributor

I'm going to pull this into an internal PR and close this. Thank you, Simon, for the contribution. We'll make sure you get the appropriate credit.

#please-close

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants