public DataTypeTransformer(Schema schema) { _schema = schema; for (Map.Entry<String, FieldSpec> entry : schema.getFieldSpecMap().entrySet()) { _dataTypes.put(entry.getKey(), PinotDataType.getPinotDataType(entry.getValue())); } }
/** * Compare two schemas ignoring their version number. * * @return <code>true</code> if two schemas equal to each other. * <p><code>false</code>if two schemas do not equal to each other. */ public static boolean equalsIgnoreVersion(@Nonnull Schema schema1, @Nonnull Schema schema2) { Preconditions.checkNotNull(schema1); Preconditions.checkNotNull(schema2); return schema1.getSchemaName().equals(schema2.getSchemaName()) && schema1.getFieldSpecMap() .equals(schema2.getFieldSpecMap()); }
public SanitationTransformer(Schema schema) { for (Map.Entry<String, FieldSpec> entry : schema.getFieldSpecMap().entrySet()) { FieldSpec fieldSpec = entry.getValue(); if (fieldSpec.getDataType() == FieldSpec.DataType.STRING) { _stringColumnMaxLengthMap.put(entry.getKey(), fieldSpec.getMaxLength()); } } }
public ExpressionTransformer(Schema schema) { for (Map.Entry<String, FieldSpec> entry : schema.getFieldSpecMap().entrySet()) { FieldSpec fieldSpec = entry.getValue(); String expression = fieldSpec.getTransformFunction(); if (expression != null) { try { _expressionEvaluators.put(entry.getKey(), new FunctionExpressionEvaluator(expression)); } catch (Exception e) { LOGGER.error("Caught exception while constructing expression evaluator for: {}, skipping", expression, e); } } } }
Schema inputSchema = Schema.fromString(schema.toString()); Assert.assertEquals(readSchema, inputSchema); Assert.assertTrue(readSchema.getFieldSpecMap().containsKey("NewColumn")); Assert.assertFalse(readSchema.getFieldSpecMap().containsKey(yetAnotherColumn)); schema.addField(new DimensionFieldSpec(yetAnotherColumn, FieldSpec.DataType.STRING, true)); PutMethod putMethod = inputSchema = Schema.fromString(schema.toString()); Assert.assertEquals(readSchema, inputSchema); Assert.assertTrue(readSchema.getFieldSpecMap().containsKey(yetAnotherColumn));