risingwavelabs / risingwave

Best-in-class stream processing, analytics, and management. Perform continuous analytics, or build event-driven applications, real-time ETL pipelines, and feature stores in minutes. Unified streaming and batch. PostgreSQL compatible.
https://go.risingwave.com/slack
Apache License 2.0
7.03k stars 578 forks source link

UPDATE statements with string literal from of the same column fails #16894

Open joelind opened 5 months ago

joelind commented 5 months ago

Describe the bug

When issuing a pretty simple update against a table, we get a syntax error, but it should work.

Error message/log

ERROR:  Failed to run the query

Caused by:
  sql parser error: Expected =, found: version at line:1, column:23
Near "update foo set"

To Reproduce

create table foo as (select 'abc' as version);

update foo set version = 'def' where version = 'abc';

Expected behavior

I'd expect the correct row in the table to be updated

How did you deploy RisingWave?

Docker compose (locally)

The version of RisingWave


risingwave_development=> select version();
                                       version
-------------------------------------------------------------------------------------
 PostgreSQL 13.14.0-RisingWave-1.9.1-rc.1 (2f44407cfa3430d1d31ce9a0d0fcb31547408d8b)
(1 row)

Additional context

No response

neverchanje commented 5 months ago

Thanks for your feedback!

create table foo as (select 'abc' as "version");

update foo set "version" = 'def' where "version" = 'abc';

The bug is because our sql tokenizer handles 'version' as a reserved word instead of an identifier. A quick workaround is to use "" wrapping up the name to prevent ambiguity.

However, this indeed causes some inconvenience and we'll need to fix this ultimately.