Closed instcode closed 7 years ago
@instcode My understanding is that this PR introduces new 2nd parameter in buildServiceRequestMapper
method to validate unexpected output schema given from input plugin. Please correct me. If so, it's better to execute such validation before Embulk transaction starts. Do you have any reasons why we cannot do that in validateOutputTask
method?
Thanks @muga. Yes, we can use the following code to handle that:
interface YourPluginTask extends Task {
void setSchema(Schema);
Schema getSchema();
}
Let me close this PR.
There are scenarios when an output plugin wants to know the schema in order to construct a proper
ServiceRequestMapper
instance. For example, a plugin may want to build a record exporter that is able to read all the columns in the source schema and process the data. With the current implementation, if we build the RecordExporter based of predefined column names, e.g. XXXX, it may throwColumn 'XXXX' is not found
if the source schema doesn't actually contains the columns.A real example below:
This is how I construct a
ServiceRequestMapper
This is the source schema (in
OutputPlugin#open(TaskSource taskSource, Schema schema, int taskIndex)
(missing "timestamp" & "delete" columns)
And when it loads a Page of data in
RestClientPageOutput
:The following exception is thrown:
This PR enables that support. If it knows the source schema when building
ServiceRequestMapper
, it can check whether a column is available to read or not and won't build a mapper contains missing columns:@dmikurube @muga Please have a look. Thank you.