Search in sources :

Example 1 with SchemaConfigException

use of org.embulk.spi.SchemaConfigException in project embulk by embulk.

the class TestRenameFilterPlugin method throwSchemaConfigExceptionIfColumnNotFound.

@Test
public void throwSchemaConfigExceptionIfColumnNotFound() {
    ConfigSource pluginConfig = Exec.newConfigSource().set("columns", ImmutableMap.of("not_found", "any_name"));
    try {
        filter.transaction(pluginConfig, SCHEMA, new FilterPlugin.Control() {

            public void run(TaskSource task, Schema schema) {
            }
        });
        fail();
    } catch (Throwable t) {
        assertTrue(t instanceof SchemaConfigException);
    }
}
Also used : ConfigSource(org.embulk.config.ConfigSource) FilterPlugin(org.embulk.spi.FilterPlugin) Schema(org.embulk.spi.Schema) TaskSource(org.embulk.config.TaskSource) SchemaConfigException(org.embulk.spi.SchemaConfigException) Test(org.junit.Test)

Example 2 with SchemaConfigException

use of org.embulk.spi.SchemaConfigException in project embulk by embulk.

the class RemoveColumnsFilterPlugin method getExistentColumns.

private List<String> getExistentColumns(Schema schema, List<String> specifiedColumns, boolean acceptUnmatch) {
    ImmutableList.Builder<String> existentColumns = ImmutableList.builder();
    for (String column : specifiedColumns) {
        try {
            schema.lookupColumn(column);
            existentColumns.add(column);
        } catch (SchemaConfigException e) {
            if (!acceptUnmatch) {
                throw new ConfigException(String.format(ENGLISH, "Column '%s' doesn't exist in the schema", column));
            }
        }
    }
    return existentColumns.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ConfigException(org.embulk.config.ConfigException) SchemaConfigException(org.embulk.spi.SchemaConfigException) SchemaConfigException(org.embulk.spi.SchemaConfigException)

Aggregations

SchemaConfigException (org.embulk.spi.SchemaConfigException)2 ImmutableList (com.google.common.collect.ImmutableList)1 ConfigException (org.embulk.config.ConfigException)1 ConfigSource (org.embulk.config.ConfigSource)1 TaskSource (org.embulk.config.TaskSource)1 FilterPlugin (org.embulk.spi.FilterPlugin)1 Schema (org.embulk.spi.Schema)1 Test (org.junit.Test)1