Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: CAST failures for float value #40282

Closed
bpintea opened this issue Mar 20, 2019 · 2 comments
Closed

SQL: CAST failures for float value #40282

bpintea opened this issue Mar 20, 2019 · 2 comments

Comments

@bpintea
Copy link
Contributor

bpintea commented Mar 20, 2019

The following CASTs of a float value lead to failures:

  • SCALED_FLOAT:
sql> select cast('0.' as SCALED_FLOAT);
Bad request [line 1:22: Does not recognize type [SCALED_FLOAT]]
  • same for HALF_FLOAT;
  • any integer type:
sql> select cast('0.0' as long);
Server error [Server encountered an error [cannot cast [0.0] to [long]]. [SqlIllegalArgumentException[cannot cast [0.0] to [long]]; nested: NumberFormatException[For input string: "0.0"];
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@costin
Copy link
Member

costin commented Mar 21, 2019

There are two issues here:

  1. Indeed CAST accepts some ES data types but not all and that's inconsistent, I've got a fix for this already.
  2. There are two issues here:

2a. one that the underlying exception gets propagated without being checked (this is a bug)
2b. not sure whether '0.0' to long should succeed or not since 0.0 is not an int. Basically the command implies two conversions - 0.0 (string to float) and then float to int. Checking quickly indicates that postgres does not support this and I propose we do the same.

Thoughts @astefan @matriv ?

costin added a commit to costin/elasticsearch that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix elastic#40282
costin added a commit to costin/elasticsearch that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix elastic#40282
costin added a commit to costin/elasticsearch that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix elastic#40282
costin added a commit that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix #40282
costin added a commit that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix #40282

(cherry picked from commit eb2ee8a)
costin added a commit that referenced this issue Mar 22, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix #40282

(cherry picked from commit eb2ee8a)
@costin costin closed this as completed in d101955 Mar 22, 2019
pgomulka pushed a commit to pgomulka/elasticsearch that referenced this issue Mar 25, 2019
Extend CAST to support all data types notations (whether SQL or ES
specific)

Fix elastic#40282

(cherry picked from commit eb2ee8a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants