idea 执行import 出现"org.apache.hadoop.hive.ql.parse.ParseException:line 1:35 extraneous input ';' "

在idea 中连接hive执行下面的语句

import table import4 from '/export';

出现

 org.apache.hadoop.hive.ql.parse.ParseException:line 1:35 extraneous input ';' expecting EOF near '<EOF>'

的错误.

解决办法去掉最后的;分号.

import table import4 from '/export'

错误原因我也不太理解,我用export添加分号是可以的,但inport就不可以.

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Hive Session ID = 081f41c9-9583-4c28-a0a8-b48c7386981a Logging initialized using configuration in jar:file:/export/server/hive/lib/hive-common-3.1.3.jar!/hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. Hive Session ID = e1ff0fc1-f846-493a-b29d-333350e3778d hive> CREATE TABLE student ( > s_id STRING, > s_name STRING, > s_birth STRING, > s_sex STRING > ) > ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' > STORED AS TEXTFILE; FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Table hive.default.student already exists) hive> LOAD DATA LOCAL INPATH '/home/hadoop/data/student.txt' INTO TABLE student; FAILED: SemanticException Line 1:23 Invalid path ''/home/hadoop/data/student.txt'': No files matching path file:/home/hadoop/data/student.txt hive> LOAD DATA LOCAL INPATH '/home/hadoop/data/course.txt' INTO TABLE course; FAILED: SemanticException Line 1:23 Invalid path ''/home/hadoop/data/course.txt'': No files matching path file:/home/hadoop/data/course.txt hive> LOAD DATA LOCAL INPATH '/home/hadoop/data/teacher.txt' INTO TABLE teacher; FAILED: SemanticException Line 1:23 Invalid path ''/home/hadoop/data/teacher.txt'': No files matching path file:/home/hadoop/data/teacher.txt hive> LOAD DATA LOCAL INPATH '/home/hadoop/data/score.txt' INTO TABLE score; FAILED: SemanticException Line 1:23 Invalid path ''/home/hadoop/data/score.txt'': No files matching path file:/home/hadoop/data/score.txt hive> SHOE datebase > SHOE datebase; NoViableAltException(24@[]) at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1387) at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:220) at org.apache.hadoop.hive.ql.parse.ParseUtils.parse(ParseUtils.java:74) at org.apache.hadoop.hive.ql.parse.ParseUtils.parse(ParseUtils.java:67) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:616) at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1826) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1773) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1768) at org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:126) at org.apache.hadoop.hive.ql.reexec.ReExecDriver.run(ReExecDriver.java:214) at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:239) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:188) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:402) at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:821) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:759) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683) 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.run(RunJar.java:333) at org.apache.hadoop.util.RunJar.main(RunJar.java:254) FAILED: ParseException line 1:0 cannot recognize input near 'SHOE' 'datebase' 'SHOE' hive> SHOW TABLES > SHOW TABLES; FAILED: ParseException line 2:5 extraneous input 'TABLES' expecting EOF near '<EOF>' hive> 我之前已经做过一遍了 现在帮我删一下 从新开开始
最新发布
01-01
Hive 中出现 `Caused by: java.lang.RuntimeException: org.apache.hadoop.hive.ql.parse.SemanticException:Line 8:99 Invalid function 'GETDATE'` 错误,通常是因为 Hive 本身没有内置 `GETDATE` 函数。可以采用以下方法解决: ### 使用 Hive 内置日期函数替代 Hive 有许多内置的日期和时间相关函数,可以根据具体需求选择合适的函数来替代 `GETDATE`。`GETDATE` 函数一般用于获取当前日期和时间,在 Hive 中可以使用 `current_date` 来获取当前日期,使用 `current_timestamp` 来获取当前时间戳。 示例代码如下: ```sql -- 获取当前日期 SELECT current_date; -- 获取当前时间戳 SELECT current_timestamp; ``` ### 自定义 UDF 函数 如果内置函数无法满足需求,可以自定义一个 UDF(用户定义函数)来实现类似 `GETDATE` 的功能。以下是一个简单的 Java 示例: ```java import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import java.sql.Timestamp; import java.util.Date; @Description(name = "getdate", value = "Returns the current timestamp", extended = "SELECT getdate();") public class GetDateUDF extends UDF { public Timestamp evaluate() { return new Timestamp(new Date().getTime()); } } ``` 将上述代码编译打包成 JAR 文件,然后在 Hive 中注册并使用该 UDF: ```sql -- 添加 JAR 文件 ADD JAR /path/to/your/jar/GetDateUDF.jar; -- 创建临时函数 CREATE TEMPORARY FUNCTION getdate AS 'com.example.GetDateUDF'; -- 使用自定义函数 SELECT getdate(); ``` ### 检查 Hive 版本和配置 确保使用的 Hive 版本支持所需的日期函数。有时候,函数的可用性可能会因 Hive 版本而异。同时,检查 Hive 的配置文件,确保没有禁用相关的日期函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值