Skip to content

Commit edad76d

Browse files
Merge pull request #1285 from data-integrations/plugin_1672_cherry_pick
[6.9.2][Cherry-pick][PLUGIN-1672] Allowing hyphen in BQ table name
2 parents 98aa2ce + f171918 commit edad76d

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

src/e2e-test/java/io/cdap/plugin/bigquery/stepsdesign/BigQueryBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ public void verifyTheBigQueryValidationErrorMessageForInvalidProperty(String pro
234234
} else if (property.equalsIgnoreCase("bucket")) {
235235
expectedErrorMessage = PluginPropertyUtils
236236
.errorProp(E2ETestConstants.ERROR_MSG_BQ_INCORRECT_TEMPORARY_BUCKET);
237+
} else if (property.equalsIgnoreCase("table")) {
238+
expectedErrorMessage = PluginPropertyUtils
239+
.errorProp(E2ETestConstants.ERROR_MSG_INCORRECT_TABLE_NAME);
237240
} else {
238241
expectedErrorMessage = PluginPropertyUtils.errorProp(E2ETestConstants.ERROR_MSG_BQ_INCORRECT_PROPERTY).
239242
replaceAll("PROPERTY", property.substring(0, 1).toUpperCase() + property.substring(1));

src/e2e-test/java/io/cdap/plugin/utils/E2ETestConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class E2ETestConstants {
77
public static final String ERROR_MSG_GCS_INVALID_PATH = "errorMessageGCSInvalidPath";
88
public static final String ERROR_MSG_GCS_INVALID_BUCKET_NAME = "errorMessageGCSInvalidBucketName";
99
public static final String ERROR_MSG_INCORRECT_TABLE = "errorMessageIncorrectBQTable";
10+
public static final String ERROR_MSG_INCORRECT_TABLE_NAME = "errorMessageIncorrectBQTableName";
1011
public static final String ERROR_MSG_PUBSUB_INVALID_ADVANCED_FIELDS = "errorMessagePubSubInvalidAdvancedField";
1112
public static final String ERROR_MSG_PUBSUB_MAX_BATCH_COUNT = "errorMessagePubSubMaxBatchCountField";
1213
public static final String ERROR_MSG_PUBSUB_MAX_BATCH_SIZE = "errorMessagePubSubMaxBatchSizeField";

src/e2e-test/resources/errorMessage.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ errorMessagePubSubRetryTimeout=Invalid max retry timeout for retrying failed pub
1515
errorMessagePubSubErrorThreshold=Invalid error threshold for publishing. Ensure the value is a positive number.
1616
errorMessageIncorrectBQChunkSize=Value must be a multiple of 262144.
1717
errorMessageIncorrectBQBucketName=Bucket name can only contain lowercase letters, numbers, '.', '_', and '-'.
18+
errorMessageIncorrectBQTableName=Table name can only contain letters (lower or uppercase), numbers, '_' and '-'.
1819
errorMessageIncorrectBQProperty=PROPERTY name can only contain letters (lower or uppercase), numbers and '_'.
1920
errorMessageInvalidPath=Error when trying to detect schema: Input path not found
2021
errorMessageBQExecuteTableDataset=Dataset and table must be specified together.

src/main/java/io/cdap/plugin/gcp/bigquery/util/BigQueryUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public final class BigQueryUtil {
8383

8484
public static final String BUCKET_PATTERN = "[a-z0-9._-]+";
8585
public static final String DATASET_PATTERN = "[A-Za-z0-9_]+";
86-
public static final String TABLE_PATTERN = "[A-Za-z0-9_]+";
86+
public static final String TABLE_PATTERN = "[A-Za-z0-9_-]+";
8787

8888
// Tags for BQ Jobs
8989
public static final String BQ_JOB_TYPE_SOURCE_TAG = "bq_source_plugin";
@@ -675,7 +675,7 @@ public static void validateDataset(String dataset, String datasetPropertyName, F
675675
*/
676676
public static void validateTable(String table, String tablePropertyName, FailureCollector collector) {
677677
// Allowed character validation for table name as per https://cloud.google.com/bigquery/docs/tables
678-
String errorMessage = "Table name can only contain letters (lower or uppercase), numbers and '_'.";
678+
String errorMessage = "Table name can only contain letters (lower or uppercase), numbers, '_' and '-'.";
679679
match(table, tablePropertyName, TABLE_PATTERN, collector, errorMessage);
680680
}
681681

src/test/java/io/cdap/plugin/gcp/dataplex/source/config/DataplexBatchSourceConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void testValidateTable() {
129129
.setReferenceName("test").build();
130130
try {
131131
dataplexBatchSourceConfig.validateBigQueryDataset(mockFailureCollector,
132-
"project", "dataset", "table-wrong");
132+
"project", "dataset", "table.wrong");
133133
} catch (Exception e) {
134134
}
135135

0 commit comments

Comments
 (0)