cursor.description's type_code is always None, even though col_types is already available internally
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
調査の方向性
Read src/crate/client/cursor.py's Cursor.description property and the type definitions and _resolve() helper in src/crate/client/converter.py. Check how col_types is populated and how existing cursor tests cover description; add coverage for the type_code value when column types are available. Done means the public description exposes each column's type code without requiring a configured Converter.
索引モデルが issue の本文から書いたものです。
説明
Summary
`Cursor.description` (PEP 249) always returns `None` for every field after the column name, including `type_code`:
https://github.com/crate/crate-python/blob/main/src/crate/client/cursor.py
```python
@property
def description(self):
if self._closed:
return None
description = []
for col in self._result["cols"]:
description.append((col, None, None, None, None, None, None))
return tuple(description)
```
This isn't because the driver doesn't have the type information. `self._result["col_types"]` is already populated from the same HTTP response (CrateDB's HTTP SQL interface column types) and is already used internally, e.g. in `Cursor._convert_rows()`:
```python
def _convert_rows(self):
if not ("col_types" in self._result and self._result["col_types"]):
raise ValueError(...)
types = self.result["col_types"]
converters = [self.converter.get(type) for type in types]
...
```
and `converter.py` already has a complete, documented mapping from these wire type codes to a `DataType` enum (`TIMESTAMP_WITH_TZ = 11`, `TIMESTAMP_WITHOUT_TZ = 15`, etc.) — so the information isn't missing, it's just not propagated into the public `description` property.
Why this matters
`type_code` is part of the standard DB-API 2.0 `description` contract (PEP 249). A consumer that only has a `Cursor` object (e.g. a driver-agnostic tool built against SQLAlchemy's cursor/dialect layer, or any generic DB-API client) has no supported way to find out a column's CrateDB type without either enabling a `Converter` (which changes value representation, not just exposing the type) or reaching into the private `cursor._result["col_types"]` attribute directly, which isn't part of the public API and could change without notice.
We actually hit this downstream in Apache Superset: `CrateEngineSpec.fetch_data()` has to read `cursor._result.get("col_types", [])` directly to tell timestamp columns apart from plain numeric ones, specifically because `cursor.description`'s `type_code` is always `None`:
https://github.com/apache/superset/blob/master/superset/db_engine_specs/crate.py#L98-L123
Suggested fix
In `Cursor.description`, populate the `type_code` slot (index 1 of the 7-tuple) from `self._result["col_types"]` (resolved through the existing `DataType` enum / `_resolve()` helper in `converter.py`) instead of hardcoding `None`, when `col_types` is available. This would bring `description` in line with the PEP 249 contract without needing a `Converter` to be configured, and let consumers stop reaching into `cursor._result` directly.
Environment
- crate-python: current `main` (same code present going back through recent tags)
- Verified by reading `src/crate/client/cursor.py` and `src/crate/client/converter.py` directly, cross-checked against the CrateDB HTTP SQL docs' column-types table.
- 主要言語
- Python
- スター
- 85
- フォーク
- 35
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crate/crate-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
crate/crate-python#794 · コメント 2 件 ·
-
Allow `connect()` (again) while the server is not responding対応中かも @florinutz が 19 日前に担当しました。 オープンenhancement
crate/crate-python#833 · 担当者 1 名 ·
-
NUMERIC reads: full digits arrive, the decode drops them対応中かも @aminghadersohi が 12 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
crate/crate-python#826 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
crate/crate-python#751 · コメント 7 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
crate/crate-python#729 · コメント 1 件 ·
crate/crate-python の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
pytest-dev/pluggy#757 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
NousResearch/hermes-agent#134960 ·
メンテナーはふだん 1 日以内に返信
-
HTML backend: `<br>` leaks the internal sentinel U+E000 into list items, headings and captions対応中かも @morten-lagabote が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
docling-project/docling#4671 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
good first issue hacktoberfest infra
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信