MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ReadSchema

Method ReadSchema

tensorflow/contrib/cloud/kernels/bigquery_table_accessor.cc:249–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249Status BigQueryTableAccessor::ReadSchema() {
250 string auth_token;
251 TF_RETURN_IF_ERROR(AuthProvider::GetToken(auth_provider_.get(), &auth_token));
252
253 // Send a request to read the schema.
254 std::unique_ptr<HttpRequest> request(http_request_factory_->Create());
255 std::vector<char> output_buffer;
256 output_buffer.reserve(kBufferSize);
257 request->SetUri(BigQueryUriPrefix());
258 request->AddAuthBearerHeader(auth_token);
259 request->SetResultBuffer(&output_buffer);
260 TF_RETURN_WITH_CONTEXT_IF_ERROR(request->Send(), " when reading schema for ",
261 FullTableName());
262
263 // Parse the schema.
264 StringPiece response_piece =
265 StringPiece(&output_buffer[0], output_buffer.size());
266
267 Json::Value root;
268 TF_RETURN_IF_ERROR(ParseJson(response_piece, &root));
269 const auto& columns = root["schema"]["fields"];
270 string column_name_prefix = "";
271 schema_root_ = {"", ColumnType::kNone};
272 TF_RETURN_IF_ERROR(
273 ExtractColumnType(columns, column_name_prefix, &schema_root_));
274 if (root["numRows"].isNull()) {
275 return errors::Internal("Number of rows cannot be extracted for table ",
276 FullTableName());
277 }
278 strings::safe_strto64(root["numRows"].asString().c_str(), &total_num_rows_);
279 return Status::OK();
280}
281
282Status BigQueryTableAccessor::ExtractColumnType(
283 const Json::Value& columns, const string& column_name_prefix,

Callers 1

NewMethod · 0.80

Calls 12

InternalFunction · 0.85
safe_strto64Function · 0.85
c_strMethod · 0.80
ParseJsonFunction · 0.70
getMethod · 0.45
CreateMethod · 0.45
reserveMethod · 0.45
SetUriMethod · 0.45
AddAuthBearerHeaderMethod · 0.45
SetResultBufferMethod · 0.45
SendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected