Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ static FieldValueList arrowRootToFieldValueList(
if (root.getFieldVectors().size() != schema.getFields().size()) {
throw new IllegalArgumentException(
String.format(
"Schema mismatch: Arrow vector count (%d) does not match BigQuery schema field count (%d)",
"Schema mismatch: Arrow vector count (%d) does not match BigQuery schema field count"
+ " (%d)",
root.getFieldVectors().size(), schema.getFields().size()));
}
List<FieldValue> fieldValues = new ArrayList<>();
Expand Down Expand Up @@ -335,7 +336,8 @@ static FieldValue arrowVectorToFieldValue(
if (subFields == null || childCount != subFields.size()) {
throw new IllegalArgumentException(
String.format(
"Schema mismatch for field '%s': Arrow struct size (%d) does not match BigQuery subfields size (%d)",
"Schema mismatch for field '%s': Arrow struct size (%d) does not match BigQuery"
+ " subfields size (%d)",
name, childCount, subFields != null ? subFields.size() : 0));
}
List<FieldValue> elements = new ArrayList<>(childCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ public Page<FieldValueList> getNextPage() {
// BigQueryReadClient across page fetches. Custom BigQuery implementations that do
// not extend BigQueryImpl cannot provide the managed gRPC storage read client.
throw new IllegalStateException(
"Arrow query result pagination requires an instance of BigQueryImpl to manage BigQueryReadClient lifecycle");
"Arrow query result pagination requires an instance of BigQueryImpl to manage"
+ " BigQueryReadClient lifecycle");
}
bqReadClient = ((BigQueryImpl) service).getBigQueryReadClient(location);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
public class BigQueryResultImpl<T> implements BigQueryResult<T> {

private static final String NULL_CURSOR_MSG =
"Error occurred while reading the cursor. This could happen if getters are called after we are done reading all the records";
"Error occurred while reading the cursor. This could happen if getters are called after we"
+ " are done reading all the records";

// This class represents a row of records, the columns are represented as a map
// (columnName:columnValue pair)
Expand Down Expand Up @@ -220,7 +221,8 @@ public boolean next() throws SQLException {
}
} catch (InterruptedException e) {
throw new SQLException(
"Error occurred while advancing the cursor. This could happen when connection is closed while we call the next method");
"Error occurred while advancing the cursor. This could happen when connection is closed"
+ " while we call the next method");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ static PeriodDuration parseCanonicalInterval(String interval) throws IllegalArgu
// Pattern is [sign]Y-M [sign]D [sign]H:M:S[.F]
Pattern pattern =
Pattern.compile(
"(?<sign1>[+-])?(?<year>\\d+)-(?<month>\\d+) (?<sign2>[-|+])?(?<day>\\d+) (?<sign3>[-|+])?(?<hours>\\d+):(?<minutes>\\d+):(?<seconds>\\d+)(\\.(?<fraction>\\d+))?");
"(?<sign1>[+-])?(?<year>\\d+)-(?<month>\\d+) (?<sign2>[-|+])?(?<day>\\d+)"
+ " (?<sign3>[-|+])?(?<hours>\\d+):(?<minutes>\\d+):(?<seconds>\\d+)(\\.(?<fraction>\\d+))?");
Comment on lines 440 to +443

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the regular expression pattern, the character classes (?<sign2>[-|+])? and (?<sign3>[-|+])? contain a literal | character. Inside a regex character class [...], the | character is treated as a literal rather than an alternation operator. This means the pattern would incorrectly match a literal | as a sign. It should be simplified to [+-] (or [-+]) to only match + or - signs, consistent with (?<sign1>[+-])?.

    Pattern pattern =
        Pattern.compile(
            "(?<sign1>[+-])?(?<year>\d+)-(?<month>\d+) (?<sign2>[+-])?(?<day>\d+)"
                + " (?<sign3>[+-])?(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)(\.(?<fraction>\d+))?");

Matcher matcher = pattern.matcher(interval);
if (!matcher.find()) {
throw new IllegalArgumentException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public FieldValue get(int index) {
public FieldValue get(String name) {
if (schema == null) {
throw new UnsupportedOperationException(
"Retrieving field value by name is not supported when there is no fields schema provided");
"Retrieving field value by name is not supported when there is no fields schema"
+ " provided");
}
return get(schema.getIndex(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ static void validateTimestamp(String timestamp) {
// matches the fraction section as long as they are digits.
if (fraction.length() > 12) {
throw new IllegalArgumentException(
"Fractional second portion of ISO8601 only supports up to picosecond (12 digits) in BigQuery");
"Fractional second portion of ISO8601 only supports up to picosecond (12 digits) in"
+ " BigQuery");
}

// Replace the entire fractional second portion with just the nanosecond portion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ private void validateRPC() throws BigQueryException, IOException {
if (!this.options.hasValidUniverseDomain()) {
String errorMessage =
String.format(
"The configured universe domain %s does not match the universe domain found in the credentials %s. If you haven't configured the universe domain explicitly, `googleapis.com` is the default.",
"The configured universe domain %s does not match the universe domain found in the"
+ " credentials %s. If you haven't configured the universe domain explicitly,"
+ " `googleapis.com` is the default.",
this.options.getUniverseDomain(), this.options.getCredentials().getUniverseDomain());
throw new BigQueryException(HTTP_UNAUTHORIZED, errorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class ConnectionImplTest {
private static final String SQL_QUERY =
"SELECT county, state_name FROM bigquery_test_dataset.large_data_testing_table limit 2";
private static final String DRY_RUN_SQL =
"SELECT county, state_name FROM bigquery_test_dataset.large_data_testing_table where country = ?";
"SELECT county, state_name FROM bigquery_test_dataset.large_data_testing_table where country"
+ " = ?";
private static final int DEFAULT_PAGE_SIZE = 10000;
private ConnectionSettings connectionSettings;
private static final Schema QUERY_SCHEMA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public void testFromPbWithUnexpectedTimePartitioningTypeRaisesInvalidArgumentExc
IllegalArgumentException.class, () -> StandardTableDefinition.fromPb(invalidTable));
Truth.assertThat(ie.getMessage())
.contains(
"Illegal Argument - Got unexpected time partitioning GHURRY in project ILLEGAL_ARG_TEST_PROJECT in dataset ILLEGAL_ARG_TEST_DATASET in table ILLEGAL_ARG_TEST_TABLE");
"Illegal Argument - Got unexpected time partitioning GHURRY in project"
+ " ILLEGAL_ARG_TEST_PROJECT in dataset ILLEGAL_ARG_TEST_DATASET in table"
+ " ILLEGAL_ARG_TEST_TABLE");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ void insert_highPrecisionTimestamp_invalidFormats() {
void queryNamedParameter_highPrecisionTimestamp() throws InterruptedException {
String query =
String.format(
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS TIMESTAMP(12))",
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS"
+ " TIMESTAMP(12))",
DATASET, defaultTableId.getTable());

QueryJobConfiguration queryConfig =
Expand Down Expand Up @@ -262,7 +263,8 @@ void queryPositionalParameter_highPrecisionTimestamp() throws InterruptedExcepti
void queryNamedParameter_highPrecisionTimestamp_microsLong() throws InterruptedException {
String query =
String.format(
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS TIMESTAMP(12))",
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS"
+ " TIMESTAMP(12))",
DATASET, defaultTableId.getTable());

QueryJobConfiguration queryConfig =
Expand Down Expand Up @@ -293,7 +295,8 @@ void queryNamedParameter_highPrecisionTimestamp_microsLong() throws InterruptedE
void queryNamedParameter_highPrecisionTimestamp_microsISOString() throws InterruptedException {
String query =
String.format(
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS TIMESTAMP(12))",
"SELECT * FROM %s.%s WHERE timestampHighPrecisionField >= CAST(@timestampParam AS"
+ " TIMESTAMP(12))",
DATASET, defaultTableId.getTable());

QueryJobConfiguration queryConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ public class ITNightlyBigQueryTest {
private static BigQuery globalBigQuery;

private static final String BASE_QUERY =
"select StringField, GeographyField, BooleanField, BigNumericField, IntegerField, NumericField, BytesField, "
+ "TimestampField, TimeField, DateField, IntegerArrayField, RecordField.BooleanField, RecordField.StringField ,"
+ " JSONField, JSONField.hello, JSONField.id from %s.%s order by IntegerField asc LIMIT %s";
"select StringField, GeographyField, BooleanField, BigNumericField, IntegerField,"
+ " NumericField, BytesField, TimestampField, TimeField, DateField, IntegerArrayField, "
+ " RecordField.BooleanField, RecordField.StringField , JSONField, JSONField.hello,"
+ " JSONField.id from %s.%s order by IntegerField asc LIMIT %s";
private static final String POSITIONAL_QUERY =
String.format(
"select RecordField.BooleanField, RecordField.StringField, StringField, BooleanField, BytesField, IntegerField, GeographyField, NumericField, BigNumericField, TimeField, DateField, TimestampField, JSONField from %s.%s where DateField = ? and BooleanField = ? and IntegerField > ? and NumericField > ? LIMIT %s",
"select RecordField.BooleanField, RecordField.StringField, StringField, BooleanField,"
+ " BytesField, IntegerField, GeographyField, NumericField, BigNumericField,"
+ " TimeField, DateField, TimestampField, JSONField from %s.%s where DateField = ?"
+ " and BooleanField = ? and IntegerField > ? and NumericField > ? LIMIT %s",
DATASET, TABLE, MULTI_LIMIT_RECS);
private static final String QUERY = String.format(BASE_QUERY, DATASET, TABLE, LIMIT_RECS);
private static final String MULTI_QUERY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public void testGetDatasetTelemetry() throws Exception {
@Test
public void testListDatasetsTelemetry() throws Exception {
setMockResponse(
"{\"kind\":\"bigquery#datasetList\",\"datasets\":[], \"nextPageToken\":\"next-page-token\"}");
"{\"kind\":\"bigquery#datasetList\",\"datasets\":[],"
+ " \"nextPageToken\":\"next-page-token\"}");

rpc.listDatasetsSkipExceptionTranslation(PROJECT_ID, new HashMap<>());

Expand All @@ -286,7 +287,8 @@ public void testListDatasetsTelemetry() throws Exception {
@Test
public void testListProjects() throws Exception {
setMockResponse(
"{\"kind\":\"bigquery#projectList\",\"projects\":[{\"id\":\"p1\",\"friendlyName\":\"Project 1\"}], \"nextPageToken\":\"token2\"}");
"{\"kind\":\"bigquery#projectList\",\"projects\":[{\"id\":\"p1\",\"friendlyName\":\"Project"
+ " 1\"}], \"nextPageToken\":\"token2\"}");

Map<BigQueryRpc.Option, Object> options = new java.util.HashMap<>();
options.put(BigQueryRpc.Option.MAX_RESULTS, 10L);
Expand Down Expand Up @@ -593,7 +595,8 @@ public void testGetRoutineTelemetry() throws Exception {
@Test
public void testListRoutinesTelemetry() throws Exception {
setMockResponse(
"{\"kind\":\"bigquery#routineList\",\"routines\":[], \"nextPageToken\":\"next-page-token\"}");
"{\"kind\":\"bigquery#routineList\",\"routines\":[],"
+ " \"nextPageToken\":\"next-page-token\"}");

rpc.listRoutinesSkipExceptionTranslation(PROJECT_ID, DATASET_ID, new HashMap<>());

Expand Down Expand Up @@ -1117,7 +1120,9 @@ public void testHttpTracingEnabled_JsonResponseException_SetsAttributes() throws
mockResponse.setStatusCode(400);
mockResponse.setContentType(Json.MEDIA_TYPE);
mockResponse.setContent(
"{\"error\":{\"code\":400,\"message\":\"Invalid request\",\"errors\":[{\"message\":\"Invalid request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}");
"{\"error\":{\"code\":400,\"message\":\"Invalid"
+ " request\",\"errors\":[{\"message\":\"Invalid"
+ " request\",\"domain\":\"global\",\"reason\":\"invalid\"}]}}");

assertThrows(
IOException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,35 @@ class RemoteBigQueryHelperTest {
private static final String JSON_KEY =
"{\n"
+ " \"private_key_id\": \"somekeyid\",\n"
+ " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS"
+ "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg"
+ "aR\\n0Pmxh3ILCND5men43j3h4e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6ak\\nECR"
+ "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl"
+ "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa"
+ "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi"
+ "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG"
+ "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk"
+ "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n"
+ " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\n"
+ "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+K2hSuFpAdrJI\\n"
+ "nCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHgaR\\n"
+ "0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\n"
+ "QP/9dJfIkIDJ9Fw9N4Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\n"
+ "knddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2LgczOjwWHGi99MFjxSer5m9\\n"
+ "1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa\\n"
+ "dYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n"
+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xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\n"
+ "EfeFCoOX75MxKwXs6xgrw4W//AYGGUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\n"
+ "HtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKkXyRDW4IG1Oa2p\\n"
+ "rALStNBx5Y9t0/LQnFI4w3aG\\n"
+ "-----END PRIVATE KEY-----\\n"
+ "\",\n"
+ " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n"
+ " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n"
+ " \"type\": \"service_account\"\n"
Expand Down
Loading