Search in sources :

Example 26 with DescriptorProperties

use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.

the class FileSystemTableFactoryTest method testSourceSink.

@Test
public void testSourceSink() {
    DescriptorProperties descriptor = new DescriptorProperties();
    descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
    descriptor.putString("path", "/tmp");
    descriptor.putString("format", "testcsv");
    // test ignore format options
    descriptor.putString("testcsv.my_option", "my_value");
    DynamicTableSource source = createTableSource(SCHEMA, descriptor.asMap());
    assertTrue(source instanceof FileSystemTableSource);
    DynamicTableSink sink = createTableSink(SCHEMA, descriptor.asMap());
    assertTrue(sink instanceof FileSystemTableSink);
}
Also used : DescriptorProperties(org.apache.flink.table.descriptors.DescriptorProperties) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) Test(org.junit.Test)

Example 27 with DescriptorProperties

use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.

the class FileSystemTableFactoryTest method testUnsupportedWatermarkTimeZone.

@Test
public void testUnsupportedWatermarkTimeZone() {
    DescriptorProperties descriptor = new DescriptorProperties();
    descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
    descriptor.putString("path", "/tmp");
    descriptor.putString("format", "csv");
    descriptor.putString(SINK_PARTITION_COMMIT_WATERMARK_TIME_ZONE.key(), "UTC+8");
    try {
        createTableSource(SCHEMA, descriptor.asMap());
    } catch (ValidationException e) {
        Throwable cause = e.getCause();
        assertTrue(cause.toString(), cause instanceof ValidationException);
        assertTrue(cause.getMessage(), cause.getMessage().contains("The supported watermark time zone is either a full name such " + "as 'America/Los_Angeles', or a custom time zone id such " + "as 'GMT-08:00', but configured time zone is 'UTC+8'."));
        return;
    }
    fail("Should fail by ValidationException.");
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) DescriptorProperties(org.apache.flink.table.descriptors.DescriptorProperties) Test(org.junit.Test)

Example 28 with DescriptorProperties

use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.

the class FileSystemTableFactoryTest method testLackOptionSink.

@Test
public void testLackOptionSink() {
    DescriptorProperties descriptor = new DescriptorProperties();
    descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
    descriptor.putString("path", "/tmp");
    try {
        createTableSink(SCHEMA, descriptor.asMap());
    } catch (ValidationException e) {
        Throwable cause = e.getCause();
        assertTrue(cause.toString(), cause instanceof ValidationException);
        assertTrue(cause.getMessage(), cause.getMessage().contains("Missing required options are:\n\nformat"));
        return;
    }
    fail("Should fail by ValidationException.");
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) DescriptorProperties(org.apache.flink.table.descriptors.DescriptorProperties) Test(org.junit.Test)

Example 29 with DescriptorProperties

use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.

the class FileSystemTableFactoryTest method testLackOptionSource.

@Test
public void testLackOptionSource() {
    DescriptorProperties descriptor = new DescriptorProperties();
    descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
    descriptor.putString("path", "/tmp");
    try {
        createTableSource(SCHEMA, descriptor.asMap());
    } catch (ValidationException e) {
        Throwable cause = e.getCause();
        assertTrue(cause.toString(), cause instanceof ValidationException);
        assertTrue(cause.getMessage(), cause.getMessage().contains("Missing required options are:\n\nformat"));
        return;
    }
    fail("Should fail by ValidationException.");
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) DescriptorProperties(org.apache.flink.table.descriptors.DescriptorProperties) Test(org.junit.Test)

Example 30 with DescriptorProperties

use of org.apache.flink.table.descriptors.DescriptorProperties in project flink by apache.

the class FileSystemTableFactoryTest method testNoFormatFactoryFound.

@Test
public void testNoFormatFactoryFound() {
    DescriptorProperties descriptor = new DescriptorProperties();
    descriptor.putString(FactoryUtil.CONNECTOR.key(), "filesystem");
    descriptor.putString("path", "/tmp");
    descriptor.putString("format", "invalid");
    Exception expected = new ValidationException("Could not find any format factory for identifier 'invalid' in the classpath.");
    try {
        createTableSource(SCHEMA, descriptor.asMap());
        fail("Should fail");
    } catch (Exception e) {
        assertThat(e.getCause(), containsCause(expected));
    }
    try {
        createTableSink(SCHEMA, descriptor.asMap());
        fail("Should fail");
    } catch (Exception e) {
        assertThat(e.getCause(), containsCause(expected));
    }
}
Also used : ValidationException(org.apache.flink.table.api.ValidationException) DescriptorProperties(org.apache.flink.table.descriptors.DescriptorProperties) ValidationException(org.apache.flink.table.api.ValidationException) Test(org.junit.Test)

Aggregations

DescriptorProperties (org.apache.flink.table.descriptors.DescriptorProperties)32 Test (org.junit.Test)22 ValidationException (org.apache.flink.table.api.ValidationException)13 DataGeneratorSourceTest (org.apache.flink.streaming.api.functions.source.datagen.DataGeneratorSourceTest)9 HashMap (java.util.HashMap)6 TableSchema (org.apache.flink.table.api.TableSchema)6 GenericRowData (org.apache.flink.table.data.GenericRowData)3 RowData (org.apache.flink.table.data.RowData)3 ArrayList (java.util.ArrayList)2 TableException (org.apache.flink.table.api.TableException)2 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)2 FileSystemValidator (org.apache.flink.table.descriptors.FileSystemValidator)2 OldCsvValidator (org.apache.flink.table.descriptors.OldCsvValidator)2 SchemaValidator (org.apache.flink.table.descriptors.SchemaValidator)2 CsvTableSink (org.apache.flink.table.sinks.CsvTableSink)2 TableSink (org.apache.flink.table.sinks.TableSink)2 CsvTableSource (org.apache.flink.table.sources.CsvTableSource)2 TableSource (org.apache.flink.table.sources.TableSource)2 DataType (org.apache.flink.table.types.DataType)2 IOException (java.io.IOException)1