Skip to content

Commit c60cbd1

Browse files
nastrarionmonster
authored andcommitted
[paimon] Align error msg when altering table properties (apache#2046)
[FLUSS-2113] Upgrade Deployed Maven to Latest Stable Release (3.9.11) [FLUSS-2113] Upgrade Deployed Maven to Latest Stable Release (3.9.11)
1 parent a429170 commit c60cbd1

File tree

7 files changed

+152
-45
lines changed

7 files changed

+152
-45
lines changed

.mvn/wrapper/maven-wrapper.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
wrapperVersion=3.3.2
17+
wrapperVersion=3.3.4
1818
distributionType=only-script
19-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
20-
distributionSha256Sum=ccf20a80e75a17ffc34d47c5c95c98c39d426ca17d670f09cd91e877072a9309
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/PaimonLakeCatalog.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,14 @@ protected Catalog getPaimonCatalog() {
8484
public void createTable(TablePath tablePath, TableDescriptor tableDescriptor, Context context)
8585
throws TableAlreadyExistException {
8686
// then, create the table
87-
Identifier paimonPath = toPaimon(tablePath);
8887
Schema paimonSchema = toPaimonSchema(tableDescriptor);
8988
try {
90-
createTable(paimonPath, paimonSchema, context.isCreatingFlussTable());
89+
createTable(tablePath, paimonSchema, context.isCreatingFlussTable());
9190
} catch (Catalog.DatabaseNotExistException e) {
9291
// create database
9392
createDatabase(tablePath.getDatabaseName());
9493
try {
95-
createTable(paimonPath, paimonSchema, context.isCreatingFlussTable());
94+
createTable(tablePath, paimonSchema, context.isCreatingFlussTable());
9695
} catch (Catalog.DatabaseNotExistException t) {
9796
// shouldn't happen in normal cases
9897
throw new RuntimeException(
@@ -109,26 +108,26 @@ public void createTable(TablePath tablePath, TableDescriptor tableDescriptor, Co
109108
public void alterTable(TablePath tablePath, List<TableChange> tableChanges, Context context)
110109
throws TableNotExistException {
111110
try {
112-
Identifier paimonPath = toPaimon(tablePath);
113111
List<SchemaChange> paimonSchemaChanges = toPaimonSchemaChanges(tableChanges);
114-
alterTable(paimonPath, paimonSchemaChanges);
112+
alterTable(tablePath, paimonSchemaChanges);
115113
} catch (Catalog.ColumnAlreadyExistException | Catalog.ColumnNotExistException e) {
116114
// shouldn't happen before we support schema change
117115
throw new RuntimeException(e);
118116
}
119117
}
120118

121-
private void createTable(Identifier tablePath, Schema schema, boolean isCreatingFlussTable)
119+
private void createTable(TablePath tablePath, Schema schema, boolean isCreatingFlussTable)
122120
throws Catalog.DatabaseNotExistException {
121+
Identifier paimonPath = toPaimon(tablePath);
123122
try {
124123
// not ignore if table exists
125-
paimonCatalog.createTable(tablePath, schema, false);
124+
paimonCatalog.createTable(paimonPath, schema, false);
126125
} catch (Catalog.TableAlreadyExistException e) {
127126
try {
128-
Table table = paimonCatalog.getTable(tablePath);
127+
Table table = paimonCatalog.getTable(paimonPath);
129128
FileStoreTable fileStoreTable = (FileStoreTable) table;
130129
validatePaimonSchemaCompatible(
131-
tablePath, fileStoreTable.schema().toSchema(), schema);
130+
paimonPath, fileStoreTable.schema().toSchema(), schema);
132131
// if creating a new fluss table, we should ensure the lake table is empty
133132
if (isCreatingFlussTable) {
134133
checkTableIsEmpty(tablePath, fileStoreTable);
@@ -155,12 +154,12 @@ private void createDatabase(String databaseName) {
155154
}
156155
}
157156

158-
private void alterTable(Identifier tablePath, List<SchemaChange> tableChanges)
157+
private void alterTable(TablePath tablePath, List<SchemaChange> tableChanges)
159158
throws Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException {
160159
try {
161-
paimonCatalog.alterTable(tablePath, tableChanges, false);
160+
paimonCatalog.alterTable(toPaimon(tablePath), tableChanges, false);
162161
} catch (Catalog.TableNotExistException e) {
163-
throw new TableNotExistException("Table " + tablePath + " not exists.");
162+
throw new TableNotExistException("Table " + tablePath + " does not exist.");
164163
}
165164
}
166165

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/utils/PaimonTableValidation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.fluss.lake.paimon.utils;
1919

2020
import org.apache.fluss.exception.TableAlreadyExistException;
21+
import org.apache.fluss.metadata.TablePath;
2122

2223
import org.apache.paimon.CoreOptions;
2324
import org.apache.paimon.catalog.Identifier;
@@ -79,13 +80,13 @@ private static void removeChangeableOptions(Map<String, String> options) {
7980
&& !entry.getKey().startsWith(FLUSS_CONF_PREFIX));
8081
}
8182

82-
public static void checkTableIsEmpty(Identifier tablePath, FileStoreTable table) {
83+
public static void checkTableIsEmpty(TablePath tablePath, FileStoreTable table) {
8384
if (table.latestSnapshot().isPresent()) {
8485
throw new TableAlreadyExistException(
8586
String.format(
8687
"The table %s already exists in Paimon catalog, and the table is not empty. "
8788
+ "Please first drop the table in Paimon catalog or use a new table name.",
88-
tablePath.getEscapedFullName()));
89+
tablePath));
8990
}
9091
}
9192

fluss-lake/fluss-lake-paimon/src/test/java/org/apache/fluss/lake/paimon/LakeEnabledTableCreateITCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ void testCreateLakeEnableTableWithExistNonEmptyLakeTable() throws Exception {
561561
.cause()
562562
.isInstanceOf(LakeTableAlreadyExistException.class)
563563
.hasMessage(
564-
"The table `fluss`.`log_table_with_non_empty_lake_table` already exists in Paimon catalog, and the table is not empty. Please first drop the table in Paimon catalog or use a new table name.");
564+
"The table fluss.log_table_with_non_empty_lake_table already exists in Paimon catalog, and the table is not empty. Please first drop the table in Paimon catalog or use a new table name.");
565565
}
566566

567567
@Test

fluss-lake/fluss-lake-paimon/src/test/java/org/apache/fluss/lake/paimon/PaimonLakeCatalogTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.fluss.lake.paimon;
1919

2020
import org.apache.fluss.config.Configuration;
21+
import org.apache.fluss.exception.TableNotExistException;
2122
import org.apache.fluss.lake.lakestorage.TestingLakeCatalogContext;
2223
import org.apache.fluss.metadata.Schema;
2324
import org.apache.fluss.metadata.TableChange;
@@ -35,6 +36,7 @@
3536
import java.util.Collections;
3637

3738
import static org.assertj.core.api.Assertions.assertThat;
39+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3840

3941
/** Unit test for {@link PaimonLakeCatalog}. */
4042
class PaimonLakeCatalogTest {
@@ -83,6 +85,34 @@ void testAlterTableProperties() throws Exception {
8385
assertThat(table.options().get("fluss.key")).isEqualTo(null);
8486
}
8587

88+
@Test
89+
void alterTablePropertiesWithNonExistentTable() {
90+
TestingLakeCatalogContext context = new TestingLakeCatalogContext();
91+
// db & table don't exist
92+
assertThatThrownBy(
93+
() ->
94+
flussPaimonCatalog.alterTable(
95+
TablePath.of("non_existing_db", "non_existing_table"),
96+
Collections.singletonList(TableChange.set("key", "value")),
97+
context))
98+
.isInstanceOf(TableNotExistException.class)
99+
.hasMessage("Table non_existing_db.non_existing_table does not exist.");
100+
101+
String database = "alter_props_db";
102+
String tableName = "alter_props_table";
103+
createTable(database, tableName);
104+
105+
// database exists but table doesn't
106+
assertThatThrownBy(
107+
() ->
108+
flussPaimonCatalog.alterTable(
109+
TablePath.of(database, "non_existing_table"),
110+
Collections.singletonList(TableChange.set("key", "value")),
111+
context))
112+
.isInstanceOf(TableNotExistException.class)
113+
.hasMessage("Table alter_props_db.non_existing_table does not exist.");
114+
}
115+
86116
private void createTable(String database, String tableName) {
87117
Schema flussSchema =
88118
Schema.newBuilder()

mvnw

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
# "License"); you may not use this file except in compliance
99
# with the License. You may obtain a copy of the License at
1010
#
11-
# http://www.apache.org/licenses/LICENSE-2.0
11+
# http://www.apache.org/licenses/LICENSE-2.0
1212
#
13-
# Unless required by applicable law or agreed to in writing, software
14-
# distributed under the License is distributed on an "AS IS" BASIS,
15-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
# See the License for the specific language governing permissions and
17-
# limitations under the License.
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
1819
# ----------------------------------------------------------------------------
1920

2021
# ----------------------------------------------------------------------------
21-
# Apache Maven Wrapper startup batch script, version 3.3.2
22+
# Apache Maven Wrapper startup batch script, version 3.3.4
2223
#
2324
# Optional ENV vars
2425
# -----------------
@@ -104,14 +105,17 @@ trim() {
104105
printf "%s" "${1}" | tr -d '[:space:]'
105106
}
106107

108+
scriptDir="$(dirname "$0")"
109+
scriptName="$(basename "$0")"
110+
107111
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
108112
while IFS="=" read -r key value; do
109113
case "${key-}" in
110114
distributionUrl) distributionUrl=$(trim "${value-}") ;;
111115
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
112116
esac
113-
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
114-
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
117+
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
118+
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
115119

116120
case "${distributionUrl##*/}" in
117121
maven-mvnd-*bin.*)
@@ -129,7 +133,7 @@ maven-mvnd-*bin.*)
129133
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
130134
;;
131135
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
132-
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
136+
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
133137
esac
134138

135139
# apply MVNW_REPOURL and calculate MAVEN_HOME
@@ -226,7 +230,7 @@ if [ -n "${distributionSha256Sum-}" ]; then
226230
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
227231
exit 1
228232
elif command -v sha256sum >/dev/null; then
229-
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
233+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
230234
distributionSha256Result=true
231235
fi
232236
elif command -v shasum >/dev/null; then
@@ -251,8 +255,41 @@ if command -v unzip >/dev/null; then
251255
else
252256
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
253257
fi
254-
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
255-
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
258+
259+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
260+
actualDistributionDir=""
261+
262+
# First try the expected directory name (for regular distributions)
263+
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264+
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265+
actualDistributionDir="$distributionUrlNameMain"
266+
fi
267+
fi
268+
269+
# If not found, search for any directory with the Maven executable (for snapshots)
270+
if [ -z "$actualDistributionDir" ]; then
271+
# enable globbing to iterate over items
272+
set +f
273+
for dir in "$TMP_DOWNLOAD_DIR"/*; do
274+
if [ -d "$dir" ]; then
275+
if [ -f "$dir/bin/$MVN_CMD" ]; then
276+
actualDistributionDir="$(basename "$dir")"
277+
break
278+
fi
279+
fi
280+
done
281+
set -f
282+
fi
283+
284+
if [ -z "$actualDistributionDir" ]; then
285+
verbose "Contents of $TMP_DOWNLOAD_DIR:"
286+
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287+
die "Could not find Maven distribution directory in extracted archive"
288+
fi
289+
290+
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291+
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292+
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
256293

257294
clean || :
258295
exec_maven "$@"

mvnw.cmd

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
@REM "License"); you may not use this file except in compliance
99
@REM with the License. You may obtain a copy of the License at
1010
@REM
11-
@REM http://www.apache.org/licenses/LICENSE-2.0
11+
@REM http://www.apache.org/licenses/LICENSE-2.0
1212
@REM
13-
@REM Unless required by applicable law or agreed to in writing, software
14-
@REM distributed under the License is distributed on an "AS IS" BASIS,
15-
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
@REM See the License for the specific language governing permissions and
17-
@REM limitations under the License.
13+
@REM Unless required by applicable law or agreed to in writing,
14+
@REM software distributed under the License is distributed on an
15+
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
@REM KIND, either express or implied. See the License for the
17+
@REM specific language governing permissions and limitations
18+
@REM under the License.
1819
@REM ----------------------------------------------------------------------------
1920

2021
@REM ----------------------------------------------------------------------------
21-
@REM Apache Maven Wrapper startup batch script, version 3.3.2
22+
@REM Apache Maven Wrapper startup batch script, version 3.3.4
2223
@REM
2324
@REM Optional ENV vars
2425
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@@ -39,7 +40,7 @@
3940
@SET __MVNW_ARG0_NAME__=
4041
@SET MVNW_USERNAME=
4142
@SET MVNW_PASSWORD=
42-
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
43+
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
4344
@echo Cannot start maven from wrapper >&2 && exit /b 1
4445
@GOTO :EOF
4546
: end batch / begin powershell #>
@@ -72,16 +73,30 @@ switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
7273
# apply MVNW_REPOURL and calculate MAVEN_HOME
7374
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
7475
if ($env:MVNW_REPOURL) {
75-
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
76-
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
76+
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
77+
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
7778
}
7879
$distributionUrlName = $distributionUrl -replace '^.*/',''
7980
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
80-
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
81+
82+
$MAVEN_M2_PATH = "$HOME/.m2"
8183
if ($env:MAVEN_USER_HOME) {
82-
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
84+
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
85+
}
86+
87+
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
88+
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
89+
}
90+
91+
$MAVEN_WRAPPER_DISTS = $null
92+
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
93+
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
94+
} else {
95+
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
8396
}
84-
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
97+
98+
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
99+
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
85100
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
86101

87102
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
@@ -133,7 +148,33 @@ if ($distributionSha256Sum) {
133148

134149
# unzip and move
135150
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
136-
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
151+
152+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
153+
$actualDistributionDir = ""
154+
155+
# First try the expected directory name (for regular distributions)
156+
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
157+
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
158+
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
159+
$actualDistributionDir = $distributionUrlNameMain
160+
}
161+
162+
# If not found, search for any directory with the Maven executable (for snapshots)
163+
if (!$actualDistributionDir) {
164+
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
165+
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
166+
if (Test-Path -Path $testPath -PathType Leaf) {
167+
$actualDistributionDir = $_.Name
168+
}
169+
}
170+
}
171+
172+
if (!$actualDistributionDir) {
173+
Write-Error "Could not find Maven distribution directory in extracted archive"
174+
}
175+
176+
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
177+
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
137178
try {
138179
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
139180
} catch {

0 commit comments

Comments
 (0)