在 Scala/Spark 中,我正在尝试执行以下操作:
val portCalls_Ports =
portCalls.join(ports, portCalls("port_id") === ports("id"), "inner")
但是我收到以下错误:
Exception in thread "main" org.apache.spark.sql.AnalysisException:
binary type expression port_id cannot be used in join conditions;
确实这是二进制类型:
root
|-- id: binary (nullable = false)
|-- port_id: binary (nullable = false)
.
.
.
+--------------------+--------------------+
| id| port_id|
+--------------------+--------------------+
|[FB 89 A0 FF AA 0...|[B2 B2 84 B9 52 2...|
原样ports("id")
。
我正在使用以下库:
scalaVersion := "2.11.11"
libraryDependencies ++= Seq(
// Spark dependencies
"org.apache.spark" %% "spark-hive" % "1.6.2",
"org.apache.spark" %% "spark-mllib" % "1.6.2",
// Third-party libraries
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
"net.sf.jopt-simple" % "jopt-simple" % "5.0.3"
)
请注意,我使用 JDBC 来读取数据库表。
解决此问题的最佳方法是什么?