我在使用Playframework中运行测试时遇到 进化问题未知数据类型:“ JSONB”
我的H2DbConnector看起来像这样:
import entities.StubData._
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import play.api.db.DBApi
import play.api.db.evolutions.Evolutions
import play.api.inject.guice.GuiceApplicationBuilder
trait H2DbConnector extends FunSuite with BeforeAndAfterAll {
val appBuilder = new GuiceApplicationBuilder()
.configure(configuration)
val injector = appBuilder.injector
lazy val databaseApi = injector.instanceOf[DBApi]
override def beforeAll() = {
Evolutions.applyEvolutions(databaseApi.database("default"))
}
override def afterAll() = {
Evolutions.cleanupEvolutions(databaseApi.database("default"))
}
}
Run Code Online (Sandbox Code Playgroud)
在application.test.conf中
slick.dbs.default.driver = "slick.driver.H2Driver$"
slick.dbs.default.db.driver = "org.h2.Driver"
slick.dbs.default.db.url = "jdbc:h2:mem:play;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=FALSE"
Run Code Online (Sandbox Code Playgroud)
我在Evolutions 2.sql文件中有一条问题线
ALTER TABLE "Messages" ADD COLUMN "metaJson" JSONB NULL; …
Run Code Online (Sandbox Code Playgroud) 我在删除元组数据集中的重复行时遇到麻烦 Dataset[(LeftDs, RightDs)]
试图像这样连接两个数据集:
val comparableDs = leftDs.joinWith(
rightDs,
fuzzyMatch(leftDs.col("name"), rightDs.col("officialName"))
)
Run Code Online (Sandbox Code Playgroud)
我想删除两个字段的重复项:
val resultDs = comparableDs.dropDuplicates("_1.name", "_2.officialName")
Run Code Online (Sandbox Code Playgroud)
但是得到这个错误:
Cannot resolve column name "_1.name" among (_1, _2);
这是以下内容的架构comparableDs
:
root
|-- _1: struct (nullable = false)
| |-- id: string (nullable = true)
| |-- name: string (nullable = true)
|-- _2: struct (nullable = false)
| |-- id: string (nullable = true)
| |-- category: string (nullable = true)
| |-- officialName: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
如何dropDuplicates …