zeroflag commented on a change in pull request #1733:
URL: https://github.com/apache/hive/pull/1733#discussion_r566971532



##########
File path: hplsql/src/main/java/org/apache/hive/hplsql/Exec.java
##########
@@ -1425,30 +1450,40 @@ public Integer 
visitCreate_function_stmt(HplsqlParser.Create_function_stmtContex
   @Override 
   public Integer 
visitCreate_package_stmt(HplsqlParser.Create_package_stmtContext ctx) { 
     String name = ctx.ident(0).getText().toUpperCase();
-    exec.currentPackageDecl = new Package(name, exec, builtinFunctions);
-    exec.packages.put(name, exec.currentPackageDecl);
-    trace(ctx, "CREATE PACKAGE");
-    exec.currentPackageDecl.createSpecification(ctx);
-    exec.currentPackageDecl = null;
+    if (exec.packageLoading) {
+      exec.currentPackageDecl = new Package(name, exec, builtinFunctions);
+      exec.packages.put(name, exec.currentPackageDecl);
+      exec.currentPackageDecl.createSpecification(ctx);
+      exec.currentPackageDecl = null;
+    } else {
+      trace(ctx, "CREATE PACKAGE");
+      exec.packages.remove(name);
+      exec.packageRegistry.createPackage(name, getFormattedText(ctx));
+    }
     return 0; 
   }
 
   /**
    * CREATE PACKAGE body statement
    */
   @Override 
-  public Integer 
visitCreate_package_body_stmt(HplsqlParser.Create_package_body_stmtContext ctx) 
{ 
+  public Integer 
visitCreate_package_body_stmt(HplsqlParser.Create_package_body_stmtContext ctx) 
{
     String name = ctx.ident(0).getText().toUpperCase();
-    exec.currentPackageDecl = exec.packages.get(name);
-    if (exec.currentPackageDecl == null) {
-      exec.currentPackageDecl = new Package(name, exec, builtinFunctions);
-      exec.currentPackageDecl.setAllMembersPublic(true);
-      exec.packages.put(name, exec.currentPackageDecl);
+    if (exec.packageLoading) {

Review comment:
       I don't know any better. The same codepath is triggered when creating 
and when loading a package, somehow we need to differentiate between those two.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to