通过hive 加载本地文件或者hdfs上的文件到表里

Time taken: 0.083 seconds
hive> select  * from  stu2;
OK
NULL zhangshan 20
NULL wangwu   NULL
NULL xiaolu   NULL
Time taken: 0.419 seconds, Fetched: 3 row(s)
hive> create  table  stu2( id int , name  String , age  int ) 
    > row format delimited 
    > fields terminated by ',' ;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Table stu2 already exists)
hive> create  table  stu3( id int , name  String , age  int ) 
    > row format delimited 
    > fields terminated by ',' ;
OK
Time taken: 0.073 seconds
hive> select  *  from  stu3 ;
OK
NULL zhangshan NULL
NULL wangwu   NULL
NULL xiaolu   NULL
Time taken: 0.069 seconds, Fetched: 3 row(s)
hive> load data local input '/home/wangshumin/stu1' into  table stu3
    > ;
MismatchedTokenException(26!=136)
at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:617)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
at org.apache.hadoop.hive.ql.parse.HiveParser.loadStatement(HiveParser.java:1794)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1605)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1109)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:396)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:308)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1122)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1170)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1059)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1049)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:736)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 1:16 mismatched input 'input' expecting INPATH near 'local' in load statement
hive> load data local inpath '/home/wangshumin/stu1' into  table stu3
    > ;
Loading data to table hive2_db1.stu3
Table hive2_db1.stu3 stats: [numFiles=2, totalSize=104]
OK
Time taken: 0.58 seconds
hive> select  * from  stu3;
OK
NULL zhangshan 20
NULL wangwu   NULL
NULL xiaolu   NULL
NULL zhangshan NULL
NULL wangwu   NULL
NULL xiaolu   NULL
Time taken: 0.068 seconds, Fetched: 6 row(s)
hive> load data  inpath "/user/hive/warehouse/hive2_db1.db/stu2/stu2" into  table  stu3;
Loading data to table hive2_db1.stu3
Table hive2_db1.stu3 stats: [numFiles=3, totalSize=155]
OK
Time taken: 0.231 seconds
hive> select  * from  stu3;
OK
NULL zhangshan 20
NULL wangwu   NULL
NULL xiaolu   NULL
NULL zhangshan 20
NULL wangwu   NULL
NULL xiaolu   NULL
NULL zhangshan NULL
NULL wangwu   NULL
NULL xiaolu   NULL
Time taken: 0.062 seconds, Fetched: 9 row(s)
hive> 
展开阅读全文
©️2020 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值