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

Adding support for renaming tables and partitioned tables #5574

Merged
merged 3 commits into from
May 16, 2017
Merged

Conversation

seut
Copy link
Member

@seut seut commented May 16, 2017

The related table will be closed upfront renaming (if not already closed), same for a partitioned table (close all non-closed partitions) and re-opened afterwards (only re-open if table or partition was open before).

@seut seut requested review from mfussenegger and dobe May 16, 2017 10:37
@codecov-io
Copy link

codecov-io commented May 16, 2017

Codecov Report

Merging #5574 into master will increase coverage by 0.23%.
The diff coverage is 85.19%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5574      +/-   ##
============================================
+ Coverage     82.66%   82.89%   +0.23%     
- Complexity    11590    11702     +112     
============================================
  Files          1382     1390       +8     
  Lines         44914    45200     +286     
  Branches       5580     5601      +21     
============================================
+ Hits          37128    37469     +341     
+ Misses         5174     5130      -44     
+ Partials       2612     2601      -11
Impacted Files Coverage Δ Complexity Δ
...er/src/main/java/io/crate/sql/tree/AstVisitor.java 32.79% <0%> (+1.34%) 41 <0> (+2) ⬆️
...a/io/crate/executor/transport/ChainableAction.java 100% <100%> (ø) 3 <3> (?)
...te/executor/transport/TransportExecutorModule.java 100% <100%> (ø) 2 <0> (ø) ⬇️
sql/src/main/java/io/crate/analyze/Analyzer.java 96.77% <100%> (+0.03%) 5 <0> (ø) ⬇️
...main/java/io/crate/analyze/AlterTableAnalyzer.java 88.88% <100%> (+2.77%) 17 <3> (+3) ⬆️
...ava/io/crate/analyze/AnalyzedStatementVisitor.java 56.41% <100%> (+1.14%) 22 <1> (+1) ⬆️
.../src/main/java/io/crate/sql/parser/AstBuilder.java 93.98% <100%> (+0.03%) 237 <1> (+1) ⬆️
...ate/analyze/AlterTableRenameAnalyzedStatement.java 100% <100%> (ø) 5 <5> (?)
...va/io/crate/action/sql/DDLStatementDispatcher.java 98.41% <100%> (+0.02%) 6 <0> (ø) ⬇️
...te/executor/transport/ddl/RenameTableResponse.java 100% <100%> (ø) 4 <4> (?)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 610da16...fc173e6. Read the comment docs.

@@ -56,6 +57,23 @@ public AlterTableAnalyzedStatement analyze(AlterTable node, Row parameters, Sess
return new AlterTableAnalyzedStatement(docTableInfo, partitionName, tableParameter, table.excludePartitions());
}

AlterTableRenameAnalyzedStatement analyzeRename(AlterTableRename node, String defaultSchema,
Copy link
Member

Choose a reason for hiding this comment

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

isn't the defaultSchema part of the sessionContext? I'd either require only the sessionContext or replace the sessionContext with user so that both dependencies are explicit, but not a mixture.


List<String> newIdentParts = node.newName().getParts();
if (newIdentParts.size() > 1) {
throw new IllegalArgumentException("Target table name must not include a schema");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a (technical) constraint that we don't allow this? If so - maybe add a short code comment to mention it

Copy link
Member

Choose a reason for hiding this comment

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

It also seems as if there is no test for this?

public class TransportRenameTableAction extends TransportMasterNodeAction<RenameTableRequest, RenameTableResponse> {

private static final String ACTION_NAME = "crate/table/rename";
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.fromOptions(false, false, false, false);
Copy link
Member

@mfussenegger mfussenegger May 16, 2017

Choose a reason for hiding this comment

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

Please rename so that it includes the characteristics of the IndicesOptions in the name. STRICT_INDICES_OPTIONS or something like that.

TableIdent tableIdent = TableIdent.of(node.table(), defaultSchema);
DocTableInfo tableInfo = schemas.getTableInfo(tableIdent, sessionContext.user());
if (!node.table().partitionProperties().isEmpty()) {
throw new UnsupportedOperationException("Renaming a single partition is not supported");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a analyzer-unit-test for this?

@seut seut merged commit fc173e6 into master May 16, 2017
@seut seut deleted the RenameTables branch May 16, 2017 12:16
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.

None yet

4 participants