用f创建Dataframe#

wgxvkvu9  于 2021-05-29  发布在  Spark
关注(0)|答案(1)|浏览(344)

我试图用f#创建一个简单的sparkDataframe,因为它在spark.net测试中使用

let schema =
    StructType (
        [|
            StructField("Name", new StringType())
            StructField("Age", new IntegerType())
            StructField("Date", new DateType())
        |] )

let rows: obj[][] =
    [|
        [| "Alice"; 20; new Date(2020, 1, 1) |]
    |]

session.CreateDataFrame(rows |> Array.map GenericRow, schema).Show(10, 0, false)

最终,此代码失败(与使用.net集合的代码完全相同)

JVM method execution failed: Nonstatic method 'createDataFrame' failed for class '7' when called with 2 arguments ([Index=1, Type=GenericRow[], Value=Microsoft.Spark.Sql.GenericRow[]], [Index=2, Type=JvmObjectReference, Value=8], )
pexxcrt2

pexxcrt21#

以上这些对我来说很好

+-----+---+----------+
|Name |Age|Date      |
+-----+---+----------+
|Alice|20 |2020-01-01|
+-----+---+----------+

请检查你使用的Spark<2.4.5我用2.4.1做了测试
java>1.8版
同时检查是否提供了所有参数
$spark_home/bin/spark submit--类org.apache.spark.deploy.dotnet.dotnetrunner--主本地bin/debug/netcoreapp3.1/microsoft-spark-2.4.x-0.11.0.jar dotnet bin/debug/netcoreapp3.1/yourlibrary.dll

相关问题