Skip to content

Commit f6e2b31

Browse files
impl(bq_driver): Picosecond support (#15925)
1 parent 03beb82 commit f6e2b31

5 files changed

Lines changed: 12 additions & 3 deletions

File tree

google/cloud/bigquery/v2/minimal/benchmarks/benchmarks_config.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ google::cloud::StatusOr<JobConfig> JobConfig::ParseArgs(
359359
flags_.push_back(
360360
{"--use-int64-timestamp=", "outputs timestamp as usec int64",
361361
[this](std::string const& v) { use_int64_timestamp = (v == "true"); }});
362+
flags_.push_back(
363+
{"--timestamp-output-format=", "sets timestamp output format",
364+
[this](std::string const& v) { timestamp_output_format = v; }});
362365
flags_.push_back(
363366
{"--min-creation-time=",
364367
"min job creation time. If set, only jobs created after or at this "

google/cloud/bigquery/v2/minimal/benchmarks/benchmarks_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct JobConfig : public Config {
100100
int start_index = 0;
101101
int timeout_ms;
102102
bool use_int64_timestamp;
103+
std::string timestamp_output_format;
103104

104105
bigquery_v2_minimal_internal::Projection projection;
105106
bigquery_v2_minimal_internal::StateFilter state_filter;

google/cloud/bigquery/v2/minimal/internal/job_request.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ std::string DataFormatOptions::DebugString(absl::string_view name,
343343
int indent) const {
344344
return internal::DebugFormatter(name, options, indent)
345345
.Field("use_int64_timestamp", use_int64_timestamp)
346+
.Field("timestamp_output_format", timestamp_output_format)
346347
.Build();
347348
}
348349

google/cloud/bigquery/v2/minimal/internal/job_request.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,17 @@ class CancelJobRequest {
311311

312312
struct DataFormatOptions {
313313
DataFormatOptions() = default;
314+
314315
bool use_int64_timestamp = false;
316+
std::string timestamp_output_format = "TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED";
315317

316318
std::string DebugString(absl::string_view name,
317319
TracingOptions const& options = {},
318320
int indent = 0) const;
319321
};
320322
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(DataFormatOptions,
321-
use_int64_timestamp);
323+
use_int64_timestamp,
324+
timestamp_output_format);
322325

323326
// Indicates the type of compute mode for the query stage.
324327
//

google/cloud/bigquery/v2/minimal/internal/job_request_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ TEST(PostQueryRequestTest, DebugString) {
10281028
R"( parameter_value { value: "query-parameter-value" } })"
10291029
R"( labels { key: "lk1" value: "lv1" } labels { key: "lk2" value: "lv2" })"
10301030
R"( default_dataset { project_id: "2" dataset_id: "1" })"
1031-
R"( format_options { use_int64_timestamp: true })"
1031+
R"( format_options { use_int64_timestamp: true timestamp_output_format: TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED })"
10321032
R"( job_creation_mode { value: "JOB_CREATION_MODE_UNSPECIFIED" } } })");
10331033

10341034
EXPECT_EQ(
@@ -1049,7 +1049,7 @@ TEST(PostQueryRequestTest, DebugString) {
10491049
R"( parameter_value { value: "query-p...<truncated>..." } })"
10501050
R"( labels { key: "lk1" value: "lv1" } labels { key: "lk2" value: "lv2" })"
10511051
R"( default_dataset { project_id: "2" dataset_id: "1" })"
1052-
R"( format_options { use_int64_timestamp: true })"
1052+
R"( format_options { use_int64_timestamp: true timestamp_output_format: TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED })"
10531053
R"( job_creation_mode { value: "JOB_CRE...<truncated>..." } } })");
10541054

10551055
EXPECT_EQ(request.DebugString("PostQueryRequest", TracingOptions{}.SetOptions(
@@ -1103,6 +1103,7 @@ TEST(PostQueryRequestTest, DebugString) {
11031103
}
11041104
format_options {
11051105
use_int64_timestamp: true
1106+
timestamp_output_format: TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED
11061107
}
11071108
job_creation_mode {
11081109
value: "JOB_CREATION_MODE_UNSPECIFIED"

0 commit comments

Comments
 (0)