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

BigQuery: Not able to create a simple(non-partitioned) table #140

Open
puneetpahuja opened this issue Sep 16, 2019 · 1 comment
Open

BigQuery: Not able to create a simple(non-partitioned) table #140

puneetpahuja opened this issue Sep 16, 2019 · 1 comment

Comments

@puneetpahuja
Copy link

puneetpahuja commented Sep 16, 2019

 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

@glep207
Copy link

glep207 commented Sep 19, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants