rahil-c commented on code in PR #18540:
URL: https://github.com/apache/hudi/pull/18540#discussion_r3143731092
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/ddl/TestCreateTable.scala:
##########
@@ -2333,4 +2333,96 @@ class TestCreateTable extends HoodieSparkSqlTestBase {
val hiveSchema = CreateHoodieTableCommand.toHiveCompatibleSchema(schema)
assertEquals(ArrayType(FloatType, containsNull = false),
hiveSchema("floats").dataType)
}
+
+ test("VECTOR column persists as VECTOR in Hudi tableCreateSchema and allows
INSERT INTO") {
+ withTempDir { tmp =>
+ val tableName = generateTableName
+ spark.sql(
+ s"""
+ |CREATE TABLE $tableName (
+ | id BIGINT,
+ | embedding VECTOR(3)
+ |) USING hudi
+ |LOCATION '${tmp.getCanonicalPath}'
+ |TBLPROPERTIES (
+ | primaryKey = 'id'
+ |)
+ """.stripMargin)
+
+ val metaClient = createMetaClient(spark, tmp.getCanonicalPath)
+ val persistedOpt = metaClient.getTableConfig.getTableCreateSchema
+ assertTrue(persistedOpt.isPresent, "tableCreateSchema should be present")
+ val persisted = persistedOpt.get()
+ val embedding =
persisted.getField("embedding").get().schema().getNonNullType()
+ assertEquals(HoodieSchemaType.VECTOR, embedding.getType)
+ assertEquals(3, embedding.asInstanceOf[HoodieSchema.Vector].getDimension)
+
+ spark.sql(s"""
+ INSERT INTO $tableName VALUES
+ (1, array(cast(0.1 as float), cast(0.2 as float), cast(0.3 as
float))),
+ (2, array(cast(0.4 as float), cast(0.5 as float), cast(0.6 as
float)))
+ """)
+ }
Review Comment:
@voonhous for your tests after adding data can you run one SELECT * query
and assert expected values?
--
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]