KnightChess commented on code in PR #12270:
URL: https://github.com/apache/hudi/pull/12270#discussion_r1849535868
##########
hudi-spark-datasource/hudi-spark3-common/src/main/scala/org/apache/spark/sql/hudi/catalog/HoodieCatalog.scala:
##########
@@ -153,6 +155,72 @@ class HoodieCatalog extends DelegatingCatalogExtension
}
}
+ override def loadTable(ident: Identifier, timestamp: Long): Table = {
+ super.loadTable(ident) match {
+ case V1Table(catalogTable0) if sparkAdapter.isHoodieTable(catalogTable0)
=>
+
+ // spark passes microseconds
+ val milliseconds = TimeUnit.MICROSECONDS.toMillis(timestamp)
+ val targetTimestamp =
HoodieInstantTimeGenerator.formatMillis(milliseconds)
+
+ constructTable(ident, catalogTable0, targetTimestamp)
+
+ case t => t
+ }
+ }
+
+ override def loadTable(ident: Identifier, version: String): Table = {
+ super.loadTable(ident) match {
+ case V1Table(catalogTable0) if sparkAdapter.isHoodieTable(catalogTable0)
=>
+
+ if (!HoodieInstantTimeGenerator.isValidInstantTime(version)) {
+ throw new AnalysisException(s"invalid snapshot id: $version")
+ }
+
+ constructTable(ident, catalogTable0, version);
+
+ case t => t
+ }
+ }
+
+ private def constructTable(ident: Identifier,
+ catalogTable0: CatalogTable,
+ timestampAsOf: String): Table = {
+ val catalogTable = catalogTable0.comment match {
+ case Some(v) =>
+ val newProps = catalogTable0.storage.properties + (
Review Comment:
this will create a new storage for create new catalogTable0.storage in
`catalogTable0.copy(storage = newStorage)`
##########
hudi-spark-datasource/hudi-spark3.3.x/src/main/scala/org/apache/spark/sql/parser/HoodieSpark3_3ExtendedSqlParser.scala:
##########
@@ -121,11 +120,7 @@ class HoodieSpark3_3ExtendedSqlParser(session:
SparkSession, delegate: ParserInt
private def isHoodieCommand(sqlText: String): Boolean = {
val normalized =
sqlText.toLowerCase(Locale.ROOT).trim().replaceAll("\\s+", " ")
- normalized.contains("system_time as of") ||
Review Comment:
Sorry, I didn’t quite understand what you meant. Could you explain in more
detail?
--
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]