You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Zhihua Deng (Jira)" <ji...@apache.org> on 2024/06/16 02:57:00 UTC

[jira] [Commented] (HIVE-28317) Support HiveServer2 JDBC Driver's `initFile` parameter to directly read SQL files on the classpath

    [ https://issues.apache.org/jira/browse/HIVE-28317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855271#comment-17855271 ] 

Zhihua Deng commented on HIVE-28317:
------------------------------------

Do we see other databases support this use case? does {*}{*}{*}classpath{*} refer to the current directory where the process is started?

> Support HiveServer2 JDBC Driver's `initFile` parameter to directly read SQL files on the classpath
> --------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-28317
>                 URL: https://issues.apache.org/jira/browse/HIVE-28317
>             Project: Hive
>          Issue Type: Wish
>            Reporter: Qiheng He
>            Priority: Major
>
> - Support HiveServer2 JDBC Driver's {*}initFile{*} parameter to directly read SQL files on the classpath.
> - In https://issues.apache.org/jira/browse/HIVE-5867 , the {*}initFile{*} parameter of HiveServer2 JDBC Driver is supported to read SQL files on absolute paths. However, this jdbcUrl parameter does not natively support paths on the {*}classpath{*}. This necessitates executing additional steps if one needs to read a file located on the {*}classpath{*}.
> {code:java}
> import com.zaxxer.hikari.HikariConfig;
> import com.zaxxer.hikari.HikariDataSource;
> import org.awaitility.Awaitility;
> import org.junit.jupiter.api.Test;
> import java.nio.file.Paths;
> import java.time.Duration;
> public class ExampleTest {
>     @Test
>     void test() {
>         String absolutePath = Paths.get("src/test/resources/test-sql/test-databases-hive.sql")
>                 .toAbsolutePath().normalize().toString();
>         HikariConfig config = new HikariConfig();
>         config.setDriverClassName("org.apache.hive.jdbc.HiveDriver");
>         config.setJdbcUrl("jdbc:hive2://localhost:10000;initFile=" + absolutePath);
>         try (HikariDataSource hikariDataSource = new HikariDataSource(config)) {
>             Awaitility.await().atMost(Duration.ofMinutes(1L)).ignoreExceptions().until(() -> {
>                 hikariDataSource.getConnection().close();
>                 return true;
>             });
>         }
>     }
> }
> {code}
> - It would greatly facilitate integration testing scenarios, such as those with {*}testcontainers-java{*}, if the {*}initFile{*} parameter could recognize classpath files by identifying a {*}classpath{*} prefix. For instance, a JDBC URL like {*}jdbc:hive2://localhost:10000;initFile=classpath:test-sql/test-databases-hive.sql{*} would become much more useful.
> - Further early discussions on this topic can be found at https://github.com/apache/shardingsphere/pull/31526 .



--
This message was sent by Atlassian Jira
(v8.20.10#820010)