Skip to content

Commit

Permalink
Fixing test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivabalan committed Jan 9, 2025
1 parent 83ed43c commit f09f1d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,12 @@ public Option<HoodieIndexMetadata> getIndexMetadata() {
StoragePath indexDefinitionPath =
new StoragePath(basePath, tableConfig.getRelativeIndexDefinitionPath().get());
try {
return Option.of(HoodieIndexMetadata.fromJson(
new String(FileIOUtils.readDataFromPath(storage, indexDefinitionPath).get())));
Option<byte[]> bytesOpt = FileIOUtils.readDataFromPath(storage, indexDefinitionPath, true);
if (bytesOpt.isPresent()) {
return Option.of(HoodieIndexMetadata.fromJson(new String(bytesOpt.get())));
} else {
return Option.of(new HoodieIndexMetadata());
}
} catch (IOException e) {
throw new HoodieIOException("Could not load expression index metadata at path: " + tableConfig.getRelativeIndexDefinitionPath().get(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,11 @@ public void testWrapAndUnwrapJavaValues(Comparable value, Class expectedWrapper)
assertEquals((int) ChronoUnit.DAYS.between(
LocalDate.ofEpochDay(0), ((Date) value).toLocalDate()),
((GenericRecord) wrapperValue).get(0));
assertEquals(((Date)(value)).getTime(), ((Date)unwrapAvroValueWrapper(wrapperValue)).getTime());
assertEquals(value, unwrapAvroValueWrapper(wrapperValue));
} else if (value instanceof LocalDate) {
assertEquals((int) ChronoUnit.DAYS.between(LocalDate.ofEpochDay(0), (LocalDate) value),
((GenericRecord) wrapperValue).get(0));
assertEquals(Date.valueOf((LocalDate)value).getTime(), ((Date)unwrapAvroValueWrapper(wrapperValue)).getTime());
assertEquals(Date.valueOf((LocalDate)value), unwrapAvroValueWrapper(wrapperValue));
} else {
assertEquals("0.000000000000000",
((BigDecimal) value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.hudi.common.testutils.RawTripTestPayload.recordsToStrings
import org.apache.hudi.common.testutils.{HoodieTestDataGenerator, HoodieTestUtils}
import org.apache.hudi.config.{HoodieClusteringConfig, HoodieCompactionConfig, HoodieWriteConfig}
import org.apache.hudi.metadata.HoodieMetadataPayload.SECONDARY_INDEX_RECORD_KEY_SEPARATOR
import org.apache.hudi.metadata.HoodieTableMetadataUtil.PARTITION_NAME_SECONDARY_INDEX
import org.apache.hudi.metadata.SecondaryIndexKeyUtils
import org.apache.hudi.storage.StoragePath
import org.apache.hudi.{DataSourceReadOptions, DataSourceWriteOptions, HoodieSparkUtils}
Expand All @@ -36,7 +37,6 @@ import org.apache.spark.sql.hudi.common.HoodieSparkSqlTestBase
import org.junit.jupiter.api.Assertions.{assertEquals, assertFalse, assertTrue}

import java.util.concurrent.atomic.AtomicInteger

import scala.collection.JavaConverters._

class TestSecondaryIndex extends HoodieSparkSqlTestBase {
Expand Down Expand Up @@ -155,7 +155,8 @@ class TestSecondaryIndex extends HoodieSparkSqlTestBase {
.build()
assertFalse(metaClient.getTableConfig.getRelativeIndexDefinitionPath.get().contains(metaClient.getBasePath))
assertTrue(metaClient.getIndexDefinitionPath.contains(metaClient.getBasePath.toString))
val indexDefinition = metaClient.getIndexMetadata.get().getIndexDefinitions.values().stream().findFirst().get()
val indexDefinition = metaClient.getIndexMetadata.get().getIndexDefinitions.values().stream()
.filter(indexDefn => indexDefn.getIndexType.equals(PARTITION_NAME_SECONDARY_INDEX)).findFirst().get()

metaClient.getTableConfig.setMetadataPartitionState(metaClient, indexDefinition.getIndexName, false)
checkAnswer(s"drop index idx_price on $tableName")()
Expand Down

0 comments on commit f09f1d7

Please sign in to comment.