hililiwei commented on code in PR #5535:
URL: https://github.com/apache/iceberg/pull/5535#discussion_r947372284


##########
spark/v3.3/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSqlExtensionsAstBuilder.scala:
##########
@@ -81,6 +87,85 @@ class IcebergSqlExtensionsAstBuilder(delegate: 
ParserInterface) extends IcebergS
       Option(ctx.name).map(_.getText))
   }
 
+  /**
+   * Create an ADD BRANCH logical command.
+   */
+  override def visitCreateBranch(ctx: CreateBranchContext): CreateBranch = 
withOrigin(ctx) {
+    val snapshotRetention = Option(ctx.snapshotRetentionClause())
+
+    CreateBranch(
+      typedVisit[Seq[String]](ctx.multipartIdentifier),
+      ctx.identifier().getText,
+      Option(ctx.snapshotId()).map(_.getText.toLong),
+      snapshotRetention.flatMap(s => 
Option(s.numSnapshots())).map(_.getText.toLong),
+      snapshotRetention.flatMap(s => Option(s.snapshotRetain())).map(
+        _.getText.toLong * 
timeUnit(ctx.snapshotRetentionClause().snapshotRetainTimeUnit().getText)),

Review Comment:
   The `snapshotRetentionTimeUnit` and `snapshotRetain` are used together. If 
`snapshotRetain` is unavailable, the `flatMap` will return a `None`, so the 
`map` does not execute.



-- 
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: [email protected]

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