bigrquery icon indicating copy to clipboard operation
bigrquery copied to clipboard

Unable to create partitioned tables...again

Open wenhsinhu opened this issue 3 years ago • 1 comments

Hi,

This issue is related to #359.

I tried to generate a partitioned table with the solutions within the above issue and encountered some problems. Not sure if this is caused by version updates.

  1. Specifiy the fields as json: for a json like this:
name = c('date','dummy_columnA','dummy_columnB')
type = c('DATE','STRING','INT64')
schema = jsonlite::toJSON(as.data.frame(cbind(name,type)))
schema
#> [{"name":"date","type":"DATE"},{"name":"dummy_columnA","type":"STRING"},{"name":"dummy_columnB","type":"INT64"}]

I tried the following scripts:

bigrquery::bq_table_create(x = bq_table, fields = schema,
            timePartitioning = list(timepartitioning = list(type='DAY', field= 'date'))
            )

an error returned

#> Error in UseMethod("as_bq_fields"): no applicable method for 'as_bq_fields' applied to an object of class "json"
  1. Specify the field as bq_fields
bq_fields <- bigrquery::as_bq_fields(list(bigrquery::bq_field('date','DATE'),
                                          bigrquery::bq_field('dummy_columnA','STRING'),
                                          bigrquery::bq_field('dummy_columnB','INT64')))


bigrquery::bq_table_create(x = bq_table, fields = bq_fields,
                timePartitioning = list(timepartitioning = list(type='DAY', field= 'date'))
)

A partitioned table is generated, whereas the field setting is not working.

截圖 2021-08-10 上午11 21 29

NOTES: The following bq commend works for me:

bq mk \
--schema=date:DATE,dummy_colA:STRING,dummy_colB:INTEGER \
 --time_partitioning_field=date \
 --time_partitioning_type=DAY bi_report.dummy_user_profile

截圖 2021-08-10 下午12 22 35

wenhsinhu avatar Aug 10 '21 04:08 wenhsinhu

You have double layer of timepartitoning lists. Can you double check the example from the previous issue

byapparov avatar Sep 11 '21 12:09 byapparov

Closing this since it's been 2 years without further communication.

hadley avatar Nov 03 '23 13:11 hadley