Cypher on SQL stores: floats near the bottom of a double's range become 0.0 or null
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1
- Forks
- 0
- Merge moyen
- 1 h 21 min
- PR mergées (30 j)
- 128
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de liberation-data/drivine-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
liberation-data/drivine-python#250 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
liberation-data/drivine-python#209 ·
Les mainteneurs répondent en général sous 1 jour
-
CI: three Oracle-only tests in test_cypher_compiled.py never run, as -k oracle doesn't select themOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
liberation-data/drivine-python#178 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
liberation-data/drivine-python#280 ·
Les mainteneurs répondent en général sous 1 jour
-
Read a list item past 32 KB by its place on Oracle without crashing the session over two rowsOuvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
liberation-data/drivine-python#279 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de liberation-data/drivine-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
aws-samples/sample-per-model-bedrock#639 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
awslabs/visual-asset-management-system#937 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
project-codeflare/codeflare-sdk#1195 ·
Les mainteneurs répondent en général sous 1 jour
-
Bump numpy dependencyOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
pandas-dev/pandas-stubs#2051 ·
Les mainteneurs répondent en général sous 1 jour