-
Notifications
You must be signed in to change notification settings - Fork 65
feat: to_char expression #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: to_char expression #874
Conversation
shehabgamin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SubhamSinghal Thank you so much for this contribution! Exciting progress
| Ok(ColumnarValue::Scalar(ScalarValue::Utf8(Some(s)))) | ||
| } | ||
| } | ||
| _ => not_impl_err!("to_char currently supports only scalar values with literal format string"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to account for array input:
(ColumnarValue::Array(array), ColumnarValue::Array(array))
(ColumnarValue::Array(array), ColumnarValue::Scalar(ScalarValue::Utf8(Some(fmt))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shehabgamin need some help in fixing rust error
Gold Data ReportNotes
Commit Information
Summary
DetailsGold Data Metrics
|
|
Thanks for the contribution! You can run the following commands locally for formatting and linting:
|
There was a problem hiding this 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 implements the to_char expression for formatting numeric values to strings in Spark SQL, enabling conversion of numbers to formatted string representations using format patterns.
- Implementation of the
to_charfunction with support for various numeric format patterns including zero-padding, optional digits, decimal points, grouping separators, and sign indicators - Addition of comprehensive test coverage through golden test files demonstrating various formatting scenarios
- Integration of the new function into the execution engine with proper registration and type handling
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| python/pysail/tests/spark/function/test_to_char.txt | Test examples showing to_char function behavior with various format patterns |
| crates/sail-spark-connect/tests/gold_data/function/string.json | Updates golden test expectations from failure to success for to_char test cases |
| crates/sail-plan/src/extension/function/string/spark_to_char.rs | Core implementation of the SparkToChar function with number formatting logic |
| crates/sail-plan/src/extension/function/string/mod.rs | Module registration for the new to_char function and format tokens |
| crates/sail-plan/src/extension/function/string/format_tokens.rs | Token parsing logic for format string patterns |
| crates/sail-execution/src/codec.rs | Function registration and integration into the execution engine |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
crates/sail-plan/src/extension/function/string/spark_to_char.rs
Outdated
Show resolved
Hide resolved
|
Nice progress! Could you merge from |
No description provided.