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

CREATE TABLE AS updates #5247

Merged
merged 1 commit into from
Aug 28, 2019
Merged

CREATE TABLE AS updates #5247

merged 1 commit into from
Aug 28, 2019

Conversation

ericharmeling
Copy link
Contributor

  • Parameter updates
  • Diagram updates
  • Examples now use MovR
  • Updated stmt_block diagram (to include new changes)

Code PRs:
cockroachdb/cockroach#38589
cockroachdb/cockroach#38904

Fixes #5190

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ericharmeling
Copy link
Contributor Author

@jseldess I added a partitioning-relevant example. Please review that for comprehension and accuracy. We can discuss more offline, but the example is limited. I figured including an entire set of instructions for setting up nodes and localities would would a little overkill. Let me know if you disagree.

@ericharmeling
Copy link
Contributor Author

@jseldess Added @lhirata to review this, as discussed.

Copy link
Contributor

@lnhsingh lnhsingh left a comment

Choose a reason for hiding this comment

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

A few minor edits but otherwise LGTM!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling, @jseldess, and @lhirata)


v19.2/create-table-as.md, line 7 at r1 (raw file):

---

The `CREATE TABLE ... AS` statement creates a new table from a [selection query](selection-queries.html).

Add link to statement


v19.2/create-table-as.md, line 59 at r1 (raw file):

<div>
  {% include {{ page.version.version }}/sql/diagrams/family_def.html %}

This diagram is a little confusing because it says opt_family_name and then name. Maybe name should be column_name?


v19.2/create-table-as.md, line 138 at r1 (raw file):

### Change column names

This statement creates a copy of an existing table but with changed column names.

Switch period to colon at end of sentence


v19.2/create-table-as.md, line 142 at r1 (raw file):

{% include copy-clipboard.html %}
~~~ sql
> CREATE TABLE users_ny_names (id, name) AS SELECT id, name FROM users WHERE city = 'new york';

Which column names are changed? To show the change, should the example instead be something like CREATE TABLE users_ny_names (user_id, user_name) AS SELECT id, name FROM ...?


v19.2/create-table-as.md, line 203 at r1 (raw file):

When a table copy is created this way, the copy is not associated to
any primary key, secondary index or constraint that was present on the

Add an Oxford comma


v19.2/create-table-as.md, line 290 at r1 (raw file):

### Specify a primary key for partitioning

If you are [partitioning](partitioning.html) a table based on a primary key, you must correctly define the primary key at table creation. It is not possible to add or change primary keys after table creation. To work around this limitation, you can create a new table from an existing one, with the correct primary keys specified in your `CREATE TABLE ... AS` statement.

Maybe link to the primary key docs here.

Copy link
Contributor Author

@ericharmeling ericharmeling left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jseldess and @lhirata)


v19.2/create-table-as.md, line 7 at r1 (raw file):

Previously, lhirata wrote…

Add link to statement

Done.


v19.2/create-table-as.md, line 59 at r1 (raw file):

Previously, lhirata wrote…

This diagram is a little confusing because it says opt_family_name and then name. Maybe name should be column_name?

I'm just going to remove the family_def diagram from here. I don't think it adds anything.


v19.2/create-table-as.md, line 138 at r1 (raw file):

Previously, lhirata wrote…

Switch period to colon at end of sentence

Done.


v19.2/create-table-as.md, line 142 at r1 (raw file):

Previously, lhirata wrote…

Which column names are changed? To show the change, should the example instead be something like CREATE TABLE users_ny_names (user_id, user_name) AS SELECT id, name FROM ...?

Good catch! Done.


v19.2/create-table-as.md, line 203 at r1 (raw file):

Previously, lhirata wrote…

Add an Oxford comma

Done.


v19.2/create-table-as.md, line 290 at r1 (raw file):

Previously, lhirata wrote…

Maybe link to the primary key docs here.

Done.

Parameter updates
Diagram updates
Examples now use MovR
New primary key example for partitioning

Code PRs:
cockroachdb/cockroach#38589
cockroachdb/cockroach#38904

Fixes #5190
@ericharmeling ericharmeling merged commit f844e19 into master Aug 28, 2019
@ericharmeling ericharmeling deleted the cta-pk branch August 28, 2019 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg: Allow user defined primary key in CREATE TABLE ... AS
3 participants