gogol
gogol copied to clipboard
BigQuery: Not able to create a simple(non-partitioned) table
let tableToCreate =
-- tabTimePartitioning .~ Just (tpField .~ Just "at" $
-- timePartitioning) $
tabLocation .~ Just bigQueryTableLocation $
tabTableReference .~ Just (trDataSetId .~ Just dataSetId $
trProjectId .~ Just projectId $
trTableId .~ Just tableId $
tableReference) $
tabSchema .~ (schemaTable ^. tabSchema) $
table
If I try to create the above table using tablesInsert
, I get an exception:
*** Exception: ServiceError (ServiceError' {_serviceId = ServiceId "bigquery:v2", _serviceStatus = Status {statusCode = 400, statusMessage = "Bad Request"}, _serviceHeaders = [("Vary","Origin"), ("Vary","X-Origin"),("Vary","Referer"),("Content-Type","application/json; charset=UTF-8"), ("Content-Encoding","gzip"),("Date","Mon, 16 Sep 2019 12:55:47 GMT"),("Server","ESF"),("Cache-Control","private"), ("X-XSS-Protection","0"),("X-Frame-Options","SAMEORIGIN"),("X-Content-Type-Options","nosniff"), ("Alt-Svc","quic=\":443\"; ma=2592000; v=\"46,43,39\""),("Transfer-Encoding","chunked")], _serviceBody = Just "{\n \"error\": {\n \"code\": 400,\n \"message\":\"Either interval partition or range partition should be specified.\",\n \"errors\": [\n {\n \"message\": \"Either interval partition or range partition should be specified.\",\n \"domain\": \"global\",\n \"reason\": \"invalid\"\n }\n ],\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n"})
But if I provide the tabTimePartitioning
(commented out in code), it works fine and creates a partitioned table.
Version: gogol-bigquery-0.4.0
Old ticket, but had the same problem recently, which caused by the Table schema having a field requirePartitionFilter with a default value of false. The JSON request sent to the BigQuery API then contains
"requirePartitionFilter":false
which causes the error because the field should be present only if the table is partitioned. Modifying the request yo remove that field avoids the problem.
So fundamentally it's a problem with the BigQuery Table resource JSON schema definition.