Cypher on SQL stores: floats near the bottom of a double's range become 0.0 or null
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start with OracleCypherCompiler.number and float_ in drivine/cypher/sql/oracle_cypher_compiler.py, then trace the avg, round, and sqrt call sites in drivine/cypher/sql/sql_cypher_compiler.py; inspect Postgres's numeric and float_ handling for avg as well. Add integration coverage in tests/integration/test_cypher_compiled.py for the six listed statements on Postgres and Oracle, and confirm the results preserve the expected tiny double values.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Port of liberation-data/drivine4j#229.
What happens here: floats near the bottom of a double's range are lost on the SQL stores. On main (d4932f7), through the cypher_pm fixture with QuerySpecification(cypher_statement(...)):
| Statement | Neo4j | Postgres | Oracle |
|---|---|---|---|
RETURN 1e-300 / 1e300 |
[0.0] |
[0.0] |
[None] |
RETURN 5e-324 * 0.6 |
[5e-324] |
[5e-324] |
[0.0] |
RETURN 1e-310 / 3 |
[3.333333333333e-311] |
[3.333333333333e-311] |
[0.0] |
RETURN sqrt(1e-320) |
[9.99994433575849e-161] |
[1e-160] |
[0.0] |
RETURN round(1e-320, 400) |
[1e-320] |
[1e-320] |
[0.0] |
UNWIND [5e-324, 0.0, 0.0] AS x RETURN avg(x) |
[5e-324] |
[0.0] |
[0.0] |
So on Oracle all six lose the value, and on Postgres avg does. Postgres's sqrt(1e-320) giving 1e-160 rather than the double's 9.99994433575849e-161 is numeric's digits, which #91 already covers.
Where:
- Oracle, arithmetic: the same cause as #117 (drivine4j#226).
OracleCypherCompiler.arithmetic(drivine/cypher/sql/oracle_cypher_compiler.py:252-259) converts each side withTO_BINARY_DOUBLE, but reads it first throughnumber(:135-138), which isJSON_VALUE(x, '$' RETURNING NUMBER).NUMBER's least magnitude is about 1e-130 and its greatest about 1e126, so 1e-300, 1e-310 and 5e-324 become 0 and 1e300 becomesNonebefore the double operation runs. - Oracle,
sqrt,roundandavg: the sameNUMBERread, at call sites #117 doesn't name.avg(drivine/cypher/sql/sql_cypher_compiler.py:3236-3237),round(:3301-3312) andsqrt(:3313-3314) each read their argument throughself.number, and only the result is turned back into a double, byfloat_(drivine/cypher/sql/oracle_cypher_compiler.py:158-159). A fix toarithmeticalone leaves these; a fix tonumber(or aBINARY_DOUBLEread where the value is a double) covers all of them. - Postgres,
avg:avg(drivine/cypher/sql/sql_cypher_compiler.py:3237) averagesnumber'snumeric(drivine/cypher/sql/postgres_cypher_compiler.py:79-82), andnumeric's division keeps too few digits for 5e-324 / 3, so the average is 0 beforefloat_(:93-96) casts it. #91's fix (float_throughdouble precision) doesn't reach this, as the value is already 0 innumeric.
Expected: a double operation keeps double precision down to the subnormals, as Neo4j does: the Neo4j column above.
Tests to port: whatever drivine4j adds for #229. The six statements above make a direct test on Postgres and Oracle in tests/integration/test_cypher_compiled.py; SQLite isn't a store here yet.
Related: #117, #91.
- Lingua principale
- Python
- Stelle
- 1
- Fork
- 0
- Merge medio
- 1h 19m
- PR unite (30g)
- 122
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di liberation-data/drivine-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
liberation-data/drivine-python#252 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
liberation-data/drivine-python#250 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
liberation-data/drivine-python#209 ·
I maintainer di solito rispondono entro 1 giorno
-
CI: three Oracle-only tests in test_cypher_compiled.py never run, as -k oracle doesn't select themAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
liberation-data/drivine-python#178 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
liberation-data/drivine-python#243 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di liberation-data/drivine-python
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ClockGU/clockwork-backend#169 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws-samples/sample-per-model-bedrock#616 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
chnm/teachinghistory-hugo#47 ·
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
pandas-dev/pandas-stubs#2047 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno