Tag: hive

通过JDBC连接到Hive时,Java NoSuchMethodError

尝试从Eclipse中的简单Java程序连接到Hive时,我收到以下错误。 看起来它连接然后抛出此错误。 我可以通过直线本地连接到Hive Thrift服务器而不会出现问题。 libthrift .jar文件都是0.9.2。 在客户端和服务器上相同。 以下.jar文件的服务器和客户端版本是相同的: hive-jdbc*.jar 1.2.0 hive-service*.jar 1.2.0 libfb303-0.9.0.jar 0.9.2 libthrift-0.9.0.jar 0.9.2 log4j-1.2.16.jar 1.2.16 slf4j-api-1.6.1.jar 1.7.5 slf4j-log4j12-1.6.1.jar 1.7.5 commons-logging-1.0.4.jar 1.1.3 Exception in thread “main” java.lang.NoSuchMethodError: org.apache.thrift.protocol.TProtocol.getScheme()Ljava/lang/Class; at org.apache.hive.service.cli.thrift.TCLIService$OpenSession_args.write(TCLIService.java:1854) at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63) at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:150) at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:142) at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:578) at org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:192) at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) 我正在使用的libthrift版本被Apache列为具有getScheme()方法。 任何帮助将不胜感激!

如何从Hive Thrift客户端运行Sqoop导入到Hive Thrift服务器?

