Search in sources :

Example 6 with HoodieMultiTableDeltaStreamer

use of org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer in project hudi by apache.

the class TestHoodieMultiTableDeltaStreamer method testCustomConfigProps.

@Test
public void testCustomConfigProps() throws IOException {
    HoodieMultiTableDeltaStreamer.Config cfg = TestHelpers.getConfig(PROPS_FILENAME_TEST_SOURCE1, dfsBasePath + "/config", TestDataSource.class.getName(), false, false, SchemaRegistryProvider.class);
    HoodieMultiTableDeltaStreamer streamer = new HoodieMultiTableDeltaStreamer(cfg, jsc);
    TableExecutionContext executionContext = streamer.getTableExecutionContexts().get(1);
    assertEquals(2, streamer.getTableExecutionContexts().size());
    assertEquals(dfsBasePath + "/multi_table_dataset/uber_db/dummy_table_uber", executionContext.getConfig().targetBasePath);
    assertEquals("uber_db.dummy_table_uber", executionContext.getConfig().targetTableName);
    assertEquals("topic1", executionContext.getProperties().getString(HoodieMultiTableDeltaStreamer.Constants.KAFKA_TOPIC_PROP));
    assertEquals("_row_key", executionContext.getProperties().getString(DataSourceWriteOptions.RECORDKEY_FIELD().key()));
    assertEquals(TestHoodieDeltaStreamer.TestGenerator.class.getName(), executionContext.getProperties().getString(DataSourceWriteOptions.KEYGENERATOR_CLASS_NAME().key()));
    assertEquals("uber_hive_dummy_table", executionContext.getProperties().getString(HoodieMultiTableDeltaStreamer.Constants.HIVE_SYNC_TABLE_PROP));
    assertEquals("http://localhost:8081/subjects/random-value/versions/latest", executionContext.getProperties().getString(SchemaRegistryProvider.Config.SRC_SCHEMA_REGISTRY_URL_PROP));
    assertEquals("http://localhost:8081/subjects/topic2-value/versions/latest", streamer.getTableExecutionContexts().get(0).getProperties().getString(SchemaRegistryProvider.Config.SRC_SCHEMA_REGISTRY_URL_PROP));
}
Also used : HoodieMultiTableDeltaStreamer(org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer) TableExecutionContext(org.apache.hudi.utilities.deltastreamer.TableExecutionContext) TestDataSource(org.apache.hudi.utilities.sources.TestDataSource) Test(org.junit.jupiter.api.Test)

Example 7 with HoodieMultiTableDeltaStreamer

use of org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer in project hudi by apache.

the class TestHoodieMultiTableDeltaStreamer method testTableLevelProperties.

@Test
public void testTableLevelProperties() throws IOException {
    HoodieMultiTableDeltaStreamer.Config cfg = TestHelpers.getConfig(PROPS_FILENAME_TEST_SOURCE1, dfsBasePath + "/config", TestDataSource.class.getName(), false, false, null);
    HoodieMultiTableDeltaStreamer streamer = new HoodieMultiTableDeltaStreamer(cfg, jsc);
    List<TableExecutionContext> tableExecutionContexts = streamer.getTableExecutionContexts();
    tableExecutionContexts.forEach(tableExecutionContext -> {
        switch(tableExecutionContext.getTableName()) {
            case "dummy_table_short_trip":
                String tableLevelKeyGeneratorClass = tableExecutionContext.getProperties().getString(DataSourceWriteOptions.KEYGENERATOR_CLASS_NAME().key());
                assertEquals(TestHoodieDeltaStreamer.TestTableLevelGenerator.class.getName(), tableLevelKeyGeneratorClass);
                break;
            default:
                String defaultKeyGeneratorClass = tableExecutionContext.getProperties().getString(DataSourceWriteOptions.KEYGENERATOR_CLASS_NAME().key());
                assertEquals(TestHoodieDeltaStreamer.TestGenerator.class.getName(), defaultKeyGeneratorClass);
        }
    });
}
Also used : HoodieMultiTableDeltaStreamer(org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer) TableExecutionContext(org.apache.hudi.utilities.deltastreamer.TableExecutionContext) TestDataSource(org.apache.hudi.utilities.sources.TestDataSource) Test(org.junit.jupiter.api.Test)

Example 8 with HoodieMultiTableDeltaStreamer

use of org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer in project hudi by apache.

the class TestHoodieMultiTableDeltaStreamer method testInvalidPropsFilePath.

@Test
public void testInvalidPropsFilePath() throws IOException {
    HoodieMultiTableDeltaStreamer.Config cfg = TestHelpers.getConfig(PROPS_INVALID_FILE, dfsBasePath + "/config", TestDataSource.class.getName(), true, true, null);
    Exception e = assertThrows(IllegalArgumentException.class, () -> {
        new HoodieMultiTableDeltaStreamer(cfg, jsc);
    }, "Should fail when invalid props file is provided");
    log.debug("Expected error when creating table execution objects", e);
    assertTrue(e.getMessage().contains("Please provide valid common config file path!"));
}
Also used : HoodieMultiTableDeltaStreamer(org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer) TestDataSource(org.apache.hudi.utilities.sources.TestDataSource) HoodieException(org.apache.hudi.exception.HoodieException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Aggregations

HoodieMultiTableDeltaStreamer (org.apache.hudi.utilities.deltastreamer.HoodieMultiTableDeltaStreamer)8 Test (org.junit.jupiter.api.Test)8 TestDataSource (org.apache.hudi.utilities.sources.TestDataSource)6 IOException (java.io.IOException)4 HoodieException (org.apache.hudi.exception.HoodieException)4 TableExecutionContext (org.apache.hudi.utilities.deltastreamer.TableExecutionContext)4 TypedProperties (org.apache.hudi.common.config.TypedProperties)1 HoodieTestDataGenerator (org.apache.hudi.common.testutils.HoodieTestDataGenerator)1 JsonKafkaSource (org.apache.hudi.utilities.sources.JsonKafkaSource)1 ParquetDFSSource (org.apache.hudi.utilities.sources.ParquetDFSSource)1 Disabled (org.junit.jupiter.api.Disabled)1