Skip to content

Commit

Permalink
Fixed typo errors and readme exception descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpulidos committed Nov 14, 2023
1 parent e02db75 commit 39c12c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ You cannot append the following DataFrame which contains the required columns, b
+----+----+----+
```

Here's the error you'll get when you attempt this write: ""
Here's the error you'll get when you attempt this write: "The column col5 is not part of the current Delta table. If you want to add the column to the table, you must set the optionalCols parameter"

You also cannot append the following DataFrame which is missing one of the required columns.

Expand All @@ -299,7 +299,7 @@ You also cannot append the following DataFrame which is missing one of the requi
+----+----+
```

Here's the error you'll get: ""
Here's the error you'll get: "The base Delta table has these columns List(col1, col4), but these columns are required List(col1, col2)"


### Latest Version of Delta Table
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/mrpowers/jodie/DeltaHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ object DeltaHelpers {
for (requiredColumn <- requiredCols) {
if (!appendDataColumns.contains(requiredColumn)) {
throw new IllegalArgumentException(
s"The base Delta table has these columns $appendDataColumns, but these columns are required $requiredCols"
s"The base Delta table has these columns ${appendDataColumns.mkString("List(", ", ", ")")}, but these columns are required $requiredCols"
)
}
}
Expand All @@ -389,7 +389,7 @@ object DeltaHelpers {
}
}

val details = deltaTable.toDF.select("location").collect()(0).getString(0)
val details = deltaTable.detail().select("location").collect().head.getString(0)

// Write the appendDF to the Delta table
appendDF.write.format("delta")
Expand Down
20 changes: 11 additions & 9 deletions src/test/scala/mrpowers/jodie/DeltaHelperSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,18 @@ class DeltaHelperSpec
)
.toDF("col1", "col2", "col4")

DeltaHelpers.validateAppend(deltaTable, appendDf, List("col1", "col2"),
List("col4" ))
DeltaHelpers.validateAppend(deltaTable, appendDf, List("col1", "col2"), List("col4"))

val expected = Seq(
(1, "a", "A", None),
(2, "b", "B", None),
(3, "c", None, "cat"),
(4, "d", None, "dog"),
).toDF("col1", "col2", "col3", "col4")
(1, "a", "A", null),
(2, "b", "B", null),
(3, "c", null, "cat"),
(4, "d", null, "dog"),
)
.toDF("col1", "col2", "col3", "col4")

val result = DeltaTable.forPath(path)

assertSmallDataFrameEquality(
result.toDF,
expected,
Expand Down Expand Up @@ -507,7 +509,7 @@ class DeltaHelperSpec
List("col4") )
}.getMessage

assert(exceptionMessage.contains("but these columns are required"))
assert(exceptionMessage.contains("The column col5 is not part of the current Delta table. If you want to add the column to the table, you must set the optionalCols parameter"))
}
it("should fail to append dataframes with missing required columns"){
val path = (os.pwd / "tmp" / "delta-lake-validate-missing-required-cols").toString()
Expand Down Expand Up @@ -537,7 +539,7 @@ class DeltaHelperSpec
List("col4"))
}.getMessage

assert(exceptionMessage.contains("If you want to add the column to the table, you must set the optionalCols parameter"))
assert(exceptionMessage.contains("The base Delta table has these columns List(col1, col4), but these columns are required List(col1, col2)"))

}
}
Expand Down

0 comments on commit 39c12c6

Please sign in to comment.