使用JDBC我可以轻松连接并能够使用以下示例代码运行Hive-QL查询: – Connection con = DriverManager.getConnection(“jdbc:hive2://192.168.56.102:10000/default”, “”, “”); Statement stmt = con.createStatement(); String tableName = “testHiveDriverTable1”; stmt.executeQuery(“create table ” + tableName + ” (key int, value string)”); 这意味着我能够与Hive进行通信。 现在我也想执行sqoop。 我该怎么做? 我是通过命令行完成的,请参阅以下示例导入 sqoop import –connect jdbc:mysql://192.168.56.101:3316/dw_db –username=user –password=pwd –table active_list –hive-import -m 1 — –schema default 这怎么可能成为现实。 并确保运行在10000端口的服务器是Hive thrift Server? 如果是,那么如何让它在Hive上执行我的sqoop查询呢?

如何在Java中对Hive进行异步调用?

我想以异步方式在服务器上执行Hive查询。 Hive查询可能需要很长时间才能完成,所以我不想阻止通话。 我目前正在使用Thirft进行阻塞调用(在client.execute()上阻塞),但我还没有看到如何进行非阻塞调用的示例。 这是阻止代码: TSocket transport = new TSocket(“hive.example.com”, 10000); transport.setTimeout(999999999); TBinaryProtocol protocol = new TBinaryProtocol(transport); Client client = new ThriftHive.Client(protocol); transport.open(); client.execute(hql); // Omitted HQL List rows; while ((rows = client.fetchN(1000)) != null) { for (String row : rows) { // Do stuff with row } } transport.close(); 上面的代码缺少try / catch块来保持简短。 有没有人有任何想法如何进行异步调用? Hive / […]

不支持Hive方法

我试图使用Hive作为底层数据存储运行SQl查询,该查询调用Big Decimal函数并引发以下错误: 不支持的方法 org.apache.hadoop.hive.jdbc.HivePreparedStatement.setBigDecimal(HivePreparedStatement.java:317) 这只是因为Hive不支持如下: public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { // TODO Auto-generated method stub throw new SQLException(“Method not supported”); } 请建议可用于解决此类问题的其他解决方法或修复方法

Hive NVL不适用于列的日期类型 – NullpointerException

我在HDFS上使用MapR Hive分发并面临以下问题。 如果对于表,列类型为“日期”类型,则NVL函数不起作用。 这适用于其他数据类型。 它只是抛出 NullpointerException:Null 甚至解释函数都抛出相同的exception。 请帮忙。 它是Hive发行版中的一个错误吗?

从单个Hive UDF创建多个列

我正在使用Amazon EMR和Hive 0.11。 我正在尝试创建一个Hive UDF,它将从一个UDF调用返回多个列。 例如,我想调用类似下面的UDF并返回几个(命名)列。 SELECT get_data(columnname) FROM table; 我无法找到完成此操作的文档,但是如果使用Generic UDF,则可以听到。 有谁知道需要从evaluate()方法返回什么才能工作?

无法validationserde:org.openx.data.jsonserde.jsonserde

我写了这个查询来在hive上创建一个表。 我的数据最初是json格式,所以我已下载并构建serde并添加了运行所需的所有jar。 但我收到以下错误: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Cannot validate serde: org.openx.data.jsonserde.JsonSerDe 查询: create table tip(type string, text string, business_id string, user_id string, date date, likes int) ROW FORMAT SERDE ‘org.openx.data.jsonserde.JsonSerDe’ WITH SERDEPROPERTIES(“date.mapping”=”date”) STORED AS TEXTFILE;

java.sql.SQLException:没有为jdbc找到合适的驱动程序:hive:// localhost:10000 / default

我是Hadoop和生态系统的新手。 我正在尝试用Java编写Hive。 这是我的简单代码,仅用于测试驱动程序: import java.sql.DriverManager; import java.sql.SQLException; public class PrepareHiveTable { private static String driverName = “org.apache.hive.jdbc.HiveDriver”; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName(driverName); Connection con = DriverManager.getConnection(“jdbc:hive://localhost:10000/default”, “”, “”); } } 我已将org.apache.hive.jdbc.HiveDriver导入到类路径中,这是我的DriverManager上的驱动程序列表: org.apache.calcite.avatica.remote.Driver@45ff54e6 org.apache.calcite.jdbc.Driver@3581c5f3 org.apache.derby.jdbc.AutoloadedDriver40@4f8e5cde com.mysql.jdbc.Driver@6f75e721 org.apache.hive.jdbc.HiveDriver@69222c14 但是,当我运行代码时,我收到此错误: Exception in thread “main” java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default at java.sql.DriverManager.getConnection(DriverManager.java:689) […]

如何找到哪个Java / Scala线程锁定了文件?

简单来说: 如何找到哪个Java / Scala线程锁定了文件? 我知道JVM中的一个类/线程已经锁定了一个具体文件(重叠了一个文件区域),但我不知道如何。 当我在断点中停止应用程序时,有可能找出正在执行此操作的类/线程吗? 以下代码抛出OverlappingFileLockException : FileChannel.open(Paths.get(“thisfile”), StandardOpenOption.APPEND).tryLock().isValid(); FileChannel.open(Paths.get(“thisfile”), StandardOpenOption.APPEND).tryLock()..isShared(); Java / Scala如何锁定此文件( Spark )? 我知道如何使用java.nio.channels锁定文件,但我没有在Spark的github存储库中找到适当的调用。 关于我的问题的更多信息: 1。当我在Windows操作系统中使用Hive运行Spark时,它可以正常工作,但是每次Spark关闭时,它都无法删除一个临时目录(在此之前的其他临时目录被正确删除)并输出以下exception: 2015-12-11 15:04:36 [Thread-13] INFO org.apache.spark.SparkContext – Successfully stopped SparkContext 2015-12-11 15:04:36 [Thread-13] INFO oaspark.util.ShutdownHookManager – Shutdown hook called 2015-12-11 15:04:36 [Thread-13] INFO oaspark.util.ShutdownHookManager – Deleting directory C:\Users\MyUser\AppData\Local\Temp\spark-9d564520-5370-4834-9946-ac5af3954032 2015-12-11 15:04:36 [Thread-13] INFO oaspark.util.ShutdownHookManager – Deleting directory […]

无法通过JAVA连接到HIVE2

参考Hive2创建了一个连接到HIVE2服务器(非本地)的简单java程序,在eclipse的类路径中添加了上述链接中所有提到的jar,但是当我运行代码时它会抛出一个错误: 09:42:35,580 INFO Utils:285 – Supplied authorities: hdstg-c01-edge-03:20000 09:42:35,583 INFO Utils:372 – Resolved authority: hdstg-c01-edge-03:20000 09:42:35,656 INFO HiveConnection:189 – Will try to open client transport with JDBC Uri: jdbc:hive2://hdstg-c01-edge-03:20000 FAILED: f java.lang.NoSuchMethodError: org.apache.thrift.protocol.TProtocol.getScheme()Ljava/lang/Class; at org.apache.hive.service.cli.thrift.TCLIService$OpenSession_args.write(TCLIService.java:1854) at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63) at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:150) at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:142) at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:456) at org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:178) at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105) at java.sql.DriverManager.getConnection(DriverManager.java:579) at java.sql.DriverManager.getConnection(DriverManager.java:221) at testScripts.HiveJdbcClient.f(HiveJdbcClient.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native […]