Skip to content

Commit e100ec2

Browse files
authored
Merge pull request #41 from data-integrations/feature/CDAP-14473-macro-enable-schema
CDAP-14473 macro enable schemas
2 parents f98b88d + ad98829 commit e100ec2

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

src/main/java/co/cask/gcp/bigquery/BigQuerySinkConfig.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,26 @@
3030
* configuring the <code>BigQuerySink</code> plugin.
3131
*/
3232
public final class BigQuerySinkConfig extends GCPReferenceSinkConfig {
33-
@Name("dataset")
33+
@Macro
3434
@Description("The dataset to write to. A dataset is contained within a specific project. "
3535
+ "Datasets are top-level containers that are used to organize and control access to tables and views.")
36-
@Macro
3736
public String dataset;
3837

39-
@Name("table")
38+
@Macro
4039
@Description("The table to write to. A table contains individual records organized in rows. "
4140
+ "Each record is composed of columns (also called fields). "
4241
+ "Every table is defined by a schema that describes the column names, data types, and other information.")
43-
@Macro
4442
public String table;
4543

44+
@Macro
4645
@Nullable
47-
@Name("bucket")
4846
@Description("The Google Cloud Storage bucket to store temporary data in. "
4947
+ "It will be automatically created if it does not exist, but will not be automatically deleted. "
5048
+ "Cloud Storage data will be deleted after it is loaded into BigQuery. " +
5149
"If it is not provided, a unique bucket will be created and then deleted after the run finishes.")
52-
@Macro
5350
public String bucket;
5451

55-
@Name("schema")
52+
@Macro
5653
@Description("The schema of the data to write. Must be compatible with the table schema.")
5754
public String schema;
5855

src/main/java/co/cask/gcp/bigquery/BigQuerySourceConfig.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,27 @@
2929
* Holds configuration required for configuring {@link BigQuerySource}.
3030
*/
3131
public final class BigQuerySourceConfig extends GCPReferenceSourceConfig {
32-
@Name("dataset")
32+
@Macro
3333
@Description("The dataset the table belongs to. A dataset is contained within a specific project. "
3434
+ "Datasets are top-level containers that are used to organize and control access to tables and views.")
35-
@Macro
3635
public String dataset;
3736

38-
@Name("table")
37+
@Macro
3938
@Description("The table to read from. A table contains individual records organized in rows. "
4039
+ "Each record is composed of columns (also called fields). "
4140
+ "Every table is defined by a schema that describes the column names, data types, and other information.")
42-
@Macro
4341
public String table;
4442

43+
@Macro
4544
@Nullable
46-
@Name("bucket")
4745
@Description("The Google Cloud Storage bucket to store temporary data in. "
4846
+ "It will be automatically created if it does not exist, but will not be automatically deleted. "
4947
+ "Temporary data will be deleted after it has been read. " +
5048
"If it is not provided, a unique bucket will be created and then deleted after the run finishes.")
51-
@Macro
5249
public String bucket;
5350

54-
@Name("schema")
55-
@Description("The schema of the table to read.")
5651
@Macro
52+
@Description("The schema of the table to read.")
5753
public String schema;
5854

5955
/**

src/main/java/co/cask/gcp/gcs/source/GCSSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public static class GCSSourceConfig extends GCPReferenceSourceConfig implements
122122
+ "'parquet', 'text', and 'tsv'.")
123123
private String format;
124124

125+
@Macro
125126
@Nullable
126127
@Description("Output schema. If a Path Field is set, it must be present in the schema as a string.")
127128
private String schema;

src/main/java/co/cask/gcp/spanner/sink/SpannerSinkConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public class SpannerSinkConfig extends GCPReferenceSinkConfig {
6060

6161
public void validate() {
6262
super.validate();
63-
SpannerUtil.validateSchema(getSchema());
63+
if (!containsMacro("schema")) {
64+
SpannerUtil.validateSchema(getSchema());
65+
}
6466
if (!containsMacro("batchSize") && batchSize != null && batchSize < 1) {
6567
throw new IllegalArgumentException("Spanner batch size for writes should be positive");
6668
}

src/main/java/co/cask/gcp/spanner/source/SpannerSourceConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public class SpannerSourceConfig extends GCPReferenceSourceConfig {
5959

6060
public void validate() {
6161
super.validate();
62-
SpannerUtil.validateSchema(getSchema());
62+
if (!containsMacro("schema")) {
63+
SpannerUtil.validateSchema(getSchema());
64+
}
6365
if (!containsMacro("maxPartitions") && maxPartitions != null && maxPartitions < 1) {
6466
throw new IllegalArgumentException("Max partitions should be positive");
6567
}

0 commit comments

Comments
 (0)