AnalysisException: u"cannot resolve 'name' given input columns: [ list] in sqlContext in spark

前端 未结 3 906
庸人自扰
庸人自扰 2021-02-19 08:30

I tried a simple example like:

data = sqlContext.read.format(\"csv\").option(\"header\", \"true\").option(\"inferSchema\", \"true\").load(\"/databricks-datasets/         


        
3条回答
  •  甜味超标
    2021-02-19 09:28

    As there were tabs in my input file, removing the tabs or spaces in the header helped display the answer.
    
    My example:
    
    saledf = spark.read.csv("SalesLTProduct.txt", header=True, inferSchema= True, sep='\t')
    
    
    saledf.printSchema()
    
    root
    |-- ProductID: string (nullable = true)
    |-- Name: string (nullable = true)
    |-- ProductNumber: string (nullable = true)
    
    saledf.describe('ProductNumber').show()
    
     +-------+-------------+
     |summary|ProductNumber|
     +-------+-------------+
     |  count|          295|
     |   mean|         null|
     | stddev|         null|
     |    min|      BB-7421|
     |    max|      WB-H098|
     +-------+-------------+
    

提交回复
热议问题