如何将文件从桌面加载到 Hive
How to load a file from desktop into Hive
我正在使用我们用来与 HIVE 交互的内部 HIVE 终端控制台。我有一个包含帐号列表的 csv。我需要从我们数据库中的 table 中的那些帐号中提取数据。通常我只会说 where acct_num = XXXXXX 但我有一个 800 的列表需要提取。我已经尝试创建一个 table 然后使用 infile 加载数据但似乎无法掌握它。该文件在我的桌面上,但我使用 winscp 将 csv 文件移动到我的 "directory",我在其中创建 tables。
这是我正在使用的代码。帐号为15位数字,全部为数字。我不确定将其保存为 .csv 是否会混淆数字的格式,但我尝试使用 create table 作为 sting 和 int.
drop table acorn_data.cj_test_accounts_load;
create table acorn_data.cj_test_accounts_load
(acct_num int);
load data inpath
'/axp/buanalytics/csgsn/dev/Akhilesh/acorn_data/Test_accounts.csv'
into table acorn_data.cj_test_accounts_load
如果可能的话,我希望至少将此文件加载到一个临时 table 中,以便我可以将其加入我们数据库中的 table。
试试下面的代码
create table acorn_data.cj_test_accounts_load
(acct_num int) row format delimited fields terminated by ',';
LOAD DATA LOCAL INPATH '/cuddle/prod/sales.csv' INTO TABLE acorn_data.cj_test_accounts_load;
取决于此 "desktop" 的位置以及您使用的确切网络工具(色调?- 我认为您不能)。
然后您有 2 个选项可以将数据从文件加载到配置单元中:
(1) 本地 - 来自 hdfs 所在的 unix 框(很可能不是你的 "desktop")
(2) 非本地 - 来自 hdfs(例如,您可以与 webhdf 交互 - 直接将文件转储到那里:https://hadoop.apache.org/docs/r1.0.4/webhdfs.html,或者从提到的 unix 框中执行 hadoop fs -put
)
我正在使用我们用来与 HIVE 交互的内部 HIVE 终端控制台。我有一个包含帐号列表的 csv。我需要从我们数据库中的 table 中的那些帐号中提取数据。通常我只会说 where acct_num = XXXXXX 但我有一个 800 的列表需要提取。我已经尝试创建一个 table 然后使用 infile 加载数据但似乎无法掌握它。该文件在我的桌面上,但我使用 winscp 将 csv 文件移动到我的 "directory",我在其中创建 tables。
这是我正在使用的代码。帐号为15位数字,全部为数字。我不确定将其保存为 .csv 是否会混淆数字的格式,但我尝试使用 create table 作为 sting 和 int.
drop table acorn_data.cj_test_accounts_load;
create table acorn_data.cj_test_accounts_load
(acct_num int);
load data inpath
'/axp/buanalytics/csgsn/dev/Akhilesh/acorn_data/Test_accounts.csv'
into table acorn_data.cj_test_accounts_load
如果可能的话,我希望至少将此文件加载到一个临时 table 中,以便我可以将其加入我们数据库中的 table。
试试下面的代码
create table acorn_data.cj_test_accounts_load
(acct_num int) row format delimited fields terminated by ',';
LOAD DATA LOCAL INPATH '/cuddle/prod/sales.csv' INTO TABLE acorn_data.cj_test_accounts_load;
取决于此 "desktop" 的位置以及您使用的确切网络工具(色调?- 我认为您不能)。
然后您有 2 个选项可以将数据从文件加载到配置单元中:
(1) 本地 - 来自 hdfs 所在的 unix 框(很可能不是你的 "desktop")
(2) 非本地 - 来自 hdfs(例如,您可以与 webhdf 交互 - 直接将文件转储到那里:https://hadoop.apache.org/docs/r1.0.4/webhdfs.html,或者从提到的 unix 框中执行 hadoop fs -put
)