tomtongue opened a new pull request, #8562:
URL: https://github.com/apache/iceberg/pull/8562

   ## Changes
   * Fix `CREATE BRANCH` syntax in *Branching and Tagging* part and Spark DDL
   * Fix broken link in *Writing to Branches* section in Spark Writes
   
   ## Details
   There are several syntax descriptions that don't follow the current design 
in the doc.
   
   The current doc shows the CREATE BRANCH in Branching and Tagging part like;
   
   ```sql
   -- Create a branch "test-branch" which will be retained for 7 days along 
with the  latest 2 snapshots
   ALTER TABLE prod.db.table CREATE BRANCH test-branch RETAIN 7 DAYS WITH 
RETENTION 2 SNAPSHOTS
   
   ```
   
   If you run the query, the query fails with the following error;
   
   ```scala
   scala> spark.sql("ALTER TABLE glue_catalog.garbagedb.iceberg_branch CREATE 
BRANCH branch3 RETAIN 2 DAYS WITH RETENTION 3 SNAPSHOTS")
   org.apache.spark.sql.catalyst.parser.extensions.IcebergParseException:
   no viable alternative at input 'WITH RETENTION'
   == SQL ==
   ALTER TABLE glue_catalog.garbagedb.iceberg_branch CREATE BRANCH branch3 
RETAIN 2 DAYS WITH RETENTION 3 SNAPSHOTS
     at 
org.apache.spark.sql.catalyst.parser.extensions.IcebergParseException.withCommand(IcebergSparkSqlExtensionsParser.scala:393)
     at 
org.apache.spark.sql.catalyst.parser.extensions.IcebergSparkSqlExtensionsParser.parse(IcebergSparkSqlExtensionsParser.scala:252)
     at 
org.apache.spark.sql.catalyst.parser.extensions.IcebergSparkSqlExtensionsParser.parsePlan(IcebergSparkSqlExtensionsParser.scala:129)
     at org.apache.spark.sql.SparkSession.$anonfun$sql$2(SparkSession.scala:633)
     at 
org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:192)
     at org.apache.spark.sql.SparkSession.$anonfun$sql$1(SparkSession.scala:632)
     at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:827)
     at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:630)
     at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:671)
     ... 47 elided
   
   ```
   
   Based on the [antlr 
source](https://github.com/apache/iceberg/blob/master/spark/v3.4/spark-extensions/src/main/antlr/org.apache.spark.sql.catalyst.parser.extensions/IcebergSqlExtensions.g4#L101)
 in the Iceberg, the following query looks correct (this query worked well in 
Spark 3.4 and the latest Iceberg built from source).
   
   ```scala
   scala> spark.sql("ALTER TABLE glue_catalog.garbagedb.iceberg_branch CREATE 
BRANCH branch3 RETAIN 2 DAYS WITH SNAPSHOT RETENTION 3 DAYS").
   ```


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