@Nullable @Override public String getSchemaToAdd() { Schema schema = config.getFormat().getSchema(); return schema == null ? null : schema.toString(); } }
@Override public List<?> makeRow(ViewDetail object) { return Lists.newArrayList(object.getId(), object.getFormat().getName(), object.getTableName(), GSON.toJson(object.getFormat().getSchema()), GSON.toJson(object.getFormat().getSettings())); } }).build();
@Nullable @Override public String getSchemaToAdd() { Schema schema = viewSpec.getFormat().getSchema(); if (schema == null) { FormatSpecification format = viewSpec.getFormat(); RecordFormat<Object, Object> initializedFormat; try { initializedFormat = RecordFormats.createInitializedFormat(format); schema = initializedFormat.getSchema(); } catch (IllegalAccessException | InstantiationException | UnsupportedTypeException | ClassNotFoundException e) { LOG.debug("Exception: ", e); LOG.warn("Exception while determining schema for view {}. View {} will not contain schema as metadata.", viewId, viewId); } } return schema == null ? null : schema.toString(); } }
@Override public List<?> makeRow(StreamProperties object) { FormatSpecification format = object.getFormat(); return Lists.newArrayList(object.getTTL(), format.getName(), format.getSchema().toString(), object.getNotificationThresholdMB(), object.getDescription()); } }).build();
@Override public void configurePipeline(PipelineConfigurer pipelineConfigurer) { super.configurePipeline(pipelineConfigurer); streamBatchConfig.validate(); if (!streamBatchConfig.containsMacro(Properties.Stream.NAME)) { pipelineConfigurer.addStream(new Stream(streamBatchConfig.name)); } // if no format is specified then default schema is used, if otherwise its based on format spec. if (streamBatchConfig.format == null) { pipelineConfigurer.getStageConfigurer().setOutputSchema(DEFAULT_SCHEMA); } else if (streamBatchConfig.getFormatSpec() != null && streamBatchConfig.getFormatSpec().getSchema() != null) { List<Schema.Field> fields = Lists.newArrayList(); fields.add(Schema.Field.of("ts", Schema.of(Schema.Type.LONG))); fields.add(Schema.Field.of("headers", Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING)))); fields.addAll(streamBatchConfig.getFormatSpec().getSchema().getFields()); pipelineConfigurer.getStageConfigurer().setOutputSchema(Schema.recordOf("event", fields)); } }
/** * Initialize the format with the given desired schema and properties. * Guaranteed to be called once before any other method is called. * * @param formatSpecification the specification for the format, containing the desired schema and settings * @throws UnsupportedTypeException if the desired schema and properties are not supported */ public void initialize(@Nullable FormatSpecification formatSpecification) throws UnsupportedTypeException { Schema desiredSchema = null; Map<String, String> settings = Collections.emptyMap(); if (formatSpecification != null) { desiredSchema = formatSpecification.getSchema(); settings = formatSpecification.getSettings(); } desiredSchema = desiredSchema == null ? getDefaultSchema() : desiredSchema; if (desiredSchema == null) { String msg = "A schema must be provided to the format: "; if (formatSpecification != null) { msg += formatSpecification.getName(); } throw new UnsupportedTypeException(msg); } validateIsRecord(desiredSchema); validateSchema(desiredSchema); this.schema = desiredSchema; configure(settings); }
/** * Initialize the format with the given desired schema and properties. * Guaranteed to be called once before any other method is called. * * @param formatSpecification the specification for the format, containing the desired schema and settings * @throws UnsupportedTypeException if the desired schema and properties are not supported */ public void initialize(@Nullable FormatSpecification formatSpecification) throws UnsupportedTypeException { Schema desiredSchema = null; Map<String, String> settings = Collections.emptyMap(); if (formatSpecification != null) { desiredSchema = formatSpecification.getSchema(); settings = formatSpecification.getSettings(); } desiredSchema = desiredSchema == null ? getDefaultSchema() : desiredSchema; if (desiredSchema == null) { String msg = "A schema must be provided to the format: "; if (formatSpecification != null) { msg += formatSpecification.getName(); } throw new UnsupportedTypeException(msg); } validateIsRecord(desiredSchema); validateSchema(desiredSchema); this.schema = desiredSchema; configure(settings); }
schema = formatSpec.getSchema();
Schema streamSchema = config.getFormat().getSchema(); for (Schema.Field field : streamSchema.getFields()) { Schema fieldSchema = field.getSchema();