【问题标题】:AZURE HD INSIGHT (Cluster) Import CSV file to storage: Creating a tableAZURE HDINSIGHT(集群)将 CSV 文件导入存储:创建表
【发布时间】:2019-07-31 18:51:06
【问题描述】:

我对编码完全陌生 - 我知道基础知识,所以我在这个项目上大发雷霆。

我正在尝试最终将我的 Hadoop 集群链接到 Tableau,我的大部分项目都将集中在 Tableau 上。 我正在关注this guy

但是,他没有具体解释如何将 CSV 文件链接到集群。经过一番研究,我发现我需要通过集群导入数据。 我已设法通过 CloudXplorer 导入 CSV 文件。现在我只需要创建表格。

我没有通过 Ambari(创建一个表,错误是获取数据库时出错,而且它从一开始就没有真正上传我的文件)或 Zeppelin。

我在 Zeppelin 上的代码如下:

%livy2.spark
 //The above magic instructs Zeppelin to use the Livy Scala interpreter

 // Create an RDD using the default Spark context, sc
 val SearchText = sc.textFile("wasb://test'myname'1@.blob.core.windows.net/sample/stopandsearch.csv")

 // Define a schema
 case class Search(Type: String, date: String, time: String, LATITUDE: String, LONGITUDE: String, Gender: String, Age_Range: String, Self_defined_Eth: String, Officer_defined_Eth: String, Legislation: String, Obj_Of_Search: String, Outcome: String)

 // Map the values in the .csv file to the schema
 val Search = SearchText.map(s => s.split(",")).map(
     s => Search(s(6), 
             s(1),
             s(7),
             s(3),
             s(6),
             s(7),
             s(3),
             s(7),
             s(12),
             s(12),
             s(12)
     )
 ).toDF()
 Search.registerAsTable("Search")
 Search.saveAsTable("Search")
<console>:30: error: recursive value Search needs type
            s => Search(s(6),
                 ^
<console>:42: error: value toDF is not a member of org.apache.spark.rdd.RDD[U]
possible cause: maybe a semicolon is missing before `value toDF'?
        ).toDF()
          ^

请有任何建议。围绕这个的任何快捷方式,我只需要将数据插入到漂亮的表中! :)

提前致谢。

PS 我不知道如何获取到 wasb 的链接?容器中 csv 文件的 Http link

【问题讨论】:

    标签: azure bigdata apache-zeppelin azure-hdinsight


    【解决方案1】:

    我觉得这条路不正确。

    wasb://test'myname'1@.blob.core.windows.net/sample/stopandsearch.csv"
    

    应该是

    wasb://test'myname'1@<storageaccount>.blob.core.windows.net/sample/stopandsearch.csv"
    

    您缺少 storageaccount,我假设 test'myname'1 是容器名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多