Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ class SQLTransformer @Since("1.6.0") (@Since("1.6.0") override val uid: String)
val tableName = Identifiable.randomUID(uid)
dataset.createOrReplaceTempView(tableName)
val realStatement = $(statement).replace(tableIdentifier, tableName)
dataset.sparkSession.sql(realStatement)
val result = dataset.sparkSession.sql(realStatement)
dataset.sparkSession.catalog.dropTempView(tableName)
result
}

@Since("1.6.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SQLTransformerSuite
assert(result.schema.toString == resultSchema.toString)
assert(resultSchema == expected.schema)
assert(result.collect().toSeq == expected.collect().toSeq)
assert(original.sparkSession.catalog.listTables().count() == 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does assert(original.sparkSession.catalog.listTables().isEmpty) work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I believe isEmpty is only currently defined for an RDD, not a Dataset, you could do collect().isEmpty but that would be equally verbose I think.

}

test("read/write") {
Expand Down