@Test public void testValueAlreadyExists() { Schema pinotSchema = new Schema(); DimensionFieldSpec dimensionFieldSpec = new DimensionFieldSpec("fullName", FieldSpec.DataType.STRING, true); pinotSchema.addField(dimensionFieldSpec); List<TransformConfig> transformConfigs = new ArrayList<>(); transformConfigs.add(new TransformConfig("fullName", "Groovy({firstName + ' ' + lastName}, firstName, lastName)")); TableConfig tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("testValueExists") .setIngestionConfig(new IngestionConfig(null, transformConfigs)).build(); ExpressionTransformer expressionTransformer = new ExpressionTransformer(tableConfig, pinotSchema); GenericRow genericRow = new GenericRow(); genericRow.putValue("firstName", "John"); genericRow.putValue("lastName", "Denver"); genericRow.putValue("fullName", "John N Denver"); expressionTransformer.transform(genericRow); Assert.assertEquals(genericRow.getValue("fullName"), "John N Denver"); pinotSchema = new Schema.SchemaBuilder() .addTime(new TimeGranularitySpec(FieldSpec.DataType.LONG, TimeUnit.MILLISECONDS, "incoming"), new TimeGranularitySpec(FieldSpec.DataType.INT, TimeUnit.DAYS, "outgoing")).build(); tableConfig = new TableConfigBuilder(TableType.REALTIME).setTableName("testValueExists") .setIngestionConfig(new IngestionConfig(null, null)).build(); expressionTransformer = new ExpressionTransformer(tableConfig, pinotSchema); genericRow = new GenericRow(); genericRow.putValue("incoming", "123456789"); genericRow.putValue("outgoing", "123"); expressionTransformer.transform(genericRow); Assert.assertEquals(genericRow.getValue("outgoing"), "123"); }
@Override public GenericRow transform(GenericRow record) { for (Map.Entry<String, FunctionEvaluator> entry : _expressionEvaluators.entrySet()) { String column = entry.getKey(); FunctionEvaluator transformFunctionEvaluator = entry.getValue(); if (record.getValue(column) == null) { Object result = transformFunctionEvaluator.evaluate(record); record.putValue(column, result); } } return record; }
ExpressionTransformer implements RecordTransformer { @Override public GenericRow transform(GenericRow record) { for (Map.Entry<String, FunctionEvaluator> entry : _expressionEvaluators.entrySet()) { String column = entry.getKey(); FunctionEvaluator transformFunctionEvaluator = entry.getValue(); if (record.getValue(column) == null) { Object result = transformFunctionEvaluator.evaluate(record); record.putValue(column, result); } } return record; } }
ExpressionTransformer implements RecordTransformer { @Override public GenericRow transform(GenericRow record) { for (Map.Entry<String, FunctionEvaluator> entry : _expressionEvaluators.entrySet()) { String column = entry.getKey(); FunctionEvaluator transformFunctionEvaluator = entry.getValue(); if (record.getValue(column) == null) { Object result = transformFunctionEvaluator.evaluate(record); record.putValue(column, result); } } return record; } ExpressionTransformer(TableConfig tableConfig, Schema schema); }
ExpressionTransformer implements RecordTransformer { @Override public GenericRow transform(GenericRow record) { for (Map.Entry<String, FunctionEvaluator> entry : _expressionEvaluators.entrySet()) { String column = entry.getKey(); FunctionEvaluator transformFunctionEvaluator = entry.getValue(); if (record.getValue(column) == null) { Object result = transformFunctionEvaluator.evaluate(record); record.putValue(column, result); } } return record; } ExpressionTransformer(TableConfig tableConfig, Schema schema); @Override GenericRow transform(GenericRow record); }
ExpressionTransformer implements RecordTransformer { @Override public GenericRow transform(GenericRow record) { for (Map.Entry<String, FunctionEvaluator> entry : _expressionEvaluators.entrySet()) { String column = entry.getKey(); FunctionEvaluator transformFunctionEvaluator = entry.getValue(); if (record.getValue(column) == null) { Object result = transformFunctionEvaluator.evaluate(record); record.putValue(column, result); } } return record; } ExpressionTransformer(TableConfig tableConfig, Schema schema); @Override GenericRow transform(GenericRow record);  }