@@ -42,7 +42,8 @@ class CatalogV2UtilSuite extends SparkFunSuite {
4242 when(table.properties()).thenReturn(util.Map .of(
4343 " persisted" , " stored" , TableCatalog .PROP_EXTERNAL , " true" ))
4444
45- assert(CatalogV2Util .tablePropertiesForDisplay(table) === Map (" persisted" -> " stored" ))
45+ assert(CatalogV2Util .tablePropertiesForDisplay(
46+ table.properties(), table.displayProperties(), new SQLConf ) === Map (" persisted" -> " stored" ))
4647 }
4748
4849 test(" tablePropertiesForDisplay ignores reserved display keys and preserves stored values" ) {
@@ -55,11 +56,28 @@ class CatalogV2UtilSuite extends SparkFunSuite {
5556 .withDisplayProperties(displayProperties)
5657 .build(), " table" )
5758
58- assert(CatalogV2Util .tablePropertiesForDisplay(table) ===
59+ assert(CatalogV2Util .tablePropertiesForDisplay(
60+ table.properties(), table.displayProperties(), new SQLConf ) ===
5961 Map (" persisted" -> " stored" , " catalog-label" -> " catalog-value" ))
6062 assert(table.properties() === util.Map .of(" persisted" , " stored" ))
6163 }
6264
65+ test(" tablePropertiesForDisplay redacts stored and display-only values" ) {
66+ val conf = new SQLConf
67+ conf.setConf(SQLConf .SQL_OPTIONS_REDACTION_PATTERN , " (?i)catalog-label" .r)
68+ val properties = util.Map .of(" password" , " stored-password" , " persisted" , " stored" )
69+ val displayProperties = util.Map .of(
70+ " catalog-label" , " catalog-value" , " secret" , " display-secret" , " persisted" , " display-value" )
71+
72+ assert(CatalogV2Util .tablePropertiesForDisplay(properties, displayProperties, conf) === Map (
73+ " password" -> " *********(redacted)" ,
74+ " catalog-label" -> " *********(redacted)" ,
75+ " secret" -> " *********(redacted)" ,
76+ " persisted" -> " stored" ))
77+ assert(properties.get(" password" ) === " stored-password" )
78+ assert(displayProperties.get(" secret" ) === " display-secret" )
79+ }
80+
6381 private def catalogWithStateOptions (keys : java.util.Set [String ]): TableCatalog = {
6482 val catalog = mock(classOf [TableCatalog ])
6583 when(catalog.tableStateOptionKeys()).thenReturn(keys)
0 commit comments