Skip to content

chore(bigquery): migrate to std::optional#16210

Open
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:migrate-bigquery-optional
Open

chore(bigquery): migrate to std::optional#16210
colinmoy wants to merge 1 commit into
googleapis:mainfrom
colinmoy:migrate-bigquery-optional

Conversation

@colinmoy

Copy link
Copy Markdown

Replacing explicit usages of absl::optional with std::optional in the BigQuery Client library as part of broader modernization efforts

@colinmoy colinmoy requested a review from a team as a code owner June 26, 2026 21:58
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Jun 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the use of absl::optional with std::optional across several files in the BigQuery v2 minimal internal library, aligning with C++17 standards. The reviewer suggests returning std::optional<std::chrono::system_clock::time_point> by value instead of by const& in ListJobsRequest because it is a small, trivially copyable type, which avoids pointer indirection and potential lifetime issues.

Comment on lines +117 to 124
std::optional<std::chrono::system_clock::time_point> const&
min_creation_time() const {
return min_creation_time_;
}
absl::optional<std::chrono::system_clock::time_point> const&
std::optional<std::chrono::system_clock::time_point> const&
max_creation_time() const {
return max_creation_time_;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since std::chrono::system_clock::time_point is a small, trivially copyable type, std::optional<std::chrono::system_clock::time_point> is also small and cheap to copy. Returning it by value instead of by const& is more idiomatic in C++, avoids pointer indirection overhead, and prevents potential lifetime issues (dangling references) for callers.

  std::optional<std::chrono::system_clock::time_point>
  min_creation_time() const {
    return min_creation_time_;
  }
  std::optional<std::chrono::system_clock::time_point>
  max_creation_time() const {
    return max_creation_time_;
  }

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (e0b2850) to head (6b36030).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16210      +/-   ##
==========================================
- Coverage   92.24%   92.24%   -0.01%     
==========================================
  Files        2265     2265              
  Lines      210126   210126              
==========================================
- Hits       193839   193828      -11     
- Misses      16287    16298      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant