rangareddy commented on issue #14352:
URL: https://github.com/apache/hudi/issues/14352#issuecomment-3581152121
**Reproducible Test code:**
`hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/TestExpressionIndex.scala`
```scala
test("Test Expression Index Column With Timestamp Expressions") {
withTempDir { tmp =>
val tableName = generateTableName
val basePath = s"$tmp/$tableName"
spark.sql(
s"""CREATE TABLE $tableName (
| ts LONG,
| id STRING,
| rider STRING,
| driver STRING,
| fare DOUBLE,
| dateDefault STRING,
| date STRING,
| city STRING,
| state STRING
|) USING HUDI
|options(
| primaryKey ='id',
| hoodie.write.record.merge.mode = 'COMMIT_TIME_ORDERING'
|)
|PARTITIONED BY (city)
|location '$basePath'
""".stripMargin
)
spark.sql(
s"""
|insert into $tableName(ts, id, rider, driver, fare, dateDefault,
date, city, state) VALUES
| (1695159649087,'trip1','rider-A','driver-K',19.10, '2020-11-30
01:30:40', '2020-11-30', 'san_francisco','california'),
| (1695091554788,'trip6','rider-C','driver-K',17.14, '2021-11-30
01:30:40', '2021-11-30', 'san_diego','california'),
| (1695046462179,'trip3','rider-E','driver-O',93.50, '2022-11-30
01:30:40', '2022-11-30', 'austin','texas'),
| (1695516137016,'trip4','rider-F','driver-P',34.15, '2023-11-30
01:30:40', '2023-11-30', 'houston','texas')
""".stripMargin
)
spark.sql(s"CREATE INDEX idx_column_ts on $tableName using
column_stats(ts) options(expr='from_unixtime', format='yyyy-MM-dd')")
checkAnswer(s"select id, rider, driver from $tableName WHERE
from_unixtime(ts, 'yyyy-MM-dd') = '2023-09-24'")(
Seq("trip4", "rider-F", "driver-P")
)
spark.sql(s"DROP INDEX idx_column_ts on $tableName")
}
}
```
--
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]