-
Notifications
You must be signed in to change notification settings - Fork 988
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
[Core] Support alter database #4700
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
030f8c9
support alter database
jerry-024 1e66c0a
add AlterDatabase request and response, and remove ignoreIfExists in …
jerry-024 ecd6a90
fix compile fail
jerry-024 95c88c2
add getAddAndRemovePropertiesFromDatabaseChanges in AbstractCatalog t…
jerry-024 8b97cf7
fix typo
jerry-024 9edbd55
add ut for alter database
jerry-024 ba12048
fix typo
jerry-024 6c77dca
add alter database open api define
jerry-024 5cbb9db
fix typo and update remove properties to remove keys
jerry-024 a4d3c46
fix add when keys has exist in jdbc catalog
jerry-024 4bb3e52
update name for getSetPropertiesToRemoveKeys
jerry-024 29da0ec
add alter database ut for FileSystemCatalog
jerry-024 c2cfcbe
add alter database in catalog-api doc
jerry-024 240c30b
update alert database add multiply properties and update databases to…
jerry-024 c0e45e5
rename DatabaseChange to PropertyChange
jerry-024 36583ea
support ALTER DATABASE for Flink SQL and Spark SQL
jerry-024 f7a2e15
fix ut fail
jerry-024 6b77e13
add alter database doc for flink and spark and support comment when c…
jerry-024 dbe6591
Merge branch 'master' into rest-catalog
jerry-024 91f3408
fix flink alter database change comment and add test, doc for location
jerry-024 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,3 +240,21 @@ The following SQL changes the type of a nested column `f2` to `BIGINT` in a stru | |
-- column v previously has type MAP<INT, STRUCT<f1: STRING, f2: INT>> | ||
ALTER TABLE my_table ALTER COLUMN v.value.f2 TYPE BIGINT; | ||
``` | ||
|
||
|
||
# ALTER DATABASE | ||
|
||
The following SQL sets one or more properties in the specified database. If a particular property is already set in the database, override the old value with the new one. | ||
|
||
```sql | ||
ALTER { DATABASE | SCHEMA | NAMESPACE } my_database | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add example to alter comment and location. |
||
SET { DBPROPERTIES | PROPERTIES } ( property_name = property_value [ , ... ] ) | ||
``` | ||
|
||
## Altering Database Location | ||
|
||
The following SQL sets the location of the specified database to `file:/temp/my_database.db`. | ||
|
||
```sql | ||
ALTER DATABASE my_database SET LOCATION 'file:/temp/my_database.db' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
paimon-core/src/main/java/org/apache/paimon/catalog/PropertyChange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.paimon.catalog; | ||
|
||
import org.apache.paimon.utils.Pair; | ||
|
||
import org.apache.paimon.shade.guava30.com.google.common.collect.Maps; | ||
import org.apache.paimon.shade.guava30.com.google.common.collect.Sets; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** define change to the database property. */ | ||
public interface PropertyChange { | ||
|
||
static PropertyChange setProperty(String property, String value) { | ||
return new SetProperty(property, value); | ||
} | ||
|
||
static PropertyChange removeProperty(String property) { | ||
return new RemoveProperty(property); | ||
} | ||
|
||
static Pair<Map<String, String>, Set<String>> getSetPropertiesToRemoveKeys( | ||
List<PropertyChange> changes) { | ||
Map<String, String> setProperties = Maps.newHashMap(); | ||
Set<String> removeKeys = Sets.newHashSet(); | ||
changes.forEach( | ||
change -> { | ||
if (change instanceof PropertyChange.SetProperty) { | ||
PropertyChange.SetProperty setProperty = | ||
(PropertyChange.SetProperty) change; | ||
setProperties.put(setProperty.property(), setProperty.value()); | ||
} else { | ||
removeKeys.add(((PropertyChange.RemoveProperty) change).property()); | ||
} | ||
}); | ||
return Pair.of(setProperties, removeKeys); | ||
} | ||
|
||
/** Set property for database change. */ | ||
final class SetProperty implements PropertyChange { | ||
|
||
private final String property; | ||
private final String value; | ||
|
||
private SetProperty(String property, String value) { | ||
this.property = property; | ||
this.value = value; | ||
} | ||
|
||
public String property() { | ||
return this.property; | ||
} | ||
|
||
public String value() { | ||
return this.value; | ||
} | ||
} | ||
|
||
/** Remove property for database change. */ | ||
final class RemoveProperty implements PropertyChange { | ||
|
||
private final String property; | ||
|
||
private RemoveProperty(String property) { | ||
this.property = property; | ||
} | ||
|
||
public String property() { | ||
return this.property; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add example to alter comment and location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in flink sql couldn't alter comment for the database, so we could only alter the location.