okumin commented on code in PR #5856:
URL: https://github.com/apache/hive/pull/5856#discussion_r2154018928


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java:
##########
@@ -258,21 +254,20 @@ List<Partition> getPartitionsByFilter(final String 
filter) throws MetaException
       return new ArrayList<>(parts.values());
     }
     List<Partition> result = new ArrayList<>();
-    ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript");
-    if (se == null) {
-      LOG.error("JavaScript script engine is not found, therefore partition 
filtering "
-          + "for temporary tables is disabled.");
-      return result;
-    }
-    for (Map.Entry<String, Partition> entry : parts.entrySet()) {
-      se.put("partitionName", entry.getKey());
-      se.put("values", entry.getValue().getValues());
-      try {
-        if ((Boolean)se.eval(filter)) {
-          result.add(entry.getValue());
+    try (GraalJSScriptEngine se = GraalJSScriptEngine.create(null,
+            Context.newBuilder().allowExperimentalOptions(true)
+                    .option("js.nashorn-compat", "true")
+                    .allowAllAccess(true))) {

Review Comment:
   You'll be right. What if `.allowAllAccess(true)` is removed? The document 
doesn't mention the option.
   
   ```
   try (Context context = 
Context.newBuilder().allowExperimentalOptions(true).option("js.nashorn-compat", 
"true").build()) {
         context.eval("js", "print(__LINE__)");
     }
   ```
   
   If GraalJS works with Hive without the option, it's better from the point of 
view of security.
   
https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Context.Builder.html#allowAllAccess(boolean)



-- 
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-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to