apache / apache/druid

casting numbers, and combining with other sql operations doesn't seem to work right

Open
#11,065 1 comment 0 reactions 0 assignees View on GitHub
Area - SQL
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

Reproduced in druid 0.20.0

This will return an integer results, giving the floor of the result, which is expected:

select 5/2

(returns 2). Casting the numerator and/or denominator makes no difference. Eg,

select (cast (5 as decimal))/(cast (2 as decimal))

or any other variation I can think if, still returns 2. You can only get the decimal portion by doing something like

select 5.0/2

or a variation like

select (1.0*5)/2

Also,

cast(1.0 as integer)

will return 1, but something like

cast(1.0 as integer) || 'test'

will return 1.0test

or

select mod(cast('10' as integer), 3) || 'test'

returns 1test, but

select cast(mod('10',3) as integer) || 'test'

returns 1.0test

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Reproduce the listed arithmetic, CAST, MOD, and string-concatenation queries against Druid 0.20.0, then trace the SQL expression handling and existing regression tests. Done means the reported queries follow the expected numeric and concatenation behavior with tests covering them.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.