|
21 | 21 | import co.cask.cdap.api.annotation.Name; |
22 | 22 | import co.cask.cdap.api.annotation.Plugin; |
23 | 23 | import co.cask.cdap.api.data.schema.Schema; |
| 24 | +import co.cask.cdap.api.plugin.EndpointPluginContext; |
24 | 25 | import co.cask.cdap.etl.api.PipelineConfigurer; |
25 | 26 | import co.cask.cdap.etl.api.batch.BatchSource; |
26 | 27 | import co.cask.cdap.etl.api.batch.BatchSourceContext; |
|
41 | 42 | import java.util.Map; |
42 | 43 | import java.util.regex.Pattern; |
43 | 44 | import javax.annotation.Nullable; |
| 45 | +import javax.ws.rs.Path; |
44 | 46 |
|
45 | 47 | /** |
46 | 48 | * Class description here. |
@@ -87,6 +89,23 @@ protected void recordLineage(LineageRecorder lineageRecorder, List<String> outpu |
87 | 89 | lineageRecorder.recordRead("Read", "Read from Google Cloud Storage.", outputFields); |
88 | 90 | } |
89 | 91 |
|
| 92 | + /** |
| 93 | + * Endpoint method to get the output schema of a source. |
| 94 | + * |
| 95 | + * @param config configuration for the source |
| 96 | + * @param pluginContext context to create plugins |
| 97 | + * @return schema of fields |
| 98 | + */ |
| 99 | + @Path("getSchema") |
| 100 | + public Schema getSchema(GCSSourceConfig config, EndpointPluginContext pluginContext) { |
| 101 | + FileFormat fileFormat = config.getFormat(); |
| 102 | + if (fileFormat == null) { |
| 103 | + return config.getSchema(); |
| 104 | + } |
| 105 | + Schema schema = fileFormat.getSchema(config.getPathField()); |
| 106 | + return schema == null ? config.getSchema() : schema; |
| 107 | + } |
| 108 | + |
90 | 109 | /** |
91 | 110 | * Config for the plugin. |
92 | 111 | */ |
|
0 commit comments