voonhous commented on code in PR #18488:
URL: https://github.com/apache/hudi/pull/18488#discussion_r3067742168
##########
hudi-spark-datasource/hudi-spark3.4.x/src/main/scala/org/apache/spark/sql/parser/HoodieSpark3_4ExtendedSqlAstBuilder.scala:
##########
@@ -2705,8 +2720,13 @@ class HoodieSpark3_4ExtendedSqlAstBuilder(conf: SQLConf,
delegate: ParserInterfa
private def addMetadataForType(dataType:
HoodieSqlBaseParser.DataTypeContext, builder: MetadataBuilder): Unit = {
val typeText = dataType.getText
- if (typeText.equalsIgnoreCase(HoodieSchemaType.BLOB.name())) {
+ val upperTypeText = typeText.toUpperCase(Locale.ROOT)
+ if (upperTypeText == HoodieSchemaType.BLOB.name()) {
builder.putString(HoodieSchema.TYPE_METADATA_FIELD,
HoodieSchemaType.BLOB.name())
+ } else if (upperTypeText.startsWith("VECTOR(")) {
+ // Normalize to canonical form (e.g. "VECTOR(128,FLOAT)" ->
"VECTOR(128)")
+ val vectorSchema =
HoodieSchema.parseTypeDescriptor(typeText).asInstanceOf[HoodieSchema.Vector]
Review Comment:
No, it doesn't need a try/catch.
Call flow in `visitColType`:
```scala
val dataType = typedVisit[DataType](ctx.dataType) // calls
visitPrimitiveDataType
addMetadataForType(ctx.dataType(), builder) // called only if above
succeedee
```
`visitPrimitiveDataType` runs first and already calls `parseTypeDescriptor`
wrapped in try/catch. If the input is invalid, `ParseException` is thrown there
and we never reach `addMetadataForType`.
By the time addMetadataForType is called, the exact same typeText has
already been successfully parsed and validated. i.e. Second call will
definitely succeed.
--
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]