背景
datax 离线同步数据到 hive 后,对于 impala 需要手动刷新元数据。
即
invalidate metadata lyk.ods_jinan_carbondata
OR
refresh lyk.ods_jinan_carbondata
思路
在 datax 任务节点后,新增一个 SQL 节点,专门用来使用 impala 引擎执行刷新元数据的操作。
具体实践
报错1
服务端异常: ### Error updating database. Cause: java.sql.SQLException:
Subquery returns more than 1 row ###
The error may exist in class path resource [org/apache/dolphinscheduler/dao/mapper/TaskDefinitionNotOnlineMapper.xml]
### The error may involve defaultParameterMap ### The error occurred while setting parameters ###
SQL: DELETE FROM t_ds_task_definition WHERE code =(
SELECT post_task_code FROM t_ds_process_task_relation WHERE project_code=?
and process_definition_code=?) ###
Cause: java.sql.SQLException: Subquery returns more than 1 row ;
bad SQL grammar []; nested exception is java.sql.SQLException:
Subquery returns more than 1 row
任务创建接口
taskDefinitionNotOnlineService.deleteTaskDefinition(projectCode, processDefinition.getCode());
报错2
Caused by: java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://10.11.14.37:21050/default: java.net.SocketTimeoutException: Read timed out
Driver org.apache.hive.jdbc.HiveDriver claims to not accept jdbcUrl, jdbc:impala://10.11.14.37:21050/default
这个错误通常是因为您正在使用 Hive 的 JDBC 驱动程序连接到 Impala 服务,这两个服务虽然都可以使用 Hive SQL 语法,但它们之间的连接方式和 URL 格式是不一样的,因此可能会导致这个错误。
要连接 Impala 服务,您需要使用 Impala 的 JDBC 驱动程序,并使用其特定的 JDBC URL。
请将您的 JDBC URL 修改为 Impala 的 JDBC URL 格式,同时使用 Impala 的 JDBC 驱动程序,例如:
import java.sql.*;
public class ImpalaJdbcExample {
public static void main(String[] args) throws SQLException {
String jdbcUrl = "jdbc:impala://10.11.14.37:21050/default";
String username = "<your-username>";
String password = "<your-password>";
// Load the Impala JDBC driver
Class.forName("com.cloudera.impala.jdbc41.Driver");
// Establish a JDBC connection to Impala
Connection conn = DriverManager.getConnection(jdbcUrl, username, password);
// Use the connection to execute SQL statements
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM my_table");
while (rs.next()) {
System.out.println("Record count: " + rs.getInt(1));
}
// Clean up the resources
rs.close();
stmt.close();
conn.close();
}
}
请注意,这里使用的是 com.cloudera.impala.jdbc41.Driver 驱动程序,而不是 Hive 的 JDBC 驱动程序 org.apache.hive.jdbc.HiveDriver。另外,您需要将 AuthMech、transportMode 和 SSL 等连接属性设置为适当的值,以配置连接 Impala 服务的方式。