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

Unsupported cast when casting to a one field struct using the parenthesis syntax #16979

Closed
maingoh opened this issue May 28, 2024 · 1 comment
Labels
type/bug Something isn't working
Milestone

Comments

@maingoh
Copy link

maingoh commented May 28, 2024

Describe the bug

The following raise an error

SELECT (foo.my_id)::struct<id string> as foo FROM ...

However using the row() function it works:

SELECT row(foo.my_id)::struct<id string> as foo FROM ...

Error message/log

Unsupported function: cast(character varying) -> struct<id character varying>;


### To Reproduce

_No response_

### Expected behavior

The `()` syntax for creating struct should work with one field. When I add a second one it works. I currently explicitely use `row()` as a workaround.

### How did you deploy RisingWave?

K8s operator

### The version of RisingWave

v1.8.2

### Additional context

_No response_
@maingoh maingoh added the type/bug Something isn't working label May 28, 2024
@github-actions github-actions bot added this to the release-1.10 milestone May 28, 2024
@xiangjinwu
Copy link
Contributor

The ROW keyword is actually optional as long as you have more than one field in the expression

https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-CONSTRUCTING

This is actually PostgreSQL behavior, which is essential to differentiate it from parentheses used for precedence: (int_x + int_y) * int_z.

If you know Python, it is also the case that (int_x) is an integer while (int_x,) with an awkward trailing comma is a tuple containing an integer field. The trailing comma syntax is not adopted by PostgreSQL, so does RisingWave.

@xiangjinwu xiangjinwu closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants