jackye1995 commented on code in PR #6617: URL: https://github.com/apache/iceberg/pull/6617#discussion_r1082118486
########## spark/v3.3/spark-extensions/src/main/antlr/org.apache.spark.sql.catalyst.parser.extensions/IcebergSqlExtensions.g4: ########## @@ -168,34 +175,77 @@ fieldList ; nonReserved - : ADD | ALTER | AS | ASC | BY | CALL | DESC | DROP | FIELD | FIRST | LAST | NULLS | ORDERED | PARTITION | TABLE | WRITE - | DISTRIBUTED | LOCALLY | UNORDERED | REPLACE | WITH | IDENTIFIER_KW | FIELDS | SET + : ADD | ALTER | AS | ASC | BRANCH | BY | CALL | CREATE | DAYS | DESC | DROP | FIELD | FIRST | HOURS | LAST | NULLS | OF | ORDERED | PARTITION | TABLE | WRITE + | DISTRIBUTED | LOCALLY | MINUTES | MONTHS | UNORDERED | REPLACE | RETAIN | VERSION | WITH | IDENTIFIER_KW | FIELDS | SET | SNAPSHOT | SNAPSHOTS | TRUE | FALSE | MAP ; +snapshotId + : number + ; + +numSnapshots + : number + ; + +snapshotRetain + : number + ; + +snapshotRefRetain + : number + ; + +snapshotRefRetainTimeUnit + : timeUnit + ; + +snapshotRetainTimeUnit + : timeUnit + ; + +timeUnit + : MONTHS + | DAYS + | HOURS + | MINUTES Review Comment: sure, I am fine with minute level. We can always add more if needed. ########## spark/v3.3/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/parser/extensions/IcebergSqlExtensionsAstBuilder.scala: ########## @@ -267,6 +286,12 @@ class IcebergSqlExtensionsAstBuilder(delegate: ParserInterface) extends IcebergS private def typedVisit[T](ctx: ParseTree): T = { ctx.accept(this).asInstanceOf[T] } + + private def timeRetain(unit: String, duration: Long): Long = unit.toUpperCase(Locale.ENGLISH) match { + case "MONTHS" => 30 * TimeUnit.DAYS.toMillis(duration) Review Comment: hmm, good point, there is not exactly always 30 days in a month. That's probably why it is not supported by `TimeUnit`. So I would say in that case let's remove MONTHS from the time unit in parser and just support DAYS, HOURS and MINUTES. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org