File tree Expand file tree Collapse file tree
main/scala/za/co/absa/pramen/core/utils
test/scala/za/co/absa/pramen/core/tests/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,9 +125,9 @@ object SparkUtils {
125125
126126 val fieldsToSelect = df.schema.fields.map(field => {
127127 val srcName = field.name
128- val trgName = replaceSpecialChars(if (hasTablePrefix) removeTablePrefix(srcName) else srcName)
128+ val trgName = replaceSpecialChars(if (hasTablePrefix) removeTablePrefix(srcName.trim ) else srcName.trim )
129129 if (srcName != trgName) {
130- log.info(s " Renamed column: $srcName -> $trgName" )
130+ log.info(s " Renamed column: ' $srcName' -> ' $trgName'' " )
131131 col(s " ` $srcName` " ).as(trgName)
132132 } else {
133133 col(s " ` $srcName` " )
Original file line number Diff line number Diff line change @@ -105,19 +105,19 @@ class SparkUtilsSuite extends AnyWordSpec with SparkTestBase with TempDirFixture
105105 }
106106
107107 " sanitizeDfColumns()" should {
108- " rename spaces of input dataframe columns" in {
108+ " trim leading and trailing spaces, and rename spaces in the middle of input dataframe columns" in {
109109 val expected =
110110 """ [ {
111111 | "a_a" : "A",
112- | "_b_ " : 1,
112+ | "b " : 1,
113113 | "c" : 4
114114 |}, {
115115 | "a_a" : "B",
116- | "_b_ " : 2,
116+ | "b " : 2,
117117 | "c" : 5
118118 |}, {
119119 | "a_a" : "C",
120- | "_b_ " : 3,
120+ | "b " : 3,
121121 | "c" : 6
122122 |} ]"""
123123
You can’t perform that action at this time.
0 commit comments