Skip to content

Commit 070f9e6

Browse files
committed
Move the property enum to a separate file
1 parent 69fc9fa commit 070f9e6

File tree

2 files changed

+89
-59
lines changed

2 files changed

+89
-59
lines changed

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

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -83,63 +83,6 @@ public SnowflakeLogsConnector() {
8383
this("snowflake-logs", SCHEMA_ONLY_SOURCE);
8484
}
8585

86-
enum SnowflakeLogsConnectorProperty implements ConnectorProperty {
87-
OVERRIDE_QUERY("snowflake.logs.query", "Custom query for log dump."),
88-
OVERRIDE_WHERE(
89-
"snowflake.logs.where", "Custom where condition to append to query for log dump."),
90-
91-
WAREHOUSE_EVENTS_HISTORY_OVERRIDE_QUERY(
92-
"snowflake.warehouse_events_history.query",
93-
"Custom query for warehouse events history dump"),
94-
AUTOMATIC_CLUSTERING_HISTORY_OVERRIDE_QUERY(
95-
"snowflake.automatic_clustering_history.query",
96-
"Custom query for automatic clustering history dump"),
97-
COPY_HISTORY_OVERRIDE_QUERY(
98-
"snowflake.copy_history.query", "Custom query for copy history dump"),
99-
DATABASE_REPLICATION_USAGE_HISTORY_OVERRIDE_QUERY(
100-
"snowflake.database_replication_usage_history.query",
101-
"Custom query for database replication usage history dump"),
102-
LOGIN_HISTORY_OVERRIDE_QUERY(
103-
"snowflake.login_history.query", "Custom query for login history dump"),
104-
METERING_DAILY_HISTORY_OVERRIDE_QUERY(
105-
"snowflake.metering_daily_history.query", "Custom query for metering daily history dump"),
106-
PIPE_USAGE_HISTORY_OVERRIDE_QUERY(
107-
"snowflake.pipe_usage_history.query", "Custom query for pipe usage history dump"),
108-
QUERY_ACCELERATION_HISTORY_OVERRIDE_QUERY(
109-
"snowflake.query_acceleration_history.query",
110-
"Custom query for query acceleration history dump"),
111-
REPLICATION_GROUP_USAGE_HISTORY_OVERRIDE_QUERY(
112-
"snowflake.replication_group_usage_history.query",
113-
"Custom query for replication group usage history dump"),
114-
SERVERLESS_TASK_HISTORY_OVERRIDE_QUERY(
115-
"snowflake.serverless_task_history.query", "Custom query for serverless task history dump"),
116-
TASK_HISTORY_OVERRIDE_QUERY(
117-
"snowflake.task_history.query", "Custom query for task history dump"),
118-
WAREHOUSE_LOAD_HISTORY_OVERRIDE_QUERY(
119-
"snowflake.warehouse_load_history.query", "Custom query for warehouse load history dump"),
120-
WAREHOUSE_METERING_HISTORY_OVERRIDE_QUERY(
121-
"snowflake.warehouse_metering_history.query",
122-
"Custom query for warehouse metering history dump");
123-
124-
private final String name;
125-
private final String description;
126-
127-
SnowflakeLogsConnectorProperty(String name, String description) {
128-
this.name = name;
129-
this.description = description;
130-
}
131-
132-
@Nonnull
133-
public String getName() {
134-
return name;
135-
}
136-
137-
@Nonnull
138-
public String getDescription() {
139-
return description;
140-
}
141-
}
142-
14386
private static class TaskDescription {
14487
private final String zipPrefix;
14588
private final String unformattedQuery;
@@ -180,7 +123,7 @@ public String getDescription() {
180123
@Override
181124
@Nonnull
182125
public ImmutableList<ConnectorProperty> getPropertyConstants() {
183-
return stream(SnowflakeLogsConnectorProperty.values()).collect(toImmutableList());
126+
return SnowflakeLogsConnectorProperty.getConstants();
184127
}
185128

186129
private String newQueryFormat(@Nonnull ConnectorArguments arguments)
@@ -390,7 +333,7 @@ public final void addTasksTo(
390333
.map(
391334
item -> {
392335
String override = arguments.getDefinition(item.property);
393-
String prefix = formatPrefix(item.headerClass, item.name());
336+
String prefix = formatPrefix(item.headerClass, item.viewName());
394337
String query = overrideableQuery(override, prefix, item.column.value);
395338
return new TaskDescription(item.zipPrefix, query, item.headerClass);
396339
})
@@ -547,6 +490,10 @@ enum TimeSeriesView {
547490
TASK_HISTORY,
548491
WAREHOUSE_LOAD_HISTORY,
549492
WAREHOUSE_METERING_HISTORY);
493+
494+
String viewName() {
495+
return name();
496+
}
550497
}
551498

552499
@Nonnull
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 com.google.common.collect.ImmutableList.toImmutableList;
20+
import static java.util.Arrays.stream;
21+
22+
import com.google.common.collect.ImmutableList;
23+
import com.google.edwmigration.dumper.application.dumper.connector.ConnectorProperty;
24+
import javax.annotation.Nonnull;
25+
26+
enum SnowflakeLogsConnectorProperty implements ConnectorProperty {
27+
/* Basic overrides. */
28+
OVERRIDE_QUERY("snowflake.logs.query", "Custom query for log dump."),
29+
OVERRIDE_WHERE("snowflake.logs.where", "Custom where condition to append to query for log dump."),
30+
31+
/* Time series custom queries. */
32+
WAREHOUSE_EVENTS_HISTORY_OVERRIDE_QUERY(
33+
"snowflake.warehouse_events_history.query", "Custom query for warehouse events history dump"),
34+
AUTOMATIC_CLUSTERING_HISTORY_OVERRIDE_QUERY(
35+
"snowflake.automatic_clustering_history.query",
36+
"Custom query for automatic clustering history dump"),
37+
COPY_HISTORY_OVERRIDE_QUERY("snowflake.copy_history.query", "Custom query for copy history dump"),
38+
DATABASE_REPLICATION_USAGE_HISTORY_OVERRIDE_QUERY(
39+
"snowflake.database_replication_usage_history.query",
40+
"Custom query for database replication usage history dump"),
41+
LOGIN_HISTORY_OVERRIDE_QUERY(
42+
"snowflake.login_history.query", "Custom query for login history dump"),
43+
METERING_DAILY_HISTORY_OVERRIDE_QUERY(
44+
"snowflake.metering_daily_history.query", "Custom query for metering daily history dump"),
45+
PIPE_USAGE_HISTORY_OVERRIDE_QUERY(
46+
"snowflake.pipe_usage_history.query", "Custom query for pipe usage history dump"),
47+
QUERY_ACCELERATION_HISTORY_OVERRIDE_QUERY(
48+
"snowflake.query_acceleration_history.query",
49+
"Custom query for query acceleration history dump"),
50+
REPLICATION_GROUP_USAGE_HISTORY_OVERRIDE_QUERY(
51+
"snowflake.replication_group_usage_history.query",
52+
"Custom query for replication group usage history dump"),
53+
SERVERLESS_TASK_HISTORY_OVERRIDE_QUERY(
54+
"snowflake.serverless_task_history.query", "Custom query for serverless task history dump"),
55+
TASK_HISTORY_OVERRIDE_QUERY("snowflake.task_history.query", "Custom query for task history dump"),
56+
WAREHOUSE_LOAD_HISTORY_OVERRIDE_QUERY(
57+
"snowflake.warehouse_load_history.query", "Custom query for warehouse load history dump"),
58+
WAREHOUSE_METERING_HISTORY_OVERRIDE_QUERY(
59+
"snowflake.warehouse_metering_history.query",
60+
"Custom query for warehouse metering history dump");
61+
62+
private final String name;
63+
private final String description;
64+
65+
SnowflakeLogsConnectorProperty(String name, String description) {
66+
this.name = name;
67+
this.description = description;
68+
}
69+
70+
static ImmutableList<ConnectorProperty> getConstants() {
71+
return stream(values()).collect(toImmutableList());
72+
}
73+
74+
@Nonnull
75+
public String getName() {
76+
return name;
77+
}
78+
79+
@Nonnull
80+
public String getDescription() {
81+
return description;
82+
}
83+
}

0 commit comments

Comments
 (0)