【问题标题】:How to insert data from Excel into a temp table in Spark SQL如何将 Excel 中的数据插入 Spark SQL 中的临时表中
【发布时间】:2020-03-16 08:22:54
【问题描述】:

我在 Excel 电子表格中有一个包含大约 12,000 个用户 ID 的列表,我想将它们插入 SQL 中的临时表中。我知道在 SQL Server 等中有很多不同的方法可以做到这一点,但我在 Zeppelin /Apache Spark SQL 中工作,我不熟悉快速的方法。

excel数据如下:

userid
014
020
055
101
151
175
...
12000

我试图做这样的事情:

CREATE TABLE user.temp_excel_import (userid string)

...

INSERT INTO TABLE user.temp_excel_import
VALUES
('014'),
('020'),
('055'),...

这是可以在 Zeppelin 中有效完成的事情,还是在粘贴到 Zeppelin 之前我需要在 Excel 中进行一些操作?

【问题讨论】:

标签: sql apache-spark apache-zeppelin


【解决方案1】:

以 CSV 格式读取您的文件。

当您拥有 DataFrame 时,请使用 createOrReplaceTempView,您将能够查询它。

Zeppelin 中带有随机 DataFrame 的示例:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-02
    • 2016-07-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-21
    相关资源
    最近更新 更多