Skip to content

Conversation

@yuhao-su
Copy link
Contributor

@yuhao-su yuhao-su commented Nov 29, 2022

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • support creating sink as a query
  • fix some wrongly assigned data in meta and missed handling for sink.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.

Types of user-facing changes

  • SQL commands, functions, and operators

Release note

support CREATE SINK sink_name AS select xxx from TABLE / MATERIALIZED VIEW / SOURCE WITH(connector = 'xxx')

Refer to a related PR or issue link (optional)

let user_core = &mut core.user;
database_core.ensure_database_id(sink.database_id)?;
database_core.ensure_schema_id(sink.schema_id)?;
database_core.ensure_table_id(sink.associated_table_id)?;
Copy link
Contributor

@HuaHuaY HuaHuaY Nov 29, 2022

Choose a reason for hiding this comment

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

I suggest to check whether dependent_relations exists here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the other streaming jobs did this. Maybe do it in a separate pr.

Copy link
Contributor

Choose a reason for hiding this comment

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

All of other streaming jobs do this. You can take a look at start_create_table_procedure. Some functions doesn't check dependent_relations, because we can find all the dependents without dependent_relations variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see. Acctually create_index did't do this. Should I also add the check for it?

Copy link
Contributor

@HuaHuaY HuaHuaY Nov 29, 2022

Choose a reason for hiding this comment

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

No. Index only depends on its primary table, so we just check whether primary_table_id exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the dependent_relations should contains 1 and only 1 item that is the primary_table_id ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, index's dependent_relations only contains primary_table_id

Copy link
Contributor Author

@yuhao-su yuhao-su Nov 29, 2022

Choose a reason for hiding this comment

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

Then let's add an assert here!

// If colume names not specified, use the name in materialized view.
let col_names = get_column_names(&bound, session, stmt.columns)?.or(sink_col_names);

let sink_name = Binder::resolve_sink_name(stmt.sink_name)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Help to remove resolve_sink_name. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe no need to do that. still not sure if it will be used later

Copy link
Contributor

@HuaHuaY HuaHuaY Nov 29, 2022

Choose a reason for hiding this comment

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

This resolve_sink_name was used to ensure that the sink and the corresponding table are in the same schema. I think after your PR, we don't need this constraint anymore. I think we support create sink xxx as select * from a.yyy join b.zzz on ... now and we have no idea whether xxx's schema is a or b

@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

Merging #6648 (1b62609) into main (f2801d3) will decrease coverage by 0.64%.
The diff coverage is 61.52%.

@@            Coverage Diff             @@
##             main    #6648      +/-   ##
==========================================
- Coverage   73.95%   73.30%   -0.65%     
==========================================
  Files         980     1012      +32     
  Lines      159120   162132    +3012     
==========================================
+ Hits       117671   118845    +1174     
- Misses      41449    43287    +1838     
Flag Coverage Δ
rust 73.30% <61.52%> (-0.65%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/batch/src/error.rs 0.00% <ø> (ø)
src/batch/src/executor/group_top_n.rs 68.42% <ø> (-6.44%) ⬇️
src/batch/src/executor/insert.rs 82.28% <ø> (ø)
...batch/src/executor/join/distributed_lookup_join.rs 0.00% <0.00%> (ø)
src/batch/src/executor/join/nested_loop_join.rs 91.73% <ø> (ø)
src/batch/src/executor/join/sort_merge_join.rs 79.04% <ø> (ø)
src/batch/src/executor/mod.rs 74.60% <0.00%> (+2.29%) ⬆️
src/batch/src/executor/order_by.rs 95.32% <ø> (ø)
src/batch/src/executor/project_set.rs 76.15% <ø> (ø)
src/batch/src/executor/source.rs 0.00% <0.00%> (ø)
... and 438 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yuhao-su yuhao-su added the user-facing-changes Contains changes that are visible to users label Nov 30, 2022
Comment on lines +8 to +14
CREATE SINK s4 AS select mv4.v1 as v1, mv4.v2 as v2 from mv4 WITH (
connector = 'mysql',
endpoint = '127.0.0.1:3306',
user = 'root',
database = 'test',
table = 't4'
);
Copy link
Contributor

Choose a reason for hiding this comment

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

we are deprecating the built-in mysql connector soon. please use jdbc connector here.

blocked by #6631

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How and when should I swith to jdbc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @yuhao-su, I think I can rewrite it in JDBC connector for you in #6631. In that PR I'm going to fix existing historic problems in sink e2e tests as well - it seems that sink e2e tests weren't enabled in CI at all.

@StrikeW StrikeW self-requested a review November 30, 2022 07:24
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

Generally LGTM! Good work!

Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

The Frontend part LGTM. But this PR modifies so many components, PTAL again 😿 c.c. @BugenZhao @yezizp2012 @HuaHuaY

Copy link
Contributor

@HuaHuaY HuaHuaY left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

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

The meta part LGTM, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature. user-facing-changes Contains changes that are visible to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants