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

[GitHub] [iceberg] dramaticlly commented on a diff in pull request #7593: Spark: Throw a friendly exception if table is empty when creating branch

dramaticlly commented on code in PR #7593:
URL: https://github.com/apache/iceberg/pull/7593#discussion_r1192627356


##########
spark/v3.4/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/CreateOrReplaceBranchExec.scala:
##########
@@ -41,6 +41,9 @@ case class CreateOrReplaceBranchExec(
   override protected def run(): Seq[InternalRow] = {
     catalog.loadTable(ident) match {
       case iceberg: SparkTable =>
+        if (iceberg.table.currentSnapshot() == null) {
+          throw new UnsupportedOperationException(s"The Iceberg table: $iceberg" + " has no snapshots")
+        }

Review Comment:
   I think `iceberg.table.currentSnapshot().snapshotId` below always assume the currentSnapshot is not null but it's not the case. Probably need a way to probably handle that instead of branching out and throw a new exception.  FYI @amogh-jahagirdar 



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