bhat-vinay commented on code in PR #10491:
URL: https://github.com/apache/hudi/pull/10491#discussion_r1449039323
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestHoodieTableValuedFunction.scala:
##########
@@ -558,4 +558,50 @@ class TestHoodieTableValuedFunction extends
HoodieSparkSqlTestBase {
}
}
}
+
+ test(s"Test hudi_metadata Table-Valued Function") {
+ if (HoodieSparkUtils.gteqSpark3_2) {
+ withTempDir { tmp =>
+ Seq("cow").foreach { tableType =>
+ val tableName = generateTableName
+ val identifier = tableName
+ spark.sql("set " + SPARK_SQL_INSERT_INTO_OPERATION.key + "=upsert")
+ spark.sql(
+ s"""
+ |create table $tableName (
+ | id int,
+ | name string,
+ | ts long,
+ | price int
+ |) using hudi
+ |partitioned by (price)
+ |tblproperties (
+ | type = '$tableType',
+ | primaryKey = 'id',
+ | preCombineField = 'ts',
+ | hoodie.datasource.write.recordkey.field = 'id',
+ | hoodie.metadata.record.index.enable = 'true',
+ | hoodie.metadata.index.column.stats.enable = 'true',
+ | hoodie.metadata.index.column.stats.column.list = 'price'
+ |)
+ |location '${tmp.getCanonicalPath}/$tableName'
+ |""".stripMargin
+ )
+
+ spark.sql(
+ s"""
+ | insert into $tableName
+ | values (1, 'a1', 1000, 10), (2, 'a2', 2000, 20), (3, 'a3',
3000, 30)
+ | """.stripMargin
+ )
+
+ val result1DF = spark.sql(
+ s"select * from hudi_metadata('$identifier')"
+ )
+ result1DF.show(false)
Review Comment:
The output here looks like following:
```
+------------------------------------------------+----+---------------------------------------------------------------------------------------------+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
|key |type|filesystemMetadata
|BloomFilterMetadata|ColumnStatsMetadata
|recordIndexMetadata
|
+------------------------------------------------+----+---------------------------------------------------------------------------------------------+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
|XV1ds8/f890=Y3BB5pb5nN8=w+ks42Peh7IzHkz0AvRedw==|3 |null
|null
|{2f2a4323-62df-4cf1-b1d5-91ed26f082f5-0_1-34-81_20240111152056298.parquet,
price, {null, {20}, null, null, null, null, null, null, null, null, null},
{null, {20}, null, null, null, null, null, null, null, null, null}, 1, 0, 51,
33, false}|null
|
|XV1ds8/f890=hmXBJvAQ24Y=8UOwwsuyxb+TPm8R/YquZw==|3 |null
|null
|{89fdfe8c-f77c-4917-b899-4ceba5cba32e-0_0-34-80_20240111152056298.parquet,
price, {null, {30}, null, null, null, null, null, null, null, null, null},
{null, {30}, null, null, null, null, null, null, null, null, null}, 1, 0, 51,
33, false}|null
|
|XV1ds8/f890=/vI1OU7mFjI=8NI1pwlr88Hwgi5PUlSCiQ==|3 |null
|null
|{6fdc628a-b86a-42b4-8d66-3ae15fd11f9b-0_2-34-82_20240111152056298.parquet,
price, {null, {10}, null, null, null, null, null, null, null, null, null},
{null, {10}, null, null, null, null, null, null, null, null, null}, 1, 0, 51,
33, false}|null
|
|1 |5 |null
|null
|null
|{price=10, 8060425781025325748, -8257848127087632485, 0, ,
1704986456298, 0} |
|3 |5 |null
|null
|null
|{price=30, -8503360640004634345, -5144996524311469266, 0, ,
1704986456298, 0}|
|2 |5 |null
|null
|null
|{price=20, 3398602688066178289, -5632435311210364171, 0, ,
1704986456298, 0} |
|__all_partitions__ |1 |{price=30 -> {0,
false}, price=20 -> {0, false}, price=10 -> {0, false}}
|null |null
|null
|
|price=30 |2
|{89fdfe8c-f77c-4917-b899-4ceba5cba32e-0_0-34-80_20240111152056298.parquet ->
{434871, false}}|null |null
|null
|
|price=20 |2
|{2f2a4323-62df-4cf1-b1d5-91ed26f082f5-0_1-34-81_20240111152056298.parquet ->
{434871, false}}|null |null
|null
|
|price=10 |2
|{6fdc628a-b86a-42b4-8d66-3ae15fd11f9b-0_2-34-82_20240111152056298.parquet ->
{434874, false}}|null |null
|null
|
+------------------------------------------------+----+---------------------------------------------------------------------------------------------+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
```
--
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]