Search in sources :

Example 1 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.

the class ValueMetaResolver method tryConversionWithMask.

private Object tryConversionWithMask(ValueMetaInterface valueMeta, int originalType, Object value, String mask) throws PushDownOptimizationException {
    ValueMeta originalTypeMeta = new ValueMeta(null, originalType);
    originalTypeMeta.setConversionMask(mask);
    try {
        return valueMeta.convertData(originalTypeMeta, value);
    } catch (KettleValueException e) {
        throw new PushDownOptimizationException("Failed to convert type", e);
    }
}
Also used : KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMeta(org.pentaho.di.core.row.ValueMeta)

Example 2 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.

the class MongodbPredicateTest method setup.

@Before
public void setup() {
    for (int i = 0; i < 10; i++) {
        rowMeta.addValueMeta(new ValueMeta("sField" + i, ValueMetaInterface.TYPE_STRING, 50));
        rowMeta.addValueMeta(new ValueMeta("iField" + i, ValueMetaInterface.TYPE_INTEGER, 7));
    }
    resolver = new ValueMetaResolver(rowMeta);
    fieldMappings = new HashMap<String, String>();
}
Also used : ValueMetaResolver(org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver) ValueMeta(org.pentaho.di.core.row.ValueMeta) Before(org.junit.Before)

Example 3 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testGetInputFieldsToIgnore.

@Test
public void testGetInputFieldsToIgnore() {
    doReturn(true).when(analyzer).isInput();
    // setup input fields
    RowMetaInterface inputFieldRowMeta = mock(RowMetaInterface.class);
    List<ValueMetaInterface> inputFields = new ArrayList<>();
    inputFields.add(new ValueMeta("in_field_1"));
    Map<String, RowMetaInterface> inputFieldRowMetaMap = new HashMap<>();
    inputFieldRowMetaMap.put(ExternalResourceStepAnalyzer.RESOURCE, inputFieldRowMeta);
    when(inputFieldRowMeta.getValueMetaList()).thenReturn(inputFields);
    // setup output fields
    List<ValueMetaInterface> outputFields = new ArrayList<>();
    outputFields.addAll(inputFields);
    outputFields.add(new ValueMeta("file_field_1"));
    outputFields.add(new ValueMeta("additional_field"));
    outputFields.add(new ValueMeta("file_field_2"));
    RowMetaInterface outputFieldsRowMeta = mock(RowMetaInterface.class);
    when(outputFieldsRowMeta.getValueMetaList()).thenReturn(outputFields);
    // setup step "resource" fields
    final BaseFileField[] resourceFields = new BaseFileField[2];
    resourceFields[0] = new BaseFileField("file_field_1", 0, 0);
    resourceFields[1] = new BaseFileField("file_field_2", 0, 0);
    doReturn(resourceFields).when(fileMeta).getInputFields();
    Set<String> fieldsToIgnore = analyzer.getInputFieldsToIgnore(fileMeta, inputFieldRowMetaMap, outputFieldsRowMeta);
    assertEquals(2, fieldsToIgnore.size());
    assertTrue(fieldsToIgnore.contains("in_field_1"));
    assertTrue(fieldsToIgnore.contains("additional_field"));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 4 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testCreateInputFieldNode_resource.

@Test
public void testCreateInputFieldNode_resource() throws Exception {
    IAnalysisContext context = mock(IAnalysisContext.class);
    doReturn("thisStepName").when(analyzer).getStepName();
    analyzer.rootNode = node;
    when(node.getLogicalId()).thenReturn("logical id");
    ValueMetaInterface vmi = new ValueMeta("name", 1);
    IMetaverseNode inputFieldNode = analyzer.createInputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertNotNull(inputFieldNode);
    assertNotNull(inputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals("thisStepName", inputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    assertEquals("INPUT_TYPE", inputFieldNode.getType());
    // the input node should be added by this step
    verify(builder).addNode(inputFieldNode);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 5 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testGetInputRowMetaInterfaces_isInputAndIncomingNodes.

@Test
public void testGetInputRowMetaInterfaces_isInputAndIncomingNodes() throws Exception {
    Map<String, RowMetaInterface> inputs = new HashMap<>();
    RowMetaInterface inputRmi = mock(RowMetaInterface.class);
    List<ValueMetaInterface> vmis = new ArrayList<>();
    ValueMetaInterface vmi = new ValueMeta("filename");
    vmis.add(vmi);
    when(inputRmi.getValueMetaList()).thenReturn(vmis);
    inputs.put("test", inputRmi);
    doReturn(inputs).when(analyzer).getInputFields(meta);
    when(parentTransMeta.getPrevStepNames(parentStepMeta)).thenReturn(null);
    RowMetaInterface rowMetaInterface = new RowMeta();
    rowMetaInterface.addValueMeta(vmi);
    ValueMetaInterface vmi2 = new ValueMeta("otherField");
    rowMetaInterface.addValueMeta(vmi2);
    doReturn(rowMetaInterface).when(analyzer).getOutputFields(meta);
    doReturn(true).when(analyzer).isInput();
    Map<String, RowMetaInterface> rowMetaInterfaces = analyzer.getInputRowMetaInterfaces(meta);
    assertNotNull(rowMetaInterfaces);
    assertEquals(2, rowMetaInterfaces.size());
    RowMetaInterface metaInterface = rowMetaInterfaces.get(ExternalResourceStepAnalyzer.RESOURCE);
    // the row meta interface should only have 1 value meta in it, and it should NOT be filename
    assertEquals(1, metaInterface.size());
    assertEquals("otherField", metaInterface.getFieldNames()[0]);
}
Also used : HashMap(java.util.HashMap) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

ValueMeta (org.pentaho.di.core.row.ValueMeta)48 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)38 Test (org.junit.Test)20 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)16 RowMeta (org.pentaho.di.core.row.RowMeta)14 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 ArrayList (java.util.ArrayList)8 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)8 HashMap (java.util.HashMap)6 KettleStepException (org.pentaho.di.core.exception.KettleStepException)5 KettleValueException (org.pentaho.di.core.exception.KettleValueException)5 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)5 KettleException (org.pentaho.di.core.exception.KettleException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 Matchers.anyString (org.mockito.Matchers.anyString)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 ClonableStepAnalyzerTest (org.pentaho.metaverse.analyzer.kettle.step.ClonableStepAnalyzerTest)2 BatchUpdateException (java.sql.BatchUpdateException)1