Skip to content

Conversation

@mihaibudiu
Copy link
Contributor

Fixes #5386
Fixes #5385

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds validation to prevent the unary minus (negation) operator from being applied to unsigned integer values, fixing issues #5386 and #5385. The change correctly identifies that negating an unsigned value is semantically invalid and could lead to unexpected behavior.

Key changes:

  • Added compile-time validation that throws an error when unary minus is applied to unsigned integers
  • Added regression tests to verify the validation works correctly
  • Updated documentation to clarify that unary minus cannot be applied to unsigned values

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/ExpressionCompiler.java Added validation logic to reject unary minus on unsigned integer types during compilation
sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/simple/Regression1Tests.java Added test cases to verify compilation fails with appropriate error message when negating unsigned integers
docs.feldera.com/docs/sql/integer.md Updated documentation to explicitly state that unary minus cannot be applied to unsigned values

Comment on lines +1722 to +1730
public void issue5386() {
this.statementsFailingInCompilation("""
CREATE TABLE T(x INT UNSIGNED);
CREATE VIEW V AS SELECT -x FROM T;""",
"Unary minus cannot be applied");
this.statementsFailingInCompilation(
"CREATE VIEW V AS SELECT - CAST(1 AS INT UNSIGNED)",
"Unary minus cannot be applied");
}
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The test coverage for unsigned negation is limited to only INT UNSIGNED. Consider adding test cases for other unsigned integer types: TINYINT UNSIGNED, SMALLINT UNSIGNED, and BIGINT UNSIGNED to ensure the validation works consistently across all unsigned integer types.

Copilot uses AI. Check for mistakes.
@mihaibudiu mihaibudiu added this pull request to the merge queue Jan 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue Jan 9, 2026
Merged via the queue into main with commit 060eee6 Jan 9, 2026
7 checks passed
@mihaibudiu mihaibudiu deleted the issue5386 branch January 9, 2026 20:30
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.

[SQL] unary minus (-) on INT UNSIGNED produces an error [SQL] [DOCS] Document the behavior of unary minus (-) on UNSIGNED integer types

3 participants