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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangshuminjava/article/details/79525114
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> 
展开阅读全文

没有更多推荐了,返回首页