Skip to content

Conversation

@ahkcs
Copy link
Contributor

@ahkcs ahkcs commented Oct 28, 2025

Description

When the bin command is applied to a non-numeric field (e.g., string) with numeric span parameters, the command fails with unclear Calcite type validation errors, making it difficult for users to identify the root cause

This PR Added clear validation in BinFieldValidator that throws SemanticCheckException with message, Added field type checks in all numeric bin handlers before Calcite validation, providing clearer user-facing error messages

Related Issues

Partially resolves #4590

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ahkcs ahkcs force-pushed the bin_error_enhancement branch from 9798be7 to 048a7de Compare October 29, 2025 17:56
@Swiddis Swiddis added the enhancement New feature or request label Oct 29, 2025
ahkcs added 2 commits October 29, 2025 18:10
Signed-off-by: Kai Huang <[email protected]>
Signed-off-by: Kai Huang <[email protected]>
Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

QQ: what's the expected behavior? In PR description, semantic exception is expected. In issue #4590, the expectation is "the bin command should gracefully skip numeric binning for non-numeric fields and preserve the original field values instead of throwing an error." ?

Copy link
Collaborator

@ykmr1224 ykmr1224 left a comment

Choose a reason for hiding this comment

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

LGTM with minor comment.

*
* @return true if the field should use numeric binning, false if it should use time-based binning
*/
public boolean requiresNumericBinning() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This method was confusing to me. It might be better changing it to isNumeric is it is actually used to check if the field is numeric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Tomo, this method exists because some parameters such as minspan, start, end currently don't support time-based binning, so they will use this method to check first

@ahkcs
Copy link
Contributor Author

ahkcs commented Oct 30, 2025

QQ: what's the expected behavior? In PR description, semantic exception is expected. In issue #4590, the expectation is "the bin command should gracefully skip numeric binning for non-numeric fields and preserve the original field values instead of throwing an error." ?

Hi @dai-chen , this PR is for short-term fix to enhance error handling, our long-term goal would be the expected behavior in #4590

@Swiddis Swiddis merged commit d1ffabd into opensearch-project:main Oct 30, 2025
33 of 34 checks passed
@ahkcs ahkcs deleted the bin_error_enhancement branch October 30, 2025 23:58
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.19-dev failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-4690-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d1ffabd500e11730b982d53a29342e8953026724
# Push it to GitHub
git push --set-upstream origin backport/backport-4690-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-dev

Then, create a pull request where the base branch is 2.19-dev and the compare/head branch is backport/backport-4690-to-2.19-dev.

@LantaoJin
Copy link
Member

@ahkcs backport required, thanks.

ahkcs added a commit to ahkcs/sql that referenced this pull request Oct 31, 2025
@LantaoJin LantaoJin added the backport-manually Filed a PR to backport manually. label Nov 3, 2025
expani pushed a commit to vinaykpud/sql that referenced this pull request Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.19-dev backport-failed backport-manually Filed a PR to backport manually. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] bin Command Validation enhancement on Non-Numeric Fields

5 participants