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

feat(frontend): define generated column on table/source with external schema #14644

Merged
merged 6 commits into from
Jan 19, 2024

Conversation

yuhao-su
Copy link
Contributor

@yuhao-su yuhao-su commented Jan 18, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

close #12209

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

For table/source with schema from external connector, we use * to represent all columns from the external connector.

Also we can define a generated column on able/source with an external connector.

example:

create table from_kafka ( *, gen_i32_field int as int32_field + 2, primary key (some_key) )
include key as some_key
with (
  connector = 'kafka',
  topic = 'test-rw-sink-upsert-avro',
  properties.bootstrap.server = 'message_queue:29092')
format upsert encode avro (
  schema.registry = 'http://message_queue:8081');

@yuhao-su yuhao-su added the user-facing-changes Contains changes that are visible to users label Jan 19, 2024
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yuhao-su yuhao-su added this pull request to the merge queue Jan 19, 2024
Merged via the queue into main with commit be7f0b6 Jan 19, 2024
31 of 32 checks passed
@yuhao-su yuhao-su deleted the yuhao/generated_column_in_create_source branch January 19, 2024 11:08
@@ -80,6 +80,8 @@ macro_rules! impl_fmt_display {
pub struct CreateSourceStatement {
pub if_not_exists: bool,
pub columns: Vec<ColumnDef>,
// The wildchar position in columns defined in sql. Only exist when using external schema.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what doesexternal schema refer to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema from external connector

let has_items = !columns.is_empty()
|| !constraints.is_empty()
|| !watermarks.is_empty()
|| wildcard_idx.is_some();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we store the *'s index in catalog?
Is it true that the columns on the left of * means defined schema and on the right means generated columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be in the sql string in catalog

Is it true that the columns on the left of * means defined schema and on the right means generated columns
No, * means all columns from external source

cols_from_sql.append(&mut cols_from_source);
cols_from_sql.append(&mut cols_from_sql_r);
Ok(cols_from_sql)
}
} else {
// TODO(yuhao): https://github.com/risingwavelabs/risingwave/issues/12209
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This TODO should be removed

@mingfang
Copy link

mingfang commented Mar 31, 2024

this feature does not seem to work with Postgres CDC source

create table courses (*) from pg_mydb table 'public.courses';
ERROR:  Failed to run the query
Caused by these errors (recent errors listed first):
  1: gRPC request to meta service failed: Internal error
  2: failed to validate CDC table
  3: source cannot pass validation: INVALID_ARGUMENT: Primary key mismatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: define generated column on table/source whose schema is externally defined
6 participants