Arithmetic on a SYMBOL column uses its dictionary key instead of its value

Aperta
#8,306 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, sql
Ambito
databases

Direzione di ricerca

Start by tracing how QuestDB evaluates arithmetic expressions on SYMBOL columns, then compare that path with the value conversion used by sy::INT. Reproduce with the SQL in the issue and inspect nearby tests for SYMBOL arithmetic. Done when arithmetic uses the symbol value or rejects the operation with an error, including the listed cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug SQL

Arithmetic on a SYMBOL column, such as sy + 0, computes with the symbol's dictionary key rather than its value, so it returns numbers unrelated to the data. A cast, sy::INT, converts the value as expected. No error is raised.

Repro
CREATE TABLE x (sy SYMBOL, id INT, k TIMESTAMP) TIMESTAMP(k);
INSERT INTO x VALUES
    ('1', 1, 0), ('2', 2, 1), ('3', 3, 2), ('-1', 4, 3),
    ('5000000001', 5, 4), (null, 6, 5), ('1', 7, 6);
SELECT sy, sy + 0 AS plus0, sy * 1 AS times1, sy::INT AS asint FROM x;
sy sy + 0 sy * 1 sy::INT
1 0 0 1
2 1 1 2
3 2 2 3
-1 3 3 -1
5000000001 4 4 null
null null null null
1 0 0 1

SELECT 'a'::SYMBOL + 0 returns 0. A filter such as WHERE 1 + 1 = sy + 0 therefore matches the row holding '3'.

Either cast the value, as sy::INT does, or reject arithmetic on SYMBOL with an error.

Lingua principale
Java
Stelle
17.5k
Fork
1.7k
Merge medio
5g 11h
PR unite (30g)
64

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di questdb/questdb

Tutte le issue di questdb/questdb

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.