rangareddy commented on issue #17132:
URL: https://github.com/apache/hudi/issues/17132#issuecomment-5366100169
This issue was reviewed as part of the JIRA-migrated backlog triage
(HUDI-9680).
**Findings: confirmed on `master`, and it is a branch-ordering issue with a
usable workaround.**
In
`hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/IndexCommands.scala`,
`CreateIndexCommand.run` dispatches like this:
```scala
if (indexType.equals(PARTITION_NAME_COLUMN_STATS) ||
indexType.equals(PARTITION_NAME_BLOOM_FILTERS)) {
...
} else if (indexName.equals(PARTITION_NAME_RECORD_INDEX)) {
...
} else if (StringUtils.isNullOrEmpty(indexType)) {
val derivedIndexType = if (matchesRecordKeys(columnNames, tableConfig))
PARTITION_NAME_RECORD_INDEX
else PARTITION_NAME_SECONDARY_INDEX
...
} else {
throw new HoodieIndexException(String.format("%s is not supported",
indexType))
}
```
`secondary_index` is only reachable through the third branch, which requires
`indexType` to be **empty**. Naming it explicitly falls through to the final
`else` and produces exactly the message you saw.
**Workaround in the meantime:** omit the index type and let it be derived -
as long as the indexed columns are not the record key columns, it resolves to
`secondary_index`:
```sql
CREATE INDEX idx_name ON hudi_test_sec_index (Name);
```
The fix is to accept the explicit type in the first branch's condition.
Worth noting the same block is what blocks #17352 (creating column_stats /
partition_stats / bloom_filters via SQL) and #17353 (identity expression with
column stats), so all three could be addressed in one change to this dispatch.
Keeping this open.
--
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]