>我需要读取一个包含 6 列的 CSV 文件,分别类型为整数、字符串、字符串、字符串、整数、整数。我想使用 Apache Flinks 的ExecutionEnvironment.readCsvFile
方法,但我不断收到打字和参数错误。我目前有:
val env = ExecutionEnvironment.getExecutionEnvironment
val lines = env.readCsvFile[Integer, String, String, String, Integer, Integer]("C:/Users/zoldham/IdeaProjects/flinkpoc/Data/gun-violence-data_01-2013_03-2018.csv")
并得到
Error:(43, 32) wrong number of type parameters for method readCsvFile: [T](filePath: String, lineDelimiter: String, fieldDelimiter: String, quoteCharacter: Character, ignoreFirstLine: Boolean, ignoreComments: String, lenient: Boolean, includedFields: Array[Int], pojoFields: Array[String])(implicit evidence$1: scala.reflect.ClassTag[T], implicit evidence$2: org.apache.flink.api.common.typeinfo.TypeInformation[T])org.apache.flink.api.scala.DataSet[T]
请注意,这些是第 42 行和第 43 行。正确的语法会是什么样子?我一直找不到任何例子来用作它应该是什么样子的基线。谢谢!
您需要指定元组或案例类作为输入类型。请尝试以下操作:
val env = ExecutionEnvironment.getExecutionEnvironment
val lines = env.readCsvFile[(Integer, String, String, String, Integer, Integer)]("C:/Users/zoldham/IdeaProjects/flinkpoc/Data/gun-violence-data_01-2013_03-2018.csv")