Skip to content

Commit 99ef940

Browse files
committed
moved UDF.csv to metadata form query-logs
1 parent ffe2e5f commit 99ef940

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,6 @@ public final void addTasksTo(
300300
out.add(new FormatTask(FORMAT_NAME));
301301
out.add(SnowflakeYamlSummaryTask.create(FORMAT_NAME, arguments));
302302

303-
if (arguments.isAssessment()) {
304-
String userDefinedFunctions =
305-
"SELECT FUNCTION_CATALOG, FUNCTION_SCHEMA, FUNCTION_NAME, FUNCTION_LANGUAGE, ARGUMENT_SIGNATURE, "
306-
+ "FUNCTION_OWNER, COMMENT, VOLATILITY, RUNTIME_VERSION, LAST_ALTERED, "
307-
+ "PACKAGES, IMPORTS, IS_AGGREGATE, IS_DATA_METRIC, IS_MEMOIZABLE "
308-
+ "FROM SNOWFLAKE.ACCOUNT_USAGE.FUNCTIONS "
309-
+ "WHERE FUNCTION_SCHEMA != 'INFORMATION_SCHEMA' "
310-
+ "AND DELETED IS NULL";
311-
out.add(
312-
new JdbcSelectTask(
313-
"user_defined_functions.csv", userDefinedFunctions, TaskCategory.OPTIONAL)
314-
.withHeaderClass(FunctionsHeader.class));
315-
}
316-
317303
// (24 * 7) -> 7 trailing days == 168 hours
318304
// Actually, on Snowflake, 7 days ago starts at midnight in an unadvertised time zone. What the
319305
// <deleted>.
@@ -521,24 +507,6 @@ String viewName() {
521507
}
522508
}
523509

524-
private enum FunctionsHeader {
525-
FUNCTION_CATALOG,
526-
FUNCTION_SCHEMA,
527-
FUNCTION_NAME,
528-
FUNCTION_LANGUAGE,
529-
ARGUMENT_SIGNATURE,
530-
FUNCTION_OWNER,
531-
COMMENT,
532-
VOLATILITY,
533-
RUNTIME_VERSION,
534-
LAST_ALTERED,
535-
PACKAGES,
536-
IMPORTS,
537-
IS_AGGREGATE,
538-
IS_DATA_METRIC,
539-
IS_MEMOIZABLE
540-
}
541-
542510
@Nonnull
543511
static String formatPrefix(@Nonnull Class<? extends Enum<?>> enumClass, @Nonnull String view) {
544512
String selectList =

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.edwmigration.dumper.plugin.lib.dumper.spi.SnowflakeMetadataDumpFormat.SchemataFormat;
3131
import com.google.edwmigration.dumper.plugin.lib.dumper.spi.SnowflakeMetadataDumpFormat.TableStorageMetricsFormat;
3232
import com.google.edwmigration.dumper.plugin.lib.dumper.spi.SnowflakeMetadataDumpFormat.TablesFormat;
33+
import com.google.edwmigration.dumper.plugin.lib.dumper.spi.SnowflakeMetadataDumpFormat.UserDefinedFunctionsFormat;
3334
import com.google.edwmigration.dumper.plugin.lib.dumper.spi.SnowflakeMetadataDumpFormat.WarehousesFormat;
3435
import javax.annotation.ParametersAreNonnullByDefault;
3536

@@ -49,6 +50,7 @@ private enum Format {
4950
EXTERNAL_TABLES(ExternalTablesFormat.AU_ZIP_ENTRY_NAME),
5051
FUNCTION_INFO(FunctionInfoFormat.AU_ZIP_ENTRY_NAME),
5152
TABLE_STORAGE_METRICS(TableStorageMetricsFormat.AU_ZIP_ENTRY_NAME),
53+
USER_DEFINED_FUNCTIONS(UserDefinedFunctionsFormat.IS_ZIP_ENTRY_NAME),
5254
WAREHOUSES(WarehousesFormat.AU_ZIP_ENTRY_NAME);
5355

5456
private final String value;
@@ -63,6 +65,8 @@ private enum Format {
6365

6466
private final ImmutableList<AssessmentQuery> assessmentQueries =
6567
ImmutableList.of(
68+
AssessmentQuery.createUserDefinedFunctionsSelect(
69+
Format.USER_DEFINED_FUNCTIONS, UPPER_UNDERSCORE),
6670
AssessmentQuery.createMetricsSelect(Format.TABLE_STORAGE_METRICS, UPPER_UNDERSCORE),
6771
AssessmentQuery.createShow("WAREHOUSES", Format.WAREHOUSES, LOWER_UNDERSCORE),
6872
SHOW_EXTERNAL_TABLES,
@@ -142,6 +146,17 @@ static AssessmentQuery createMetricsSelect(Format zipFormat, CaseFormat caseForm
142146
return new AssessmentQuery(true, formatString, zipFormat.value, caseFormat);
143147
}
144148

149+
static AssessmentQuery createUserDefinedFunctionsSelect(
150+
Format zipFormat, CaseFormat caseFormat) {
151+
String formatString =
152+
"SELECT FUNCTION_CATALOG, FUNCTION_SCHEMA, FUNCTION_NAME, FUNCTION_LANGUAGE, ARGUMENT_SIGNATURE, "
153+
+ "FUNCTION_OWNER, COMMENT, VOLATILITY, RUNTIME_VERSION, LAST_ALTERED, "
154+
+ "PACKAGES, IMPORTS, IS_AGGREGATE, IS_DATA_METRIC, IS_MEMOIZABLE "
155+
+ "FROM SNOWFLAKE.ACCOUNT_USAGE.FUNCTIONS "
156+
+ "WHERE FUNCTION_SCHEMA != 'INFORMATION_SCHEMA' ";
157+
return new AssessmentQuery(false, formatString, zipFormat.value, caseFormat);
158+
}
159+
145160
static AssessmentQuery createShow(String view, Format zipFormat, CaseFormat caseFormat) {
146161
String queryString = String.format("SHOW %s", view);
147162
return new AssessmentQuery(false, queryString, zipFormat.value, caseFormat);

dumper/lib-dumper-spi/src/main/java/com/google/edwmigration/dumper/plugin/lib/dumper/spi/SnowflakeMetadataDumpFormat.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ enum Header {
107107
}
108108
}
109109

110+
interface UserDefinedFunctionsFormat {
111+
112+
String IS_ZIP_ENTRY_NAME = "user_defined_functions.csv";
113+
114+
enum Header {
115+
FUNCTION_CATALOG,
116+
FUNCTION_SCHEMA,
117+
FUNCTION_NAME,
118+
FUNCTION_LANGUAGE,
119+
ARGUMENT_SIGNATURE,
120+
FUNCTION_OWNER,
121+
COMMENT,
122+
VOLATILITY,
123+
RUNTIME_VERSION,
124+
LAST_ALTERED,
125+
PACKAGES,
126+
IMPORTS,
127+
IS_AGGREGATE,
128+
IS_DATA_METRIC,
129+
IS_MEMOIZABLE
130+
}
131+
}
132+
110133
interface FunctionInfoFormat {
111134
String AU_ZIP_ENTRY_NAME = "function_info.csv";
112135
}

0 commit comments

Comments
 (0)