File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -1152,10 +1152,8 @@ def create_table(
11521152
11531153 if partition_by is not None :
11541154 properties .append (
1155- sge .PartitionedByProperty (
1156- this = sge .Tuple (
1157- expressions = list (map (sg .to_identifier , partition_by ))
1158- )
1155+ sg .parse_one (
1156+ partition_by , into = sge .PartitionedByProperty , read = "bigquery"
11591157 )
11601158 )
11611159
Original file line number Diff line number Diff line change @@ -408,6 +408,40 @@ def test_create_table_with_options(con):
408408 con .drop_table (name )
409409
410410
411+ def test_create_table_with_partition_by_range_expr (con ):
412+ name = gen_name ("bigquery_temp_table" )
413+ schema = ibis .schema (dict (abc = "int64" ))
414+ t = con .create_table (
415+ name ,
416+ schema = schema ,
417+ overwrite = True ,
418+ partition_by = "RANGE_BUCKET(abc, GENERATE_ARRAY(0, 64))" ,
419+ )
420+ try :
421+ table = t .execute ()
422+ assert table .empty
423+ assert list (table .columns ) == ["abc" ]
424+ finally :
425+ con .drop_table (name )
426+
427+
428+ def test_create_table_with_partition_by_time_expr (con ):
429+ name = gen_name ("bigquery_temp_table" )
430+ schema = ibis .schema (dict (abc = "timestamp" ))
431+ t = con .create_table (
432+ name ,
433+ schema = schema ,
434+ overwrite = True ,
435+ partition_by = "TIMESTAMP_TRUNC(abc, HOUR)" ,
436+ )
437+ try :
438+ table = t .execute ()
439+ assert table .empty
440+ assert list (table .columns ) == ["abc" ]
441+ finally :
442+ con .drop_table (name )
443+
444+
411445def test_create_temp_table_from_scratch (project_id , dataset_id ):
412446 con = ibis .bigquery .connect (project_id = project_id , dataset_id = dataset_id )
413447 name = gen_name ("bigquery_temp_table" )
You can’t perform that action at this time.
0 commit comments