Я пытаюсь загрузить данные CSV в таблицу Hive, используя SparkSession.Я хочу пропустить данные заголовка при загрузке в таблицу кустов и установка tblproperties ("skip.header.line.count" = "1") также не работает.
Я использую следующий код.
import java.io.File
import org.apache.spark.sql.{SparkSession,Row,SaveMode}
case class Record(key: Int, value: String)
val warehouseLocation=new File("spark-warehouse").getAbsolutePath
val spark=SparkSession.builder().appName("Apache Spark Book Crossing Analysis").config("spark.sql.warehouse.dir",warehouseLocation).enableHiveSupport().getOrCreate()
import spark.implicits._
import spark.sql
//sql("set hive.vectorized.execution.enabled=false")
sql("drop table if exists BookTemp")
sql ("create table BookTemp(ISBN int,BookTitle String,BookAuthor String ,YearOfPublication int,Publisher String,ImageURLS String,ImageURLM String,ImageURLL String)row format delimited fields terminated by ';' ")
sql("alter table BookTemp set TBLPROPERTIES("skip.header.line.count"="1")")
sql("load data local inpath 'BX-Books.csv' into table BookTemp")
sql("select * from BookTemp limit 5").show
Ошибка в консоле:
res55: org.apache.spark.sql.DataFrame = []
<console>:1: error: ')' expected but '.' found.
sql("alter table BookTemp set TBLPROPERTIES("skip.header.line.count"="1")")
2019-02-20 22:48:09 WARN LazyStruct:151 - Extra bytes detected at the end of the row! Ignoring similar problems.
+----+--------------------+--------------------+-----------------+--------------------+--------------------+--------------------+--------------------+
|ISBN| BookTitle| BookAuthor|YearOfPublication| Publisher| ImageURLS| ImageURLM| ImageURLL|
+----+--------------------+--------------------+-----------------+--------------------+--------------------+--------------------+--------------------+
|null| "Book-Title"| "Book-Author"| null| "Publisher"| "Image-URL-S"| "Image-URL-M"| "Image-URL-L"|
|null|"Classical Mythol...|"Mark P. O. Morford"| null|"Oxford Universit...|"http://images.am...|"http://images.am...|"http://images.am...|
|null| "Clara Callan"|"Richard Bruce Wr...| null|"HarperFlamingo C...|"http://images.am...|"http://images.am...|"http://images.am...|
|null|"Decision in Norm...| "Carlo D'Este"| null| "HarperPerennial"|"http://images.am...|"http://images.am...|"http://images.am...|
|null|"Flu: The Story o...| "Gina Bari Kolata"| null|"Farrar Straus Gi...|"http://images.am...|"http://images.am...|"http://images.am...|
+----+--------------------+--------------------+-----------------+--------------------+--------------------+--------------------+--------------------+
only showing top 5 rows
Как показано в результате, я хочу пропустить первую строку данных