Skip to content

Commit 03fa572

Browse files
authored
[b/405039345] Require the assessment flag for snowflake-lite (#803)
* Require --assessment flag for snowflake-lite * apply spotless
1 parent 58ce62a commit 03fa572

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/snowflake/SnowflakeLiteConnector.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ public SnowflakeLiteConnector() {
4949
@Nonnull
5050
public Handle open(ConnectorArguments arguments)
5151
throws MetadataDumperUsageException, SQLException {
52-
if (arguments.isAssessment()) {
53-
String message =
54-
String.format(
55-
"The %s connector supports assessment without need for extra flags."
56-
+ " Try running again without the '--%s' flag",
57-
NAME, ConnectorArguments.OPT_ASSESSMENT);
58-
throw new MetadataDumperUsageException(message);
52+
if (!arguments.isAssessment()) {
53+
throw noAssessmentException();
5954
}
6055
return super.open(arguments);
6156
}
@@ -78,4 +73,13 @@ public final void addTasksTo(List<? super Task<?>> out, ConnectorArguments argum
7873
out.add(new FormatTask(FORMAT_NAME));
7974
out.addAll(planner.generateLiteSpecificQueries());
8075
}
76+
77+
private static MetadataDumperUsageException noAssessmentException() {
78+
String message =
79+
String.format(
80+
"The %s connector only supports extraction for Assessment."
81+
+ " Provide the '--%s' flag to use this connector.",
82+
NAME, ConnectorArguments.OPT_ASSESSMENT);
83+
return new MetadataDumperUsageException(message);
84+
}
8185
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2022-2025 Google LLC
3+
* Copyright 2013-2021 CompilerWorks
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.google.edwmigration.dumper.application.dumper.connector.snowflake;
18+
19+
import static org.junit.Assert.assertThrows;
20+
21+
import com.google.edwmigration.dumper.application.dumper.ConnectorArguments;
22+
import com.google.edwmigration.dumper.application.dumper.MetadataDumperUsageException;
23+
import org.junit.Test;
24+
import org.junit.runner.RunWith;
25+
import org.junit.runners.JUnit4;
26+
27+
@RunWith(JUnit4.class)
28+
public class SnowflakeLiteConnectorTest {
29+
30+
@Test
31+
public void open_noAssessmentFlag_throwsUsageException() throws Exception {
32+
ConnectorArguments noFlagArguments = new ConnectorArguments("--connector", "snowflake-lite");
33+
SnowflakeLiteConnector connector = new SnowflakeLiteConnector();
34+
35+
assertThrows(MetadataDumperUsageException.class, () -> connector.open(noFlagArguments));
36+
}
37+
}

0 commit comments

Comments
 (0)