@@ -444,17 +444,22 @@ def create_table(
444
444
schema : ibis .Schema | None = None ,
445
445
database : str | None = None ,
446
446
) -> None :
447
- if obj is not None :
448
- raise NotImplementedError (
449
- "Parameter obj is not supported for create_table method in BigQuery backend"
450
- )
451
- if schema is None :
452
- raise ValueError ("Schema is required" )
453
-
454
- table_id = self ._fully_qualified_name (name , database )
455
- bigquery_schema = ibis_schema_to_bigquery_schema (schema )
456
- table = bq .Table (table_id , schema = bigquery_schema )
457
- self .client .create_table (table )
447
+ if obj is None and schema is None :
448
+ raise ValueError ("The schema or obj parameter is required" )
449
+ if schema is not None :
450
+ table_id = self ._fully_qualified_name (name , database )
451
+ bigquery_schema = ibis_schema_to_bigquery_schema (schema )
452
+ table = bq .Table (table_id , schema = bigquery_schema )
453
+ self .client .create_table (table )
454
+ else :
455
+ project_id , dataset = self ._parse_project_and_dataset (database )
456
+ if isinstance (obj , pd .DataFrame ):
457
+ table = ibis .memtable (obj )
458
+ else :
459
+ table = obj
460
+ sql_select = self .compile (table )
461
+ table_ref = f"`{ project_id } `.`{ dataset } `.`{ name } `"
462
+ self .raw_sql (f'CREATE TABLE { table_ref } AS ({ sql_select } )' )
458
463
459
464
def drop_table (
460
465
self , name : str , database : str | None = None , force : bool = False
0 commit comments