Oracle: sum() of floats whose total is whole gives an int, 2 where Neo4j gives 2.0
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #197 @jasperblues による — マージ済み
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Start with drivine/cypher/sql/sql_cypher_compiler.py:4452-4453 and the Oracle compiler in drivine/cypher/sql/oracle_cypher_compiler.py; compare how sum is compiled with the unmerged drivine4j fix described in the issue. Port the two named tests from CypherQueryCrossEngineTest and CompiledSizeTest, then check the upcoming “Aggregates of floats” spec case in queries.yaml. Done when Oracle preserves float results for sums containing fractional values while integer sums, including empty sums, remain integers.
索引モデルが issue の本文から書いたものです。
説明
Port of liberation-data/drivine4j#304.
On Oracle, UNWIND [0.5, 1.0, 0.5] AS x RETURN sum(x) gives 2, an int, where Neo4j, Postgres and SQLite give 2.0, a float. Oracle's NUMBER keeps no kind, so a sum of floats whose total is whole comes back as an integer. The same goes for sum over [1, 1.0], [1, 0.5, 0.5], sum(DISTINCT x) over [1.0, 1.0], a parameter list such as $xs = [0.5, 0.5], a stored float, and what is worked out from such a sum (toString(sum(x)) gives "2", sum(x) + 1 gives 3).
Here, sum compiles to COALESCE(sum(<number>), 0) on every store, in drivine/cypher/sql/sql_cypher_compiler.py:4452-4453, and the Oracle compiler (drivine/cypher/sql/oracle_cypher_compiler.py) doesn't override it.
The fix in drivine4j, not merged yet, makes sum a hook on the base compiler, which Oracle overrides:
CASE WHEN MAX(JSON_VALUE(x, '$?(@.type() == "double" || (@.type() == "number" && @.string() has substring "."))')) IS NOT NULL
THEN JSON_SCALAR(TO_BINARY_DOUBLE(sum(JSON_VALUE(x, '$?(@.type() != "string")' RETURNING NUMBER))))
ELSE JSON_SCALAR(COALESCE(sum(JSON_VALUE(x, '$?(@.type() != "string")' RETURNING NUMBER)), 0)) END
That gives a float where any value summed is a double or a number with a fraction, and an integer otherwise (0 over no rows). Each read is a single JSON path that tests the kind itself, because nothing is bound under an aggregate. So the statement reads each value three times, as number() does now, and doesn't grow under nested functions. Oracle's JSON path can't compare @ to @.floor() (ORA-40597), which is why the fraction test checks the number's text for a point.
avg, min and max already keep a float a float on Oracle. percentileDisc, percentileCont, stDev and stDevP aren't compiled to SQL.
Tests to port: drivine4j's an aggregate of floats gives a float, whole or not, and a sum of integers an integer in CypherQueryCrossEngineTest, and a sum reads each value it sums as often as an avg does, and grows under functions as an avg does in CompiledSizeTest. The spec case "Aggregates of floats" is coming to drivine-cypher-spec's queries.yaml.
- 主要言語
- Python
- スター
- 1
- フォーク
- 0
- 平均マージ
- 1時間 19分
- マージ済み PR(30日)
- 122
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
liberation-data/drivine-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
liberation-data/drivine-python#252 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
liberation-data/drivine-python#250 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
liberation-data/drivine-python#209 ·
メンテナーはふだん 1 日以内に返信
-
CI: three Oracle-only tests in test_cypher_compiled.py never run, as -k oracle doesn't select themオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
liberation-data/drivine-python#178 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
liberation-data/drivine-python#243 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
liberation-data/drivine-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
btclib-org/btclib-ecc#404 ·
-
changelog investigate
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
ramnes/notion-sdk-py#430 ·
-
bug good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
hyeonjoong/debussy#56 ·
-
README устарел: статус проекта, версия 0.1.0 при описании тега v0.1.1, семантика фолбэка поискаオープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Lagrunge82/yandex-mail-mcp#43 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
noontide-co/mainbranch#1256 · コメント 1 件 ·