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

Cubestore can't use round function because of type coercion error. Support 2 argument ROUND(num, precision). #6179

Open
MrSpider opened this issue Feb 20, 2023 · 4 comments
Labels
enhancement New feature proposal help wanted Community contributions are welcome.

Comments

@MrSpider
Copy link

Describe the bug

mysql> SELECT ROUND(1, 2);
ERROR 1815 (HY000): Error during planning: Coercion from [Int64, Int64] to the signature Uniform(1, [Float64, Float32]) failed.

To Reproduce

  1. Start cubestore
  2. Execute query SELECT ROUND(1, 2);

Expected behavior
Cubestore can use round function without errors.

Version:
Latest version (0.31.62)

Additional context
I tried to cast the arguments to a variety of different types, but the error message is always the same. I was not able to cast the input types to Float32 because float, real and double all result in Float64 when used.

Above is the minimal reproduction of the error we encountered, but our use case is to round the calculation of two different measurements inside a rollup join.

@paveltiunov paveltiunov added the question The issue is a question. Please use Stack Overflow for questions. label Feb 20, 2023
@paveltiunov
Copy link
Member

@MrSpider ROUND function in Cube Store receives only one argument and always rounds to integer. For example ROUND(1.2).

@MrSpider
Copy link
Author

Thanks for the information. It seems arrow datafusion added that functionality some time ago, but cubestore still uses an older version of the datafusion library, so hopefully sometime in the future it will be usable with two arguments.

@ranjeetranjan
Copy link

ranjeetranjan commented Oct 23, 2023

Getting Round
Option-1

`ROUND((${CUBE.spend}) / CAST(${CUBE.clicks} AS FLOAT64), 2)

    cpc: {
      sql: `ROUND((${CUBE.spend}) / CAST(${CUBE.clicks} AS FLOAT64), 2)`,
      type: `number`,
      title: `CPC`
    }, 
```
**Error**

`Internal: This feature is not implemented: Unsupported SQL type Custom(ObjectName([Ident { value: "FLOAT64", quote_style: None }]))`

**Option-2**

`ROUND((${CUBE.spend}) / CAST(${CUBE.clicks} AS FLOAT), 2)
`
**Error**
`Internal: Error during planning: Coercion from [Float64, Int64] to the signature Uniform(1, [Float64, Float32]) failed. `

@paveltiunov paveltiunov added enhancement New feature proposal help wanted Community contributions are welcome. and removed question The issue is a question. Please use Stack Overflow for questions. labels Oct 24, 2023
@github-actions
Copy link

If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you.
If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines.
You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.

@paveltiunov paveltiunov changed the title Cubestore can't use round function because of type coercion error. Cubestore can't use round function because of type coercion error. Support 2 argument ROUND(num, precision). Oct 24, 2023
@paveltiunov paveltiunov reopened this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature proposal help wanted Community contributions are welcome.
Projects
None yet
Development

No branches or pull requests

3 participants