YannByron commented on a change in pull request #4714: URL: https://github.com/apache/hudi/pull/4714#discussion_r798482835
########## File path: hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieFileIndex.scala ########## @@ -282,6 +296,41 @@ object HoodieFileIndex { properties } + def convertFilterForTimestampKeyGenerator(metaClient: HoodieTableMetaClient, + partitionFilters: Seq[Expression]): Seq[Expression] = { + + val tableConfig = metaClient.getTableConfig + val keyGenerator = tableConfig.getKeyGeneratorClassName + + if (keyGenerator.equals(classOf[TimestampBasedKeyGenerator].getCanonicalName) || + keyGenerator.equals(classOf[TimestampBasedAvroKeyGenerator].getCanonicalName)) { + val inputFormat = tableConfig.getString(KeyGeneratorOptions.Config.TIMESTAMP_INPUT_DATE_FORMAT_PROP) + val outputFormat = tableConfig.getString(KeyGeneratorOptions.Config.TIMESTAMP_OUTPUT_DATE_FORMAT_PROP) + if (StringUtils.isNullOrEmpty(inputFormat) || StringUtils.isNullOrEmpty(outputFormat) || + inputFormat.equals(outputFormat)) { + partitionFilters + } else { + try { + val inDateFormat = new SimpleDateFormat(inputFormat) + val outDateFormat = new SimpleDateFormat(outputFormat) + partitionFilters.toArray.map { Review comment: yes. convert filters only if both input.format and output.format are provided. -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org