Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Cypher on SQL stores: floats near the bottom of a double's range become 0.0 or null

Ouverte
#118 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

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
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
postgresql, python
Domaine
backend, databases

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 with TO_BINARY_DOUBLE, but reads it first through number (:135-138), which is JSON_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 becomes None before the double operation runs.
  • Oracle, sqrt, round and avg: the same NUMBER read, at call sites #117 doesn't name. avg (drivine/cypher/sql/sql_cypher_compiler.py:3236-3237), round (:3301-3312) and sqrt (:3313-3314) each read their argument through self.number, and only the result is turned back into a double, by float_ (drivine/cypher/sql/oracle_cypher_compiler.py:158-159). A fix to arithmetic alone leaves these; a fix to number (or a BINARY_DOUBLE read where the value is a double) covers all of them.
  • Postgres, avg: avg (drivine/cypher/sql/sql_cypher_compiler.py:3237) averages number's numeric (drivine/cypher/sql/postgres_cypher_compiler.py:79-82), and numeric's division keeps too few digits for 5e-324 / 3, so the average is 0 before float_ (:93-96) casts it. #91's fix (float_ through double precision) doesn't reach this, as the value is already 0 in numeric.

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

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de liberation-data/drivine-python

Toutes les issues de liberation-data/drivine-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.