Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(csharp/src/Drivers/BigQuery): return null on GetValue exception #1562

Merged
merged 3 commits into from
Feb 22, 2024
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
5 changes: 4 additions & 1 deletion csharp/src/Drivers/BigQuery/BigQueryConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@
if (!this.properties.TryGetValue(BigQueryParameters.ProjectId, out projectId))
throw new ArgumentException($"The {BigQueryParameters.ProjectId} parameter is not present");

if (this.properties.TryGetValue(BigQueryParameters.AuthenticationType, out authenticationType))
if (this.properties.TryGetValue(BigQueryParameters.AuthenticationType, out string? newAuthenticationType))
{
if (!string.IsNullOrEmpty(newAuthenticationType))
authenticationType = newAuthenticationType;

if (!authenticationType.Equals(BigQueryConstants.UserAuthenticationType, StringComparison.OrdinalIgnoreCase) &&
!authenticationType.Equals(BigQueryConstants.ServiceAccountAuthenticationType, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -429,7 +432,7 @@
{
bool includeConstraints = true;

if (this.properties.TryGetValue(BigQueryParameters.IncludeConstraintsWithGetObjects, out string includeConstraintsValue))

Check warning on line 435 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Converting null literal or possible null value to non-nullable type.

Check warning on line 435 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Converting null literal or possible null value to non-nullable type.

Check warning on line 435 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Converting null literal or possible null value to non-nullable type.
{
bool.TryParse(includeConstraintsValue, out includeConstraints);
}
Expand Down Expand Up @@ -1023,7 +1026,7 @@
Open();
}

BigQueryStatement statement = new BigQueryStatement(this.client, this.credential);

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.

Check warning on line 1029 in csharp/src/Drivers/BigQuery/BigQueryConnection.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference argument for parameter 'client' in 'BigQueryStatement.BigQueryStatement(BigQueryClient client, GoogleCredential credential)'.
statement.Options = ParseOptions();
return statement;
}
Expand Down
3 changes: 3 additions & 0 deletions csharp/src/Drivers/BigQuery/BigQueryStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@

private Dictionary<String, object> ParseStructArray(StructArray structArray, int index)
{
if (structArray.IsNull(index))
return null;

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.

Check warning on line 237 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.

Dictionary<String, object> jsonDictionary = new Dictionary<String, object>();
StructType structType = (StructType)structArray.Data.DataType;
for (int i = 0; i < structArray.Data.Children.Length; i++)
Expand Down Expand Up @@ -372,7 +375,7 @@
{
if (this.readers == null)
{
return null;

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.

Check warning on line 378 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.
}

while (true)
Expand All @@ -382,7 +385,7 @@
if (!this.readers.MoveNext())
{
Dispose(); // TODO: Remove this line
return null;

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# ubuntu-latest

Possible null reference return.

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# windows-2019

Possible null reference return.

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.

Check warning on line 388 in csharp/src/Drivers/BigQuery/BigQueryStatement.cs

View workflow job for this annotation

GitHub Actions / C# macos-latest

Possible null reference return.
}
this.reader = this.readers.Current;
}
Expand Down
Loading