Skip to content

[SPARK-52701][PS] Fix float32 type widening in mod with bool under ANSI #51394

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

Closed
wants to merge 3 commits into from

Conversation

xinrong-meng
Copy link
Member

@xinrong-meng xinrong-meng commented Jul 7, 2025

What changes were proposed in this pull request?

Fix float32 type widening in mod with bool under ANSI.

Why are the changes needed?

Ensure pandas on Spark works well with ANSI mode on.
Part of https://issues.apache.org/jira/browse/SPARK-52700.

Does this PR introduce any user-facing change?

Yes. mod under ANSI works as pandas.

(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=False  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 8 seconds


(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=True  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 7 seconds

How was this patch tested?

Unit tests.

Was this patch authored or co-authored using generative AI tooling?

No.

@xinrong-meng
Copy link
Member Author

@ueshin would you please review? Thanks!

@xinrong-meng
Copy link
Member Author

Merged to master thanks!

asl3 pushed a commit to asl3/spark that referenced this pull request Jul 14, 2025
…ANSI

### What changes were proposed in this pull request?
Fix float32 type widening in `mod` with bool under ANSI.

### Why are the changes needed?
Ensure pandas on Spark works well with ANSI mode on.
Part of https://issues.apache.org/jira/browse/SPARK-52700.

### Does this PR introduce _any_ user-facing change?
Yes. `mod` under ANSI works as pandas.
```py
(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=False  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 8 seconds

(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=True  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 7 seconds

```

### How was this patch tested?
Unit tests.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#51394 from xinrong-meng/mod_dtype.

Authored-by: Xinrong Meng <xinrong@apache.org>
Signed-off-by: Xinrong Meng <xinrong@apache.org>
ksbeyer pushed a commit to ksbeyer/spark that referenced this pull request Jul 14, 2025
…ANSI

### What changes were proposed in this pull request?
Fix float32 type widening in `mod` with bool under ANSI.

### Why are the changes needed?
Ensure pandas on Spark works well with ANSI mode on.
Part of https://issues.apache.org/jira/browse/SPARK-52700.

### Does this PR introduce _any_ user-facing change?
Yes. `mod` under ANSI works as pandas.
```py
(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=False  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 8 seconds

(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=True  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 7 seconds

```

### How was this patch tested?
Unit tests.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#51394 from xinrong-meng/mod_dtype.

Authored-by: Xinrong Meng <xinrong@apache.org>
Signed-off-by: Xinrong Meng <xinrong@apache.org>
haoyangeng-db pushed a commit to haoyangeng-db/apache-spark that referenced this pull request Jul 22, 2025
…ANSI

### What changes were proposed in this pull request?
Fix float32 type widening in `mod` with bool under ANSI.

### Why are the changes needed?
Ensure pandas on Spark works well with ANSI mode on.
Part of https://issues.apache.org/jira/browse/SPARK-52700.

### Does this PR introduce _any_ user-facing change?
Yes. `mod` under ANSI works as pandas.
```py
(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=False  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 8 seconds

(dev3.11) spark (mod_dtype) % SPARK_ANSI_SQL_MODE=True  ./python/run-tests --python-executables=python3.11 --testnames "pyspark.pandas.tests.data_type_ops.test_num_mod NumModTests.test_mod"
...
Tests passed in 7 seconds

```

### How was this patch tested?
Unit tests.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#51394 from xinrong-meng/mod_dtype.

Authored-by: Xinrong Meng <xinrong@apache.org>
Signed-off-by: Xinrong Meng <xinrong@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants