rangareddy commented on issue #12234:
URL: https://github.com/apache/hudi/issues/12234#issuecomment-2527980118

   Hi Team,
   
   I am able to reproduce the issue using following code.
   
   ```sh
   export SPARK_VERSION=3.4
   bin/spark-shell --packages 
org.apache.hudi:hudi-spark$SPARK_VERSION-bundle_2.12:0.14.0 --conf 
'spark.serializer=org.apache.spark.serializer.KryoSerializer' --conf 
'spark.sql.catalog.spark_catalog=org.apache.spark.sql.hudi.catalog.HoodieCatalog'
 --conf 
'spark.sql.extensions=org.apache.spark.sql.hudi.HoodieSparkSessionExtension' 
--conf 'spark.kryo.registrator=org.apache.spark.HoodieSparkKryoRegistrar'
   ```
   
   ```scala
   import java.util.UUID
   import scala.util.Random
   
   case class RandomData(id: Long, uuid: String, ts: Long = 28800000L, 
partition: String)
   
   val partitions = List("One", "Two", "Three", "Four")
   
   val randomData = spark.range(1, 10 * 100000L).map(f => RandomData(id = f, 
uuid = UUID.randomUUID.toString, partition = Random.shuffle(partitions).head))
   
   import scala.collection.JavaConversions._
   import org.apache.spark.sql.SaveMode._
   import org.apache.hudi.DataSourceReadOptions._
   import org.apache.hudi.DataSourceWriteOptions._
   import org.apache.hudi.common.table.HoodieTableConfig._
   import org.apache.hudi.config.HoodieWriteConfig._
   import org.apache.hudi.keygen.constant.KeyGeneratorOptions._
   import org.apache.hudi.common.model.HoodieRecord
   import spark.implicits._
   import org.apache.hudi.DataSourceWriteOptions;
   import org.apache.hudi.common.config.{HoodieStorageConfig, 
HoodieMetadataConfig}
   import org.apache.hudi.config.HoodieIndexConfig
   import org.apache.hudi.common.table.HoodieTableConfig;
   import org.apache.hudi.keygen.ComplexKeyGenerator
   
   val tableName = "rli_test_table"
   val basePath = "file:///tmp/rli_test_table"
   
   val insertOptions: Map[String, String] = Map(
   DataSourceWriteOptions.OPERATION.key() -> 
DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL,
     DataSourceWriteOptions.TABLE_TYPE.key() -> 
DataSourceWriteOptions.COW_TABLE_TYPE_OPT_VAL,
     HoodieStorageConfig.PARQUET_COMPRESSION_CODEC_NAME.key() -> "snappy",
     HoodieStorageConfig.PARQUET_MAX_FILE_SIZE.key() -> "2147483648",
     "hoodie.parquet.small.file.limit" -> "1073741824",
     HoodieTableConfig.POPULATE_META_FIELDS.key() -> "true",
     HoodieMetadataConfig.ENABLE_METADATA_INDEX_COLUMN_STATS.key() -> "true",
     HoodieIndexConfig.INDEX_TYPE.key() -> "RECORD_INDEX",
     "hoodie.metadata.record.index.enable" -> "true",
     "hoodie.metadata.enable" -> "true",
     "hoodie.datasource.write.hive_style_partitioning" -> "true",
     "hoodie.datasource.write.partitionpath.field" -> "partition",
     "hoodie.datasource.write.recordkey.field" -> "id,partition",
     "hoodie.datasource.write.precombine.field" -> "ts",
     "hoodie.table.name" -> tableName,
     DataSourceWriteOptions.KEYGENERATOR_CLASS_NAME.key() -> 
classOf[ComplexKeyGenerator].getName,
     "hoodie.write.markers.type" -> "DIRECT",
     "hoodie.embed.timeline.server" -> "true",
     "hoodie.metadata.record.index.min.filegroup.count" -> "100",
    )
   
   randomData.write.format("hudi").
     options(insertOptions).
     mode(Overwrite).
     save(basePath)
   
   val ReadOptions: Map[String, String] = Map(
   "hoodie.enable.data.skipping" -> "true", 
   "hoodie.metadata.enable" -> "true", 
   "hoodie.metadata.index.column.stats.enable" -> "true", 
   "hoodie.metadata.record.index.enable" -> "true")
   
   val sqlTempTable = "my_tbl"
   
   val latestSnapshotDf = 
spark.read.format("hudi").options(ReadOptions).load(basePath)
   latestSnapshotDf.show()
   latestSnapshotDf.registerTempTable(sqlTempTable)
   
   import org.apache.spark.sql.catalyst.expressions.{And, AttributeReference, 
EqualTo, Expression, GreaterThan, GreaterThanOrEqual, In, Literal, Or}
   import org.apache.spark.sql.types.{StringType, StructField, StructType}
   
   val colName = "uuid"
   val reckey = latestSnapshotDf.limit(1).collect().map(row => 
row.getAs(colName).toString)
   val dataFilter = EqualTo(AttributeReference(colName, StringType, true)(), 
Literal(reckey(0)))
   
   spark.sql("select * from " + sqlTempTable + " where " + 
dataFilter.sql).count()
   ```
   
   **Exception:**
   
   ```java
   scala> spark.sql("select * from " + sqlTempTable + " where " + 
dataFilter.sql).count()
   24/12/09 19:02:58 ERROR HoodieFileIndex: Failed to lookup candidate files in 
File Index
   java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:529)
        at scala.None$.get(Option.scala:527)
        at 
org.apache.hudi.RecordLevelIndexSupport.attributeMatchesRecordKey(RecordLevelIndexSupport.scala:89)
        at 
org.apache.hudi.RecordLevelIndexSupport.filterQueryWithRecordKey(RecordLevelIndexSupport.scala:155)
        at 
org.apache.hudi.RecordLevelIndexSupport.$anonfun$filterQueriesWithRecordKey$1(RecordLevelIndexSupport.scala:133)
        at 
org.apache.hudi.RecordLevelIndexSupport.$anonfun$filterQueriesWithRecordKey$1$adapted(RecordLevelIndexSupport.scala:132)
        at scala.collection.immutable.List.foreach(List.scala:431)
        at 
org.apache.hudi.RecordLevelIndexSupport.filterQueriesWithRecordKey(RecordLevelIndexSupport.scala:132)
        at 
org.apache.hudi.HoodieFileIndex.recordKeys$lzycompute$1(HoodieFileIndex.scala:334)
        at 
org.apache.hudi.HoodieFileIndex.recordKeys$1(HoodieFileIndex.scala:334)
        at 
org.apache.hudi.HoodieFileIndex.$anonfun$lookupCandidateFilesInMetadataTable$1(HoodieFileIndex.scala:338)
        at scala.util.Try$.apply(Try.scala:213)
        at 
org.apache.hudi.HoodieFileIndex.lookupCandidateFilesInMetadataTable(HoodieFileIndex.scala:321)
        at 
org.apache.hudi.HoodieFileIndex.filterFileSlices(HoodieFileIndex.scala:222)
        at org.apache.hudi.HoodieFileIndex.listFiles(HoodieFileIndex.scala:149)
        at 
org.apache.spark.sql.execution.FileSourceScanLike.selectedPartitions(DataSourceScanExec.scala:256)
        at 
org.apache.spark.sql.execution.FileSourceScanLike.selectedPartitions$(DataSourceScanExec.scala:251)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.selectedPartitions$lzycompute(DataSourceScanExec.scala:506)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.selectedPartitions(DataSourceScanExec.scala:506)
        at 
org.apache.spark.sql.execution.FileSourceScanLike.dynamicallySelectedPartitions(DataSourceScanExec.scala:286)
        at 
org.apache.spark.sql.execution.FileSourceScanLike.dynamicallySelectedPartitions$(DataSourceScanExec.scala:267)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.dynamicallySelectedPartitions$lzycompute(DataSourceScanExec.scala:506)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.dynamicallySelectedPartitions(DataSourceScanExec.scala:506)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.inputRDD$lzycompute(DataSourceScanExec.scala:554)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.inputRDD(DataSourceScanExec.scala:537)
        at 
org.apache.spark.sql.execution.FileSourceScanExec.doExecuteColumnar(DataSourceScanExec.scala:588)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeColumnar$1(SparkPlan.scala:222)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:246)
        at 
org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at 
org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:243)
        at 
org.apache.spark.sql.execution.SparkPlan.executeColumnar(SparkPlan.scala:218)
        at 
org.apache.spark.sql.execution.InputAdapter.doExecuteColumnar(WholeStageCodegenExec.scala:521)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeColumnar$1(SparkPlan.scala:222)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:246)
        at 
org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at 
org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:243)
        at 
org.apache.spark.sql.execution.SparkPlan.executeColumnar(SparkPlan.scala:218)
        at 
org.apache.spark.sql.execution.ColumnarToRowExec.inputRDDs(Columnar.scala:207)
        at 
org.apache.spark.sql.execution.FilterExec.inputRDDs(basicPhysicalOperators.scala:238)
        at 
org.apache.spark.sql.execution.ProjectExec.inputRDDs(basicPhysicalOperators.scala:51)
        at 
org.apache.spark.sql.execution.aggregate.AggregateCodegenSupport.inputRDDs(AggregateCodegenSupport.scala:89)
        at 
org.apache.spark.sql.execution.aggregate.AggregateCodegenSupport.inputRDDs$(AggregateCodegenSupport.scala:88)
        at 
org.apache.spark.sql.execution.aggregate.HashAggregateExec.inputRDDs(HashAggregateExec.scala:47)
        at 
org.apache.spark.sql.execution.WholeStageCodegenExec.doExecute(WholeStageCodegenExec.scala:751)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$execute$1(SparkPlan.scala:195)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:246)
        at 
org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at 
org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:243)
        at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:191)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.inputRDD$lzycompute(ShuffleExchangeExec.scala:135)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.inputRDD(ShuffleExchangeExec.scala:135)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.mapOutputStatisticsFuture$lzycompute(ShuffleExchangeExec.scala:140)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.mapOutputStatisticsFuture(ShuffleExchangeExec.scala:139)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeLike.$anonfun$submitShuffleJob$1(ShuffleExchangeExec.scala:68)
        at 
org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:246)
        at 
org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at 
org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:243)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeLike.submitShuffleJob(ShuffleExchangeExec.scala:68)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeLike.submitShuffleJob$(ShuffleExchangeExec.scala:67)
        at 
org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.submitShuffleJob(ShuffleExchangeExec.scala:115)
        at 
org.apache.spark.sql.execution.adaptive.ShuffleQueryStageExec.shuffleFuture$lzycompute(QueryStageExec.scala:181)
        at 
org.apache.spark.sql.execution.adaptive.ShuffleQueryStageExec.shuffleFuture(QueryStageExec.scala:181)
        at 
org.apache.spark.sql.execution.adaptive.ShuffleQueryStageExec.doMaterialize(QueryStageExec.scala:183)
        at 
org.apache.spark.sql.execution.adaptive.QueryStageExec.materialize(QueryStageExec.scala:82)
        at 
org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$getFinalPhysicalPlan$5(AdaptiveSparkPlanExec.scala:266)
        at 
org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$getFinalPhysicalPlan$5$adapted(AdaptiveSparkPlanExec.scala:264)
   ```


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

Reply via email to