Skip to content

Conversation

Jefffrey
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Currently not able to easily represent arbitrary sized FixedSizeBinarys in type signature API.

What changes are included in this PR?

Introduce new FIXED_SIZE_BINARY_WILDCARD const that allows specifying type signatures which accept arbitrarily sized fixed size binary, similar to FIXED_SIZE_LIST_WILDCARD. Also modify bitmap_count signature to use this new signature.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions spark labels Sep 12, 2025
/// valid length. It exists to avoid the need to enumerate all possible fixed size binary lengths.
///
/// The value is offset by 1 to make it distinct from [`FIXED_SIZE_LIST_WILDCARD`].
pub const FIXED_SIZE_BINARY_WILDCARD: i32 = i32::MIN + 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just in case someone puts FIXED_SIZE_LIST_WILDCARD when they meant FIXED_SIZE_BINARY_WILDCARD, as otherwise they would be interchangeable

@Jefffrey
Copy link
Contributor Author

fyi @SparkApplicationMaster

/// This is used where a function can accept a fixed size binary type with any
/// valid length. It exists to avoid the need to enumerate all possible fixed size binary lengths.
///
/// The value is offset by 1 to make it distinct from [`FIXED_SIZE_LIST_WILDCARD`].
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't have to be different?

@@ -913,6 +916,10 @@ fn coerced_from<'a>(
Some(_) => Some(FixedSizeList(Arc::clone(f_into), *size_from)),
_ => None,
},
// should be able to coerce wildcard fixed size binary to non wildcard fixed size binary
(FixedSizeBinary(FIXED_SIZE_BINARY_WILDCARD), FixedSizeBinary(size_from)) => {
Copy link
Member

Choose a reason for hiding this comment

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

technically speaking, FixedSizeBinary(-2147483647) is not a valid type, so it's not meaningful to define a coercion between it and any other type. I can see how it may be useful in case of function signatures though. What we actually want is generic signatures in functions. i.e. a signature that is not a type itself, but matches a type.

Binary,
BinaryView,
LargeBinary,
FixedSizeBinary(FIXED_SIZE_BINARY_WILDCARD),
Copy link
Member

Choose a reason for hiding this comment

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

Rather than use this invalid type hack, i'd recommend implementing this for now as a "user defined signature"

long term solution is to have Signature::uniform accept generic types (type patterns).

@Jefffrey
Copy link
Contributor Author

What we actually want is generic signatures in functions. i.e. a signature that is not a type itself, but matches a type.

long term solution is to have Signature::uniform accept generic types (type patterns).

Do we have any tracking issues for these atm?

@findepi
Copy link
Member

findepi commented Sep 12, 2025

I realized we may get away without introducing a generic type concept.
The existing TypeSignature::Coercible's TypeSignatureClass seems to be more or less it.
did you try to use it?

cc @jayzhan211

@Jefffrey
Copy link
Contributor Author

I realized we may get away without introducing a generic type concept. The existing TypeSignature::Coercible's TypeSignatureClass seems to be more or less it. did you try to use it?

cc @jayzhan211

Let me take a look 👍

@Jefffrey Jefffrey marked this pull request as draft September 13, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions spark
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce wildcard const for FixedSizeBinary
2 participants