Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions data_diff/databases/database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:

The returned expression must accept any SQL datetime/timestamp, and return a string.

Date format: "YYYY-MM-DD HH:mm:SS.FFFFFF"
Date format: ``YYYY-MM-DD HH:mm:SS.FFFFFF``

Precision of dates should be rounded up/down according to coltype.rounds
"""
Expand All @@ -123,18 +123,18 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:

The returned expression must accept any SQL int/numeric/float, and return a string.

- Floats/Decimals are expected in the format
"I.P"
Floats/Decimals are expected in the format
"I.P"

Where I is the integer part of the number (as many digits as necessary),
and must be at least one digit (0).
P is the fractional digits, the amount of which is specified with
coltype.precision. Trailing zeroes may be necessary.
If P is 0, the dot is omitted.
Where I is the integer part of the number (as many digits as necessary),
and must be at least one digit (0).
P is the fractional digits, the amount of which is specified with
coltype.precision. Trailing zeroes may be necessary.
If P is 0, the dot is omitted.

Note: This precision is different than the one used by databases. For decimals,
it's the same as ``numeric_scale``, and for floats, who use binary precision,
it can be calculated as ``log10(2**numeric_precision)``.
Note: We use 'precision' differently than most databases. For decimals,
it's the same as ``numeric_scale``, and for floats, who use binary precision,
it can be calculated as ``log10(2**numeric_precision)``.
"""
...

Expand All @@ -145,9 +145,11 @@ def normalize_value_by_type(self, value: str, coltype: ColType) -> str:

The default implementation dispatches to a method according to `coltype`:

TemporalType -> normalize_timestamp()
::

TemporalType -> normalize_timestamp()
FractionalType -> normalize_number()
*else* -> to_string()
*else* -> to_string()

(`Integer` falls in the *else* category)

Expand Down
2 changes: 1 addition & 1 deletion docs/python-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Python API Reference
.. autoclass:: TableSegment
:members: __init__, get_values, choose_checkpoints, segment_by_checkpoints, count, count_and_checksum, is_bounded, new

.. autoclass:: data_diff.database.Database
.. autoclass:: data_diff.databases.database_types.AbstractDatabase
:members:

.. autodata:: DbKey
Expand Down