Skip to content

Conversation

@hsiang-c
Copy link
Contributor

@hsiang-c hsiang-c commented Nov 19, 2025

Which issue does this PR close?

Rationale for this change

Non-ANSI mode ANSI mode ANSI Interval Types
#18205 This PR TODO
  • Support ANSI mode Spark-compatible abs math function

What changes are included in this PR?

Are these changes tested?

  • unit tests
  • SQL logic tests w/ datafusion.execution.enable_ansi_mode = true

Are there any user-facing changes?

Yes, arithmetic overflow will be thrown when ANSI mode is on, i.e. datafusion.execution.enable_ansi_mode=true

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) execution Related to the execution crate functions Changes to functions implementation spark labels Nov 19, 2025
// hardcode target partitions so plans are deterministic
.with_target_partitions(4);
.with_target_partitions(4)
.with_enable_ansi_mode(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turn on ANSI mode here so that sqllogictest show overflow error. We need a different way to toggle ANSI mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just set it like so instead?

# Test disabling recursive CTE
statement ok
set datafusion.execution.enable_recursive_ctes = false;

Instead of doing it globally

Copy link
Contributor

Choose a reason for hiding this comment

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

typically we set a param in slt and then return the original value

statement ok
set datafusion.execution.batch_size = 2;

run stuff ....

statement ok
set datafusion.execution.batch_size = 8192;

@hsiang-c
Copy link
Contributor Author

@Jefffrey @comphead for review, thank you.

// hardcode target partitions so plans are deterministic
.with_target_partitions(4);
.with_target_partitions(4)
.with_enable_ansi_mode(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just set it like so instead?

# Test disabling recursive CTE
statement ok
set datafusion.execution.enable_recursive_ctes = false;

Instead of doing it globally

eval_legacy_mode!(Float64, -0.0f64, 0.0f64);
}

macro_rules! eval_ansi_mode {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't help but feel a lot of this test code could be compacted in some way, as it seems quite verbose; haven't had time to properly check this however so don't really have a suggestion myself 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to make it more concise, thanks for the feedback!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jefffrey I combined the implementation of eval_ansi_mode and eval_legacy_mode into one eval_with_mode macro, please take a look when you have time, thanks!

@coderfender
Copy link

@hsiang-c , I would like to volunteer and contribute moving other ANSI functions from Comet back to Spark

self.options.execution.enforce_batch_size_in_joins
}

pub fn with_enable_ansi_mode(mut self, enable_ansi_mode: bool) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this function? If so it needs a docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need it eventually. I also refer to this config in datafusion/sqllogictest/test_files/spark/README.md‎ now.


macro_rules! eval_legacy_mode {
($TYPE:ident, $VAL:expr) => {{
macro_rules! eval_with_mode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to try move these tests to SLTs instead? Having so much macro code just for unit tests isn't ideal here 🤔

@Jefffrey Jefffrey added this pull request to the merge queue Jan 29, 2026
Merged via the queue into apache:main with commit 41bfb79 Jan 29, 2026
28 checks passed
@Jefffrey
Copy link
Contributor

Thanks @hsiang-c & @comphead

@hsiang-c hsiang-c deleted the spark_ansi_abs branch January 31, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execution Related to the execution crate functions Changes to functions implementation spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants