You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "veghlaci05 (via GitHub)" <gi...@apache.org> on 2023/06/14 08:46:21 UTC
[GitHub] [hive] veghlaci05 commented on a diff in pull request #4407: HIVE-27430: Upgrade Antlr in hplsql to 4.9.3
veghlaci05 commented on code in PR #4407:
URL: https://github.com/apache/hive/pull/4407#discussion_r1229240681
##########
hplsql/src/main/java/org/apache/hive/hplsql/Exec.java:
##########
@@ -662,6 +660,31 @@ public void registerUdf() {
udfRegistered = true;
}
+ private static void addJar(ArrayList<String> sql, String dir, String jarName) {
+ if (isNotBlank(jarName)) {
+ sql.add("ADD JAR " + Paths.get(dir, jarName));
+ }
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(Exec.class);
Review Comment:
I think this should be declared at the top of the class.
##########
hplsql/src/main/java/org/apache/hive/hplsql/Exec.java:
##########
@@ -662,6 +660,31 @@ public void registerUdf() {
udfRegistered = true;
}
+ private static void addJar(ArrayList<String> sql, String dir, String jarName) {
+ if (isNotBlank(jarName)) {
+ sql.add("ADD JAR " + Paths.get(dir, jarName));
+ }
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(Exec.class);
+
+ private static String findJarLike(String dir, String prefix) {
+ String[] files = new File(dir).list();
+ if (files == null) {
+ LOG.warn("No jar file found in directory '{}'", dir);
+ return null;
+ }
+
+ for(String jarName: files) {
+ if(jarName.startsWith(prefix) && jarName.endsWith(".jar")) {
+ return jarName;
+ }
+ }
+
+ LOG.warn("No jar file found in directory '{}' with prefix '{}'", dir, prefix);
+ return null;
+ }
Review Comment:
You should use `File.list(FilenameFilter filter)` instead
##########
hplsql/src/main/java/org/apache/hive/hplsql/Exec.java:
##########
@@ -662,6 +660,31 @@ public void registerUdf() {
udfRegistered = true;
}
+ private static void addJar(ArrayList<String> sql, String dir, String jarName) {
+ if (isNotBlank(jarName)) {
+ sql.add("ADD JAR " + Paths.get(dir, jarName));
+ }
+ }
Review Comment:
You may call `findJarLike` from this method. For me it's a bit odd to pass null value from outside and check it here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org