Search in sources :

Example 6 with TSnowflakeOutputProperties

use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.

the class TSnowflakeOutputMigrationTest method testSnowflakeConvertToUppercaseMigration.

@Test
public void testSnowflakeConvertToUppercaseMigration() throws IOException {
    Deserialized<TSnowflakeOutputProperties> deser = Properties.Helper.fromSerializedPersistent(TestUtils.getResourceAsString(getClass(), "tSnowflakeOuputProperties.json"), TSnowflakeOutputProperties.class);
    assertTrue("The property should be migrated, the migration returned false instead of true", deser.migrated);
    TSnowflakeOutputProperties properties = deser.object;
    boolean convertToUppercase = properties.convertColumnsAndTableToUppercase.getValue();
    assertFalse(convertToUppercase);
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) Test(org.junit.Test)

Example 7 with TSnowflakeOutputProperties

use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.

the class SnowflakeSinkTest method setup.

@Before
public void setup() {
    sink = new SnowflakeSink();
    sink.initialize(null, new TSnowflakeOutputProperties("outputProperties"));
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) Before(org.junit.Before)

Example 8 with TSnowflakeOutputProperties

use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.

the class SnowflakeReadersTestIT method testSameConnectionForSeveralReaders.

@Test(expected = IOException.class)
public void testSameConnectionForSeveralReaders() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
    SnowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(connContainer).getStatus());
    TSnowflakeOutputProperties props = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
    setupProps(props.getConnectionProperties());
    setupTableWithStaticValues(props);
    props.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
    List<IndexedRecord> rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    // Read second time with the same properties but with new reader.
    rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    TSnowflakeCloseProperties closeProps = (TSnowflakeCloseProperties) getComponentService().getComponentProperties(TSnowflakeCloseDefinition.COMPONENT_NAME);
    closeProps.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeCloseSourceOrSink snowflakeCloseSourceOrSink = new SnowflakeCloseSourceOrSink();
    snowflakeCloseSourceOrSink.initialize(connContainer, closeProps);
    assertEquals(ValidationResult.Result.OK, snowflakeCloseSourceOrSink.validate(connContainer).getStatus());
    // After close, exception should be thrown by the reader, if we try to read with the same connection.
    rows = readRows(props, connContainer);
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeCloseSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink) TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 9 with TSnowflakeOutputProperties

use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.

the class SnowflakeRuntimeIT method populateOutput.

protected SnowflakeConnectionTableProperties populateOutput(int count) throws Throwable {
    TSnowflakeOutputProperties props = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
    setupProps(props.getConnectionProperties());
    checkAndSetupTable(props);
    props.outputAction.setStoredValue(TSnowflakeOutputProperties.OutputAction.INSERT);
    props.afterOutputAction();
    long time = System.currentTimeMillis();
    LOGGER.info("Start loading: " + count + " rows");
    Result result = makeAndWriteRows(makeWriter(props), count);
    assertEquals(count, result.getSuccessCount());
    assertEquals(0, result.getRejectCount());
    long elapsed = System.currentTimeMillis() - time;
    LOGGER.info("time (ms): " + elapsed + " rows/sec: " + ((float) count / (float) (elapsed / 1000)));
    return props;
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) Result(org.talend.components.api.component.runtime.Result)

Example 10 with TSnowflakeOutputProperties

use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.

the class SnowflakeRuntimeIT method getRightProperties.

protected TSnowflakeOutputProperties getRightProperties(SnowflakeConnectionTableProperties props) {
    TSnowflakeOutputProperties handleProperties;
    if (props instanceof TSnowflakeOutputProperties) {
        handleProperties = (TSnowflakeOutputProperties) props;
    } else {
        // $NON-NLS-1$
        handleProperties = new TSnowflakeOutputProperties("output");
        handleProperties.copyValuesFrom(props);
    }
    return handleProperties;
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties)

Aggregations

TSnowflakeOutputProperties (org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties)17 Test (org.junit.Test)10 Schema (org.apache.avro.Schema)3 IndexedRecord (org.apache.avro.generic.IndexedRecord)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Before (org.junit.Before)3 Form (org.talend.daikon.properties.presentation.Form)3 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)2 Result (org.talend.components.api.component.runtime.Result)2 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)2 SnowflakeTableProperties (org.talend.components.snowflake.SnowflakeTableProperties)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 LoaderProperty (net.snowflake.client.loader.LoaderProperty)1 StreamLoader (net.snowflake.client.loader.StreamLoader)1 Connector (org.talend.components.api.component.Connector)1 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)1 SnowflakeConnectionProperties (org.talend.components.snowflake.SnowflakeConnectionProperties)1