Skip to content

Types: Improve type mappings #24

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Types: Improve type mappings #24

wants to merge 1 commit into from

Conversation

amotl
Copy link
Member

@amotl amotl commented Jan 16, 2024

About

  • Consequently use upper-case type definitions from sqlalchemy.types
  • Add timestamp without time zone types (scalar and array)
  • On SQLAlchemy 2, map real and double{_precision} types to the
    newly introduced sqltypes.{DOUBLE,DOUBLE_PRECISION} types

All of this is intended to improve reverse type lookups / reflections.

References

Backlog

  • Software tests.
  • Just a short note(s) about type support within the documentation.

@amotl amotl force-pushed the amo/more-typemapping branch from 9324bf1 to 120f8ea Compare January 16, 2024 01:02
@amotl amotl changed the title Types: Improve type mapping for scalars and arrays Types: Improve type mappings Jan 16, 2024
@amotl amotl force-pushed the amo/more-typemapping branch 3 times, most recently from daa7029 to fea2527 Compare January 16, 2024 01:36
@amotl amotl force-pushed the amo/more-typemapping branch 2 times, most recently from 4732e07 to a63ce6e Compare June 25, 2024 14:54
@amotl amotl force-pushed the amo/more-typemapping branch 2 times, most recently from c3efc82 to e6837c0 Compare March 30, 2025 02:24
- Consequently use upper-case type definitions from `sqlalchemy.types`
- Add `timestamp without time zone` types (scalar and array)
- On SQLAlchemy 2, map `real` and `double{_precision}` types to the
  newly introduced `sqltypes.{DOUBLE,DOUBLE_PRECISION}` types

All of this is intended to improve reverse type lookups / reflections.
@amotl amotl force-pushed the amo/more-typemapping branch from e6837c0 to 1a0e14b Compare April 11, 2025 19:32
@amotl
Copy link
Member Author

amotl commented Apr 11, 2025

Dear @CaselIT,

may we humbly ask you to give this patch a quick review? We started to overhaul the type mapping of the CrateDB dialect the other day, and would like to conclude this patch.

Other than filling some gaps, we found that mapping database types to the uppercase type symbol variants provided by SQLAlchemy and back (i.e. using sqltypes.VARCHAR rather than sqltypes.String), offers better (reverse) type mapping behaviour with downstream frameworks like pandas, Meltano, or previous versions of Ibis and friends. Do you also think it is the right choice to do it this way?

With kind regards,
Andreas.

@CaselIT
Copy link

CaselIT commented Apr 11, 2025

for reflected tables? it's fine, sqlalchemy types have as_generic so if users need to adapt the types to other db they can simply use that in the reflect event.

@amotl
Copy link
Member Author

amotl commented Apr 11, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants