viirya commented on code in PR #16: URL: https://github.com/apache/spark-connect-swift/pull/16#discussion_r1994368629
########## Tests/SparkConnectTests/DataFrameTests.swift: ########## @@ -68,6 +68,76 @@ struct DataFrameTests { await spark.stop() } + @Test + func selectNone() async throws { + let spark = try await SparkSession.builder.getOrCreate() + let emptySchema = try await spark.range(1).select().schema() + #expect(emptySchema == #"{"struct":{}}"#) + await spark.stop() + } + + @Test + func select() async throws { + let spark = try await SparkSession.builder.getOrCreate() + let schema = try await spark.range(1).select("id").schema() + #expect( + schema + == #"{"struct":{"fields":[{"name":"id","dataType":{"long":{}}}]}}"# + ) + await spark.stop() + } + + @Test + func selectMultipleColumns() async throws { + let spark = try await SparkSession.builder.getOrCreate() + let schema = try await spark.sql("SELECT * FROM VALUES (1, 2)").select("col2", "col1").schema() + #expect( + schema + == #"{"struct":{"fields":[{"name":"col2","dataType":{"integer":{}}},{"name":"col1","dataType":{"integer":{}}}]}}"# + ) + await spark.stop() + } + + @Test + func selectInvalidColumn() async throws { + let spark = try await SparkSession.builder.getOrCreate() + try await #require(throws: Error.self) { + let _ = try await spark.range(1).select("invalid").schema() + } + await spark.stop() + } + + @Test + func limit() async throws { + let spark = try await SparkSession.builder.getOrCreate() + #expect(try await spark.range(10).limit(0).count() == 0) + #expect(try await spark.range(10).limit(1).count() == 1) + #expect(try await spark.range(10).limit(2).count() == 2) + await spark.stop() + } + + @Test + func isEmpty() async throws { + let spark = try await SparkSession.builder.getOrCreate() + #expect(try await spark.range(0).isEmpty()) + #expect(!(try await spark.range(1).isEmpty())) + await spark.stop() + } + + @Test + func sort() async throws { + let spark = try await SparkSession.builder.getOrCreate() + #expect(try await spark.range(10).sort("id").count() == 10) Review Comment: Do we need to check if the return data is actually sorted? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org