Skip to content

Comments

feat: Implement Spark bin function#20479

Open
kazantsev-maksim wants to merge 4 commits intoapache:mainfrom
kazantsev-maksim:spark_bin
Open

feat: Implement Spark bin function#20479
kazantsev-maksim wants to merge 4 commits intoapache:mainfrom
kazantsev-maksim:spark_bin

Conversation

@kazantsev-maksim
Copy link
Contributor

Which issue does this PR close?

N/A

Rationale for this change

Add new function: https://spark.apache.org/docs/latest/api/sql/index.html#bin

What changes are included in this PR?

  • Implementation
  • Unit Tests
  • SLT tests

Are these changes tested?

Yes, tests added as part of this PR.

Are there any user-facing changes?

No, these are new function.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) spark labels Feb 22, 2026

pub fn bitmap_bucket_number_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
let [array] = take_function_args("bitmap_bucket_number", arg)?;
pub fn spark_bin_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub fn spark_bin_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
fn spark_bin_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {

Doesn't need to be pub

## PySpark 3.5.5 Result: {'bin(13.3)': '1101', 'typeof(bin(13.3))': 'string', 'typeof(13.3)': 'decimal(3,1)'}
#query
#SELECT bin(13.3::decimal(3,1));
query T
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to add some null handling test cases + handling actual table columns

#SELECT bin(13::int);

## Original Query: SELECT bin(13.3);
## PySpark 3.5.5 Result: {'bin(13.3)': '1101', 'typeof(bin(13.3))': 'string', 'typeof(13.3)': 'decimal(3,1)'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Spark supports decimal, we should add this support to this PR as well

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

Labels

spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants