You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "holdenk (via GitHub)" <gi...@apache.org> on 2023/10/17 04:38:05 UTC

[I] fast_forward does not work for the first commit in Spark [iceberg]

holdenk opened a new issue, #8849:
URL: https://github.com/apache/iceberg/issues/8849

   ### Apache Iceberg version
   
   1.4.0 (latest release)
   
   ### Query engine
   
   Spark
   
   ### Please describe the bug 🐞
   
   Repro SQL:
   
   ```sql
   DROP TABLE IF EXISTS local.wap_projects;
   CREATE TABLE local.wap_projects (
          creator string,
          projectname string)
   USING iceberg
   PARTITIONED BY (creator);
   ALTER TABLE local.projects SET TBLPROPERTIES (
       'write.wap.enabled''true'
   );
   -- INSERT INTO local.wap_projects VALUES("holdenk", "spark");
   ALTER TABLE local.wap_projects DROP BRANCH IF EXISTS `audit-branch`;
   ALTER TABLE local.wap_projects CREATE BRANCH `audit-branch`;
   SET spark.wap.branch = 'audit-branch';
   INSERT INTO local.projects VALUES("krisnova", "aurae");
   SELECT count(*) FROM local.wap_projects VERSION AS OF 'audit-branch' WHERE creator is NULL;
   SELECT count(*) FROM local.wap_projects VERSION AS OF 'audit-branch' WHERE creator == "krisnova";
   CALL local.system.remove_orphan_files(table => 'local.wap_projects');
   CALL local.system.fast_forward("local.wap_projects", "main", "audit-branch");
   ```
   
   Removing the comment from above, and everything works fine :)
   
   The exception is
   
   ```
   CALL local.system.fast_forward("local.wap_projects", "main", "audit-branch")]
   java.lang.NullPointerException
   	at org.apache.iceberg.spark.procedures.FastForwardBranchProcedure.lambda$call$0(FastForwardBranchProcedure.java:80)
   	at org.apache.iceberg.spark.procedures.BaseProcedure.execute(BaseProcedure.java:107)
   	at org.apache.iceberg.spark.procedures.BaseProcedure.modifyIcebergTable(BaseProcedure.java:88)
   	at org.apache.iceberg.spark.procedures.FastForwardBranchProcedure.call(FastForwardBranchProcedure.java:77)
   	at org.apache.spark.sql.execution.datasources.v2.CallExec.run(CallExec.scala:34)
   	at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result$lzycompute(V2CommandExec.scala:43)
   	at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result(V2CommandExec.scala:43)
   	at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.executeCollect(V2CommandExec.scala:49)
   	at org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.$anonfun$applyOrElse$1(QueryExecution.scala:107)
   	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:125)
   	at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:201)
   	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:108)
   	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:900)
   	at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:66)
   	at org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.applyOrElse(QueryExecution.scala:107)
   	at org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.applyOrElse(QueryExecution.scala:98)
   	at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDownWithPruning$1(TreeNode.scala:461)
   	at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(origin.scala:76)
   	at org.apache.spark.sql.catalyst.trees.TreeNode.transformDownWithPruning(TreeNode.scala:461)
   	at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDownWithPruning(LogicalPlan.scala:32)
   	at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDownWithPruning(AnalysisHelper.scala:267)
   	at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDownWithPruning$(AnalysisHelper.scala:263)
   	at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:32)
   	at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:32)
   	at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:437)
   	at org.apache.spark.sql.execution.QueryExecution.eagerlyExecuteCommands(QueryExecution.scala:98)
   	at org.apache.spark.sql.execution.QueryExecution.commandExecuted$lzycompute(QueryExecution.scala:85)
   	at org.apache.spark.sql.execution.QueryExecution.commandExecuted(QueryExecution.scala:83)
   	at org.apache.spark.sql.Dataset.<init>(Dataset.scala:220)
   	at org.apache.spark.sql.Dataset$.$anonfun$ofRows$2(Dataset.scala:100)
   	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:900)
   	at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:97)
   	at org.apache.spark.sql.SparkSession.$anonfun$sql$4(SparkSession.scala:691)
   	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:900)
   	at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:682)
   	at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:713)
   	at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:744)
   	at org.apache.spark.sql.SQLContext.sql(SQLContext.scala:651)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLDriver.run(SparkSQLDriver.scala:68)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver.processCmd(SparkSQLCLIDriver.scala:501)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver.$anonfun$processLine$1(SparkSQLCLIDriver.scala:619)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver.$anonfun$processLine$1$adapted(SparkSQLCLIDriver.scala:613)
   	at scala.collection.Iterator.foreach(Iterator.scala:943)
   	at scala.collection.Iterator.foreach$(Iterator.scala:943)
   	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
   	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
   	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
   	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver.processLine(SparkSQLCLIDriver.scala:613)
   	at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:336)
   	at org.apache.hadoop.hive.cli.CliDriver.processReader(CliDriver.java:474)
   	at org.apache.hadoop.hive.cli.CliDriver.processFile(CliDriver.java:490)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver$.main(SparkSQLCLIDriver.scala:229)
   	at org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver.main(SparkSQLCLIDriver.scala)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
   	at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:1029)
   	at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:194)
   	at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:217)
   	at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:91)
   	at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1120)
   	at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1129)
   	at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] fast_forward does not work for the first commit in Spark [iceberg]

Posted by "amogh-jahagirdar (via GitHub)" <gi...@apache.org>.
amogh-jahagirdar closed issue #8849: fast_forward does not work for the first commit in Spark
URL: https://github.com/apache/iceberg/issues/8849


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] fast_forward does not work for the first commit in Spark [iceberg]

Posted by "ajantha-bhat (via GitHub)" <gi...@apache.org>.
ajantha-bhat commented on issue #8849:
URL: https://github.com/apache/iceberg/issues/8849#issuecomment-1765668208

   > long currentRef = table.currentSnapshot().snapshotId();
   
   Since the `audit-branch` is empty we have `table.currentSnapshot()` as null and it leads to NPE, this should be fixed. I will take a look.


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] fast_forward does not work for the first commit in Spark [iceberg]

Posted by "ajantha-bhat (via GitHub)" <gi...@apache.org>.
ajantha-bhat commented on issue #8849:
URL: https://github.com/apache/iceberg/issues/8849#issuecomment-1765789016

   Hmm, It is not just the null check addition in the procedure, later it fails because reference MAIN does not exist during replace branch. 
   
   https://github.com/apache/iceberg/blob/46cad6ddaeff8104d96defab25206a4ff7e01629/core/src/main/java/org/apache/iceberg/UpdateSnapshotReferencesOperation.java#L123
   
   The reason is we create the main branch only during first snapshot creation. 
   But in this scenario there is no main branch exist for replace operation. 
   I thought of blocking this scenario by throwing an exception. But since we support creating empty branch (from https://github.com/apache/iceberg/pull/8072/), we should also support replacing to/from empty branch. 
   
   I am thinking to add an empty/dummy snapshot for create table operation with MAIN reference in a sparate PR to tackle this.
   Let me know what you guys think, @amogh-jahagirdar, @ConeyLiu , @rdblue  


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org