Skip to content

Conversation

Standing-Man
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

Implment Spark map function map

Are these changes tested?

Yes

Are there any user-facing changes?

Yes

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) spark labels Jul 28, 2025
Signed-off-by: Alan Tang <jmtangcs@gmail.com>
@Standing-Man
Copy link
Contributor Author

Hi @alamb, no rush, but when you have some time, I’d love your review on this PR. Thanks in advance!

@alamb alamb removed the spark label Aug 12, 2025
let keys = args.keys().map(|a| a.as_ref()).collect::<Vec<_>>();
let values = args.values().map(|a| a.as_ref()).collect::<Vec<_>>();
if keys.iter().any(|a| a.data_type() != key_type) {
return exec_err!("map requires all key types to be the same");
Copy link
Contributor

Choose a reason for hiding this comment

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

please consider checking this implementation:
https://github.com/lakehq/sail/blob/0a82099c61cf29e9cdfa33666955e55b37a2256a/crates/sail-plan/src/function/scalar/map.rs#L8
https://github.com/lakehq/sail/blob/0a82099c61cf29e9cdfa33666955e55b37a2256a/crates/sail-plan/src/extension/function/map/map_function.rs#L15

it supports:

  • type coersion for keys and values
  • empty map creation
  • keys deduplication
  • map creation from values, arrays and entries

and passes spark-tests

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

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EPIC] Complete datafusion-spark Spark Compatible Functions

3 participants