Skip to content

Commit

Permalink
SNOW-1001928: Fix flaky test DatabaseMetaDataLatestIT.testHandlingSpe…
Browse files Browse the repository at this point in the history
…cialChars
  • Loading branch information
sfc-gh-dprzybysz committed Jan 8, 2024
1 parent e1ed9e6 commit 3ec871d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,13 @@ public void testHandlingSpecialChars() throws SQLException {
"create or replace table \"TEST\\1\\_1\" (\"C%1\" integer,\"C\\1\\\\11\" integer)");
statement.execute("INSERT INTO \"TEST\\1\\_1\" (\"C%1\",\"C\\1\\\\11\") VALUES (0,0)");
// test getColumns with escaped special characters in schema and table name
statement.execute("create or replace schema \"SPECIAL%_\\SCHEMA\"");
String specialSchemaSuffix = SnowflakeUtil.randomAlphaNumeric(5);
String specialSchema = "\"SPECIAL%_\\SCHEMA" + specialSchemaSuffix + "\"";
statement.execute("create or replace schema " + specialSchema);
statement.execute(
"create or replace table \"SPECIAL%_\\SCHEMA\".\"TEST_1_1\" ( \"RNUM\" integer not null, "
"create or replace table "
+ specialSchema
+ ".\"TEST_1_1\" ( \"RNUM\" integer not null, "
+ "\"C21\" integer,"
+ "\"C11\" integer,\"C%1\" integer,\"C\\1\\\\11\" integer , primary key (\"RNUM\"))");
statement.execute(
Expand All @@ -940,7 +944,8 @@ public void testHandlingSpecialChars() throws SQLException {
assertFalse(resultSet.next());

String escapedTable2 = "TEST" + escapeChar + "_1" + escapeChar + "_1";
String escapedSchema = "SPECIAL%" + escapeChar + "_" + escapeChar + "\\SCHEMA";
String escapedSchema =
"SPECIAL%" + escapeChar + "_" + escapeChar + "\\SCHEMA" + specialSchemaSuffix;
resultSet = metaData.getColumns(database, escapedSchema, escapedTable2, null);
assertTrue(resultSet.next());
assertEquals("RNUM", resultSet.getString("COLUMN_NAME"));
Expand Down Expand Up @@ -976,6 +981,8 @@ public void testHandlingSpecialChars() throws SQLException {
resultSet = metaData.getColumns(database, schema, "special" + escapeChar + "%table", null);
assertTrue(resultSet.next());
assertEquals("COLA", resultSet.getString("COLUMN_NAME"));

statement.execute("drop schema " + specialSchema);
}

@Test
Expand Down

0 comments on commit 3ec871d

Please sign in to comment.