Skip to content

Commit 1625404

Browse files
[Snowflake Connector] Include more column properties in the metadata archive. (#827)
1 parent f16cf4c commit 1625404

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ public final void addTasksTo(
211211
getOverrideableQuery(
212212
arguments,
213213
"SELECT table_catalog, table_schema, table_name, ordinal_position, column_name,"
214-
+ " data_type FROM %1$s.COLUMNS%2$s",
214+
+ " data_type, is_nullable, column_default, character_maximum_length,"
215+
+ " numeric_precision, numeric_scale, datetime_precision, comment FROM %1$s.COLUMNS%2$s",
215216
MetadataView.COLUMNS),
216217
ColumnsFormat.IS_ZIP_ENTRY_NAME,
217218
IS,

dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/snowflake/SnowflakeMetadataConnectorTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import javax.annotation.Nonnull;
3737
import org.junit.Assert;
3838
import org.junit.Assume;
39-
import org.junit.Ignore;
4039
import org.junit.Test;
4140
import org.junit.runner.RunWith;
4241
import org.junit.runners.JUnit4;
@@ -138,7 +137,6 @@ public void testDatabaseNameFailure() {
138137
Assert.assertTrue(exception.getMessage().startsWith("Database name not found"));
139138
}
140139

141-
@Ignore
142140
@Test
143141
public void connector_generatesExpectedSql() throws IOException {
144142
Map<String, String> actualSqls = collectSqlStatements();

dumper/app/src/test/resources/connector/snowflake/jdbc-tasks-sql.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ schemata-au.csv: "SELECT catalog_name, schema_name FROM SNOWFLAKE.ACCOUNT_USAGE.
44
schemata.csv: "SELECT catalog_name, schema_name FROM INFORMATION_SCHEMA.SCHEMATA"
55
tables-au.csv: "SELECT table_catalog, table_schema, table_name, table_type, row_count, bytes, clustering_key FROM SNOWFLAKE.ACCOUNT_USAGE.TABLES WHERE DELETED IS NULL"
66
tables.csv: "SELECT table_catalog, table_schema, table_name, table_type, row_count, bytes, clustering_key FROM INFORMATION_SCHEMA.TABLES"
7-
external_tables.csv: "SELECT table_catalog, table_schema, table_name, location, file_format_name, file_format_type FROM INFORMATION_SCHEMA.EXTERNAL_TABLES WHERE table_schema != 'INFORMATION_SCHEMA'"
8-
columns-au.csv: "SELECT table_catalog, table_schema, table_name, ordinal_position, column_name, data_type FROM SNOWFLAKE.ACCOUNT_USAGE.COLUMNS WHERE DELETED IS NULL"
9-
columns.csv: "SELECT table_catalog, table_schema, table_name, ordinal_position, column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS"
7+
columns-au.csv: "SELECT table_catalog, table_schema, table_name, ordinal_position, column_name, data_type, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale, datetime_precision, comment FROM SNOWFLAKE.ACCOUNT_USAGE.COLUMNS WHERE DELETED IS NULL"
8+
columns.csv: "SELECT table_catalog, table_schema, table_name, ordinal_position, column_name, data_type, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale, datetime_precision, comment FROM INFORMATION_SCHEMA.COLUMNS"
109
views-au.csv: "SELECT table_catalog, table_schema, table_name, view_definition FROM SNOWFLAKE.ACCOUNT_USAGE.VIEWS WHERE DELETED IS NULL"
1110
views.csv: "SELECT table_catalog, table_schema, table_name, view_definition FROM INFORMATION_SCHEMA.VIEWS"
1211
functions-au.csv: "SELECT function_schema, function_name, data_type, argument_signature FROM SNOWFLAKE.ACCOUNT_USAGE.FUNCTIONS WHERE DELETED IS NULL"
1312
functions.csv: "SELECT function_schema, function_name, data_type, argument_signature FROM INFORMATION_SCHEMA.FUNCTIONS"
13+
external_tables.csv: "SHOW EXTERNAL TABLES"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ enum Header {
7070
TableName,
7171
OrdinalPosition,
7272
ColumnName,
73-
DataType
73+
DataType,
74+
IsNullable,
75+
ColumnDefault,
76+
CharacterMaximumLength,
77+
NumericPrecision,
78+
NumericScale,
79+
DatetimePrecision,
80+
Comment
7481
}
7582
}
7683

0 commit comments

Comments
 (0)