【发布时间】:2021-03-21 06:46:45
【问题描述】:
我对 Scala/Spark 还很陌生,希望你们能帮助我。我想获取在 hdfs 目录中某个时间戳之后创建的文件,以便在 Zeppelin 中进行一些监视。因此我需要一个包含文件名、文件大小和修改日期的列。
我发现这对我来说可以获取我需要的所有信息:
val fs = FileSystem.get(new Configuration())
val dir: String = "some/hdfs/path"
val input_files = fs.listStatus(new Path(dir)).filter(_.getModificationTime> timeInEpoch)
结果我想在 spark 中创建一个 DataFrame,每个文件都有一行及其信息(或至少是上面提到的信息)
val data = sc.parallelize(input_files)
val dfFromData2 = spark.createDataFrame(data).toDF()
如果我以这种方式尝试,我会得到以下响应:
309: error: overloaded method value createDataFrame with alternatives:
[A <: Product](data: Seq[A])(implicit evidence$3: reflect.runtime.universe.TypeTag[A])org.apache.spark.sql.DataFrame <and>
[A <: Product](rdd: org.apache.spark.rdd.RDD[A])(implicit evidence$2: reflect.runtime.universe.TypeTag[A])org.apache.spark.sql.DataFrame
cannot be applied to (org.apache.spark.rdd.RDD[org.apache.hadoop.fs.FileStatus])
val dfFromData2 = spark.createDataFrame(data).toDF()
希望你能帮帮我:)
问候
【问题讨论】:
标签: scala apache-spark hdfs apache-zeppelin