Skip to content

Conversation

@kesmit13
Copy link
Collaborator

@kesmit13 kesmit13 commented Dec 5, 2025

No description provided.

kesmit13 and others added 2 commits November 19, 2025 15:33
This commit adds extensive test coverage for np.bool_ and bool types in
Python UDFs, including both scalar (non-vector) and vector operations.

Changes:
- Added np.bool_ to numpy_type_map in signature.py for proper type
  signature resolution

- Added bool UDF implementations in ext_funcs/__init__.py:
  * Scalar operations: bool_and, bool_or, bool_not, bool_xor
  * Vector operations for numpy, pandas, polars, and pyarrow
  * Nullable variants for all frameworks
  * Masked variants with explicit null handling

- Added test data in test.sql:
  * bool_data table with non-nullable bool columns
  * bool_data_with_nulls table for testing null handling

- Added integration tests in test_ext_func.py:
  * 4 scalar bool tests (and, or, not, xor)
  * 4 vector non-nullable tests (numpy, pandas, polars, arrow)
  * 5 nullable tests (scalar + 4 frameworks)
  * 4 masked tests (all frameworks)

- Added type signature tests in test_udf.py:
  * bool and np.bool_ type mapping
  * Optional[bool] nullable mapping
  * List[bool] vector mapping
  * Bool return types

Special handling for pyarrow:
- Converts TINYINT (0/1) to bool using pc.not_equal(x, 0)
- Converts bool results back to int8 for proper serialization

All tests passing, pre-commit hooks clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

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 PR adds support for using boolean types in User-Defined Function (UDF) type annotations for SingleStoreDB, enabling developers to use bool and np.bool_ types in their UDF signatures. The implementation correctly handles the Python type system where bool is a subclass of int, ensuring proper type resolution and SQL mapping.

Key changes:

  • Extended type mapping system to recognize bool types (both Python's built-in bool and NumPy's np.bool_)
  • Added comprehensive test coverage for scalar, vector, nullable, and masked bool operations across multiple data processing libraries
  • Created test data fixtures for bool validation with and without nulls

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
singlestoredb/functions/signature.py Added bool type mappings to numpy_type_map and int_type_map for proper type normalization
singlestoredb/tests/test_udf.py Added unit tests verifying bool type annotations generate correct SQL signatures for parameters and return types
singlestoredb/tests/test_ext_func.py Added comprehensive integration tests for bool UDFs including scalar operations (AND, OR, NOT, XOR), vector operations, and nullable variants across numpy, pandas, polars, and pyarrow
singlestoredb/tests/test.sql Created test tables bool_data and bool_data_with_nulls with appropriate bool column configurations
singlestoredb/tests/ext_funcs/init.py Implemented bool UDF test functions following existing patterns, including explicit BOOL dtype decorators and library-specific implementations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kesmit13 kesmit13 merged commit 377ddcf into main Dec 5, 2025
11 checks passed
@kesmit13 kesmit13 deleted the add-np-bool-udf-tests branch December 5, 2025 17:09
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.

2 participants