Commit Graph

19 Commits

Author SHA1 Message Date
Claude Code
b3604af4ce fix(postgres): address review feedback on INTERVAL normalization
Applies the three suggestions from #34513 review:

1. Drop the dead `isinstance(v, (int, float))` branch. psycopg2 and
   psycopg3 always hand INTERVAL columns back as datetime.timedelta;
   the numeric branch was unreachable in practice and was creating
   false confidence in the tests covering it.
2. Move `_normalize_interval` from a `@staticmethod` on the class to a
   module-level function. The previous form required
   `INTERVAL: _normalize_interval.__func__  # type: ignore[attr-defined]`
   to extract the underlying function from the staticmethod descriptor
   inside the class body. Module-level lets `column_type_mutators`
   reference the function directly — no `__func__`, no suppress.
3. Add a `logger.warning(...)` to the defensive return-None path so a
   future driver surfacing something other than timedelta gets logged
   rather than silently dropped.

Test updates: the numeric/bool assertions that exercised the removed
branch now exercise the defensive return-None path instead (same
expectations, but for the right reason).
2026-05-20 15:59:03 -07:00
Evan Rusackas
0a2b837c89 fix: address review feedback for INTERVAL type handling
- Extract lambda to named `_normalize_interval` method for testability
- Return None for NULL values to preserve NULL semantics (not 0)
- Exclude bool from numeric branch (bool is subclass of int in Python)
- Return None for unconvertible types to avoid mixed-type columns
- Add tests for zero duration, negative intervals, and bool handling
- Add INTERVAL to column spec test (NUMERIC type)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-22 08:53:15 -07:00
Evan Rusackas
d3c562657a feat(postgres): convert INTERVAL to milliseconds for DURATION formatter
Changed INTERVAL values to be converted to milliseconds instead of
seconds, enabling users to use Superset's built-in "DURATION" number
format for human-readable display (e.g., "1d 2h 30m 45s" instead of
raw numeric values like "95445000").

This addresses the review feedback about making interval values more
user-friendly in charts while maintaining numeric operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-22 08:53:14 -07:00
Evan Rusackas
be90e08f83 feat(postgres): improve INTERVAL type handling for robust chart rendering
- Enhanced mutator to handle multiple PostgreSQL INTERVAL formats
- Added support for timedelta, numeric, None, and string values
- Improved test coverage with comprehensive test cases
- Added documentation explaining the mutator's purpose

Addresses review comments from @korbit-ai and @giftig
2026-04-22 08:53:14 -07:00
Evan Rusackas
4e74dc0250 fix(charts): handle PostgreSQL INTERVAL type in bar and pie charts
PostgreSQL INTERVAL types were causing bar and pie charts to fail rendering when used as metrics. This fix converts INTERVAL values (timedelta objects) to numeric seconds so they can be properly displayed in charts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-22 08:53:09 -07:00
Beto Dealmeida
5d9f53ff0c feat: prevent Postgres connection to Redshift (#38693) 2026-03-24 10:44:38 -04:00
Elizabeth Thompson
e9b494163b refactor(db): use Dialect instead of Engine in select_star to avoid SSH tunnels (#35540)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-02 10:26:35 -08:00
Beto Dealmeida
21d8d57380 fix: select star (#33763) 2025-06-13 14:59:52 -04:00
Maxime Beauchemin
e51b95ffa8 chore: enforce more ruff rules (#31447)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
2024-12-18 17:41:34 -08:00
Sam Firke
ac66ae813f fix(db_engine_specs): add a few missing time grains to Postgres spec (#30325) 2024-09-20 13:34:10 -04:00
Patrick Schmidt
6294e339e2 feat(db_engine): Implement user impersonation support for StarRocks (#28110) 2024-09-06 09:13:38 -07:00
Beto Dealmeida
8e15d4807f chore: s/MockFixture/MockerFixture/g (#29160) 2024-06-10 12:35:07 -04:00
Beto Dealmeida
e90246fd1f feat(SIP-95): permissions for catalogs (#28317) 2024-05-06 11:41:58 -04:00
Maxime Beauchemin
2d63722150 chore: set up ruff as a new linter/formatter (#28158) 2024-04-24 17:19:53 -07:00
Beto Dealmeida
7675e0db10 fix: search_path in RDS (#24739) 2023-07-20 12:57:48 -07:00
John Bodley
a4d5d7c6b9 chore(pre-commit): Add pyupgrade and pycln hooks (#24197) 2023-06-01 12:01:10 -07:00
Beto Dealmeida
2c6f581fa6 feat(postgresql): dynamic schema (#23401) 2023-03-17 17:53:42 -07:00
Beto Dealmeida
42e8d1b498 chore: improve schema security (#23385) 2023-03-17 08:05:50 -07:00
Ville Brofeldt
cd6fc35f60 chore(db_engine_specs): clean up column spec logic and add tests (#22871) 2023-01-31 15:54:07 +02:00