在spark 2.2.0下,我使用columnSimilarities()时遇到了错误。
这是重现的代码。
from pyspark.mllib.linalg.distributed import RowMatrix
rdd = sc.parallelize([[1.0,2.0,1.0],[1.0,5.0,1.0],[1.0,2.0,1.0],[4.0,2.0,4.0]])
mat = RowMatrix(rdd)
sim = mat.columnSimilarities(0.1)
sim.entries.collect()
错误是这样的(已转移。太长。完整日志为here)。
17/08/13 10:15:19 ERROR Schema: Failed initialising database.
Unable to open a test connection to the given database. JDBC url = jdbc:derby:;databaseName=metastore_db;create=true, username = APP. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@3234df5e, see the next exception for details.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
此代码效果很好。
from pyspark.mllib.linalg.distributed import IndexedRow, IndexedRowMatrix
rdd = sc.parallelize([IndexedRow(0, [1.0,2.0,1.0]),
IndexedRow(1, [1.0,5.0,1.0]),
IndexedRow(2, [1.0,2.0,1.0]),
IndexedRow(3, [4.0,2.0,4.0])])
mat = IndexedRowMatrix(rdd).toRowMatrix()
sim = mat.columnSimilarities(0.1)
sim.entries.collect()
这是Spark的错误吗?
答案 0 :(得分:1)
这是jdbc
连接问题 - 而不是columnSimilarities
- 或一般的MLlib。
您可能需要做一些工作才能运行derby
连接。这是一个起点:https://stackoverflow.com/a/40547664/1056563