all-things-risingwave

How to handle automatically incremented IDs in RisingWave similar to 'series' datatype in Postgres?

Georg Boegerl is looking for a recommendation on handling automatically incremented IDs in RisingWave similar to the 'series' datatype in Postgres. He needs a unique record ID to delete duplicates and prefers database management over application level. He also mentions the challenge of migrating legacy data from Postgres and ingesting it without duplicates. Tianxiao Shen mentions internally generated primary keys in RisingWave and suggests using them for deduplication. Georg Boegerl asks how to take advantage of these internally generated primary keys in a SQL statement.

Ge

Georg Boegerl

Asked on Jan 09, 2024

  • RisingWave internally generates primary keys if not provided, with a hidden column '_row_id' functioning as the primary key.
  • To utilize the internal column in a SQL statement, use '__row__id' instead of '_row_id'.
  • Example SQL statement:
select __row__id, v from t;
  • When using SQLAlchemy with RisingWave, ensure to use '__row__id' instead of '_row_id' in the query to avoid reserved word error.
Jan 09, 2024Edited by