Skip to content

GH-22232: [C++][Python] Introduce optional default_column_type parameter - #47663

Merged
AlenkaF merged 16 commits into
apache:mainfrom
vladborovtsov:default-column-type
May 13, 2026
Merged

GH-22232: [C++][Python] Introduce optional default_column_type parameter#47663
AlenkaF merged 16 commits into
apache:mainfrom
vladborovtsov:default-column-type

Conversation

@vladborovtsov

@vladborovtsovvladborovtsov commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Rationale for this change

Add an optional default_column_type parameter to the CSV reading API (C++ and Python) to provide a fallback type when per-column types aren’t specified, improving schema consistency and complementing the existing column_types logic.

What changes are included in this PR?

Are these changes tested?

Yes. Existing and new tests are passing.

C++:

> [==========] Running 3 tests from 1 test suite.
> [----------] Global test environment set-up.
> [----------] 3 tests from ReaderTests
> [ RUN ] ReaderTests.DefaultColumnTypePartialDefault
> [ OK ] ReaderTests.DefaultColumnTypePartialDefault (3 ms)
> [ RUN ] ReaderTests.DefaultColumnTypeAllStringsWithHeader
> [ OK ] ReaderTests.DefaultColumnTypeAllStringsWithHeader (0 ms)
> [ RUN ] ReaderTests.DefaultColumnTypeAllStringsNoHeader
> [ OK ] ReaderTests.DefaultColumnTypeAllStringsNoHeader (0 ms)
> [----------] 3 tests from ReaderTests (4 ms total)
> > [----------] Global test environment tear-down
> [==========] 3 tests from 1 test suite ran. (4 ms total)
> [ PASSED ] 3 tests.
All:
> [==========] 264 tests from 46 test suites ran. (452 ms total)
> [ PASSED ] 264 tests.

pyarrow:
New tests are passing.

Are there any user-facing changes?

I believe this change is backward compatible. Parameter is optional and its default value doesn't change the existing behavior; All the existing rests are passing.

Maybe relevant: #22232

Relates to #47502

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

4 similar comments
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@vladborovtsov

Copy link
Copy Markdown
ContributorAuthor

@github-actions crossbow submit preview-docs

@github-actions

Copy link
Copy Markdown
Only contributors can submit requests to this bot. Please ask someone from the community for help with getting the first commit in.
The Archery job run can be found at: https://github.com/apache/arrow/actions/runs/18062577036

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@vladborovtsov
vladborovtsov marked this pull request as ready for review September 27, 2025 19:26
@koukou changed the title GH-47502: Introduce optional default_column_type parameterGH-47502: [C++] Introduce optional default_column_type parameterOct 13, 2025
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47502has been automatically assigned in GitHub to PR creator.

@AlenkaF

Copy link
Copy Markdown
Member

Thank you @vladborovtsov for the contribution.
I will add info about the proposed solution in the original issue (#22232) so I can see opinions from C++ devs on the proposed solution.

@AlenkaFAlenkaF changed the title GH-47502: [C++] Introduce optional default_column_type parameterGH-22232: [C++][Python] Introduce optional default_column_type parameterOct 24, 2025
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #22232has been automatically assigned in GitHub to PR creator.

@vladborovtsov

Copy link
Copy Markdown
ContributorAuthor

Hi @AlenkaF
I'm happy to continue the labour and discussion to get that merged.
As for AI, it wasn't used much, although I tried :) With such huge codebase the generation quality is quite low.

@AlenkaF

Copy link
Copy Markdown
Member

Happy to see a response!
All good, it is totally OK to use gen AI wisely ;)

I will wait for an opinion from a C++ dev and in the meantime try to look at the Python part.

@vladborovtsov

Copy link
Copy Markdown
ContributorAuthor

Hi @AlenkaF
Any feedback?

@AlenkaFAlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Python part looks good to me. I only added a comment for the docstring examples.

@rok@raulcd do you have any opinions on the C++ approach to handle this use case?

Comment threadpython/pyarrow/_csv.pyx Outdated
@github-actionsgithub-actionsBot removed the awaiting review Awaiting review label Dec 12, 2025
@vladborovtsov

Copy link
Copy Markdown
ContributorAuthor

Hi @AlenkaF
I believe now it should be fine?
I'm running tests locally in docker using pytest -v --pyargs pyarrow.tests.test_csv.
Am I missing something?

@AlenkaFAlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, everything looking good. I will just run the extended builds before merging. Thanks!

@AlenkaF

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g python

@github-actions

Copy link
Copy Markdown

Revision: c1ad5f6

Submitted crossbow builds: ursacomputing/crossbow @ actions-9de857b990

TaskStatus
example-python-minimal-build-fedora-condaGitHub Actions
example-python-minimal-build-ubuntu-venvGitHub Actions
test-conda-python-3.10GitHub Actions
test-conda-python-3.10-hdfs-2.9.2GitHub Actions
test-conda-python-3.10-hdfs-3.2.1GitHub Actions
test-conda-python-3.10-pandas-1.3.4-numpy-1.21.2GitHub Actions
test-conda-python-3.11GitHub Actions
test-conda-python-3.11-dask-latestGitHub Actions
test-conda-python-3.11-dask-upstream_develGitHub Actions
test-conda-python-3.11-hypothesisGitHub Actions
test-conda-python-3.11-pandas-latest-numpy-latestGitHub Actions
test-conda-python-3.11-spark-masterGitHub Actions
test-conda-python-3.12GitHub Actions
test-conda-python-3.12-cpython-debugGitHub Actions
test-conda-python-3.12-pandas-latest-numpy-1.26GitHub Actions
test-conda-python-3.12-pandas-latest-numpy-latestGitHub Actions
test-conda-python-3.13GitHub Actions
test-conda-python-3.13-pandas-nightly-numpy-nightlyGitHub Actions
test-conda-python-3.13-pandas-upstream_devel-numpy-nightlyGitHub Actions
test-conda-python-3.14GitHub Actions
test-conda-python-emscriptenGitHub Actions
test-debian-13-python-3-amd64GitHub Actions
test-debian-13-python-3-i386GitHub Actions
test-fedora-42-python-3GitHub Actions
test-ubuntu-22.04-python-3GitHub Actions
test-ubuntu-22.04-python-313-freethreadingGitHub Actions
test-ubuntu-24.04-python-3GitHub Actions

@AlenkaF

Copy link
Copy Markdown
Member

The failing emscripten build is not related. Will merge.
Thanks!

@AlenkaF
AlenkaF merged commit 3d6e138 into apache:mainMay 13, 2026
58 checks passed
@AlenkaFAlenkaF removed the awaiting change review Awaiting change review label May 13, 2026
@vladborovtsov
vladborovtsov deleted the default-column-type branch May 13, 2026 15:01
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 1 benchmarking run that has been run so far on merge-commit 3d6e138.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 1 benchmarking run that has been run so far on merge-commit 3d6e138.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 1 benchmarking run that has been run so far on merge-commit 3d6e138.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 2 benchmarking runs that have been run so far on merge-commit 3d6e138.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Mottl pushed a commit to Mottl/arrow that referenced this pull request May 26, 2026
…parameter (apache#47663)
### Rationale for this change
Add an optional default_column_type parameter to the CSV reading API (C++ and Python) to provide a fallback type when per-column types aren’t specified, improving schema consistency and complementing the existing column_types logic.
### What changes are included in this PR?
- c++: new convert option "default_column_type" to augment logic around column_types parameter
- 3 reader tests: DefaultColumnTypePartialDefault, DefaultColumnTypeAllStringsWithHeader, DefaultColumnTypeAllStringsNoHeader). The last two tests are inspired by pandas-dev/pandas#62242 and pandas-dev/pandas#57666
- python: corresponding changes to make cpp change consumable from python
- python: extended test_convert_options test - include. default_column_type
- python: added new test "test_default_column_type" which tests how the field impacts schema; also test implicitly verifies leading zero preservation - relevant documentation update for python component;
### Are these changes tested?
Yes. Existing and new tests are passing.
C++: > [==========] Running 3 tests from 1 test suite.
> [----------] Global test environment set-up.
> [----------] 3 tests from ReaderTests
> [ RUN ] ReaderTests.DefaultColumnTypePartialDefault
> [ OK ] ReaderTests.DefaultColumnTypePartialDefault (3 ms)
> [ RUN ] ReaderTests.DefaultColumnTypeAllStringsWithHeader
> [ OK ] ReaderTests.DefaultColumnTypeAllStringsWithHeader (0 ms)
> [ RUN ] ReaderTests.DefaultColumnTypeAllStringsNoHeader
> [ OK ] ReaderTests.DefaultColumnTypeAllStringsNoHeader (0 ms)
> [----------] 3 tests from ReaderTests (4 ms total)
> > [----------] Global test environment tear-down
> [==========] 3 tests from 1 test suite ran. (4 ms total)
> [ PASSED ] 3 tests.
All:
> [==========] 264 tests from 46 test suites ran. (452 ms total)
> [ PASSED ] 264 tests.
pyarrow:
New tests are passing. ### Are there any user-facing changes?
I believe this change is backward compatible. Parameter is optional and its default value doesn't change the existing behavior; All the existing rests are passing. Maybe relevant: apache#22232
Relates to apache#47502
* GitHub Issue: apache#47502
* GitHub Issue: apache#22232
Lead-authored-by: Vlad Borovtsov <borovcov.vlad@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
Sign up for freeto 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.

5 participants

@vladborovtsov@AlenkaF@rok@raulcd@pitrou