@@ -435,6 +435,12 @@ def _make_resource(self):
435435 "sourceFormat" : "CSV" ,
436436 "csvOptions" : {"allowJaggedRows" : True , "encoding" : "encoding" },
437437 },
438+ "biglakeConfiguration" : {
439+ "connectionId" : "connection" ,
440+ "storageUri" : "uri" ,
441+ "fileFormat" : "PARQUET" ,
442+ "tableFormat" : "ICEBERG" ,
443+ },
438444 "labels" : {"x" : "y" },
439445 }
440446
@@ -521,6 +527,15 @@ def _verifyResourceProperties(self, table, resource):
521527 else :
522528 self .assertIsNone (table .encryption_configuration )
523529
530+ if "biglakeConfiguration" in resource :
531+ self .assertIsNotNone (table .biglake_configuration )
532+ self .assertEqual (table .biglake_configuration .connection_id , "connection" )
533+ self .assertEqual (table .biglake_configuration .storage_uri , "uri" )
534+ self .assertEqual (table .biglake_configuration .file_format , "PARQUET" )
535+ self .assertEqual (table .biglake_configuration .table_format , "ICEBERG" )
536+ else :
537+ self .assertIsNone (table .biglake_configuration )
538+
524539 def test_ctor (self ):
525540 dataset = DatasetReference (self .PROJECT , self .DS_ID )
526541 table_ref = dataset .table (self .TABLE_NAME )
@@ -893,6 +908,60 @@ def test_table_constraints_property_getter(self):
893908 assert isinstance (table_constraints , TableConstraints )
894909 assert table_constraints .primary_key == PrimaryKey (columns = ["id" ])
895910
911+ def test_biglake_configuration_not_set (self ):
912+ dataset = DatasetReference (self .PROJECT , self .DS_ID )
913+ table_ref = dataset .table (self .TABLE_NAME )
914+ table = self ._make_one (table_ref )
915+
916+ assert table .biglake_configuration is None
917+
918+ def test_biglake_configuration_set (self ):
919+ from google .cloud .bigquery .table import BigLakeConfiguration
920+
921+ dataset = DatasetReference (self .PROJECT , self .DS_ID )
922+ table_ref = dataset .table (self .TABLE_NAME )
923+ table = self ._make_one (table_ref )
924+
925+ table ._properties ["biglakeConfiguration" ] = {
926+ "connectionId" : "connection" ,
927+ "storageUri" : "uri" ,
928+ "fileFormat" : "PARQUET" ,
929+ "tableFormat" : "ICEBERG" ,
930+ }
931+
932+ config = table .biglake_configuration
933+
934+ assert isinstance (config , BigLakeConfiguration )
935+ assert config .connection_id == "connection"
936+ assert config .storage_uri == "uri"
937+ assert config .file_format == "PARQUET"
938+ assert config .table_format == "ICEBERG"
939+
940+ def test_biglake_configuration_property_setter (self ):
941+ from google .cloud .bigquery .table import BigLakeConfiguration
942+
943+ dataset = DatasetReference (self .PROJECT , self .DS_ID )
944+ table_ref = dataset .table (self .TABLE_NAME )
945+ table = self ._make_one (table_ref )
946+
947+ config = BigLakeConfiguration (
948+ connection_id = "connection" ,
949+ storage_uri = "uri" ,
950+ file_format = "PARQUET" ,
951+ table_format = "ICEBERG" ,
952+ )
953+ table .biglake_configuration = config
954+
955+ assert table ._properties ["biglakeConfiguration" ] == {
956+ "connectionId" : "connection" ,
957+ "storageUri" : "uri" ,
958+ "fileFormat" : "PARQUET" ,
959+ "tableFormat" : "ICEBERG" ,
960+ }
961+
962+ table .biglake_configuration = None
963+ assert table .biglake_configuration is None
964+
896965 def test_table_constraints_property_setter (self ):
897966 from google .cloud .bigquery .table import (
898967 ColumnReference ,
@@ -2166,6 +2235,97 @@ def test_ctor_full_resource(self):
21662235 assert instance .snapshot_time == expected_time
21672236
21682237
2238+ class TestBigLakeConfiguration (unittest .TestCase ):
2239+ @staticmethod
2240+ def _get_target_class ():
2241+ from google .cloud .bigquery .table import BigLakeConfiguration
2242+
2243+ return BigLakeConfiguration
2244+
2245+ @classmethod
2246+ def _make_one (cls , * args , ** kwargs ):
2247+ klass = cls ._get_target_class ()
2248+ return klass (* args , ** kwargs )
2249+
2250+ def test_ctor_empty_resource (self ):
2251+ instance = self ._make_one ()
2252+ self .assertIsNone (instance .connection_id )
2253+ self .assertIsNone (instance .storage_uri )
2254+ self .assertIsNone (instance .file_format )
2255+ self .assertIsNone (instance .table_format )
2256+
2257+ def test_ctor_kwargs (self ):
2258+ instance = self ._make_one (
2259+ connection_id = "conn" ,
2260+ storage_uri = "uri" ,
2261+ file_format = "FILE" ,
2262+ table_format = "TABLE" ,
2263+ )
2264+ self .assertEqual (instance .connection_id , "conn" )
2265+ self .assertEqual (instance .storage_uri , "uri" )
2266+ self .assertEqual (instance .file_format , "FILE" )
2267+ self .assertEqual (instance .table_format , "TABLE" )
2268+
2269+ def test_ctor_full_resource (self ):
2270+ resource = {
2271+ "connectionId" : "conn" ,
2272+ "storageUri" : "uri" ,
2273+ "fileFormat" : "FILE" ,
2274+ "tableFormat" : "TABLE" ,
2275+ }
2276+ instance = self ._make_one (_properties = resource )
2277+ self .assertEqual (instance .connection_id , "conn" )
2278+ self .assertEqual (instance .storage_uri , "uri" )
2279+ self .assertEqual (instance .file_format , "FILE" )
2280+ self .assertEqual (instance .table_format , "TABLE" )
2281+
2282+ def test_to_api_repr (self ):
2283+ resource = {
2284+ "connectionId" : "conn" ,
2285+ "storageUri" : "uri" ,
2286+ "fileFormat" : "FILE" ,
2287+ "tableFormat" : "TABLE" ,
2288+ }
2289+ instance = self ._make_one (_properties = resource )
2290+ self .assertEqual (instance .to_api_repr (), resource )
2291+
2292+ def test_from_api_repr_partial (self ):
2293+ klass = self ._get_target_class ()
2294+ api_repr = {"fileFormat" : "FILE" }
2295+ instance = klass .from_api_repr (api_repr )
2296+
2297+ self .assertIsNone (instance .connection_id )
2298+ self .assertIsNone (instance .storage_uri )
2299+ self .assertEqual (instance .file_format , "FILE" )
2300+ self .assertIsNone (instance .table_format )
2301+
2302+ def test_comparisons (self ):
2303+ resource = {
2304+ "connectionId" : "conn" ,
2305+ "storageUri" : "uri" ,
2306+ "fileFormat" : "FILE" ,
2307+ "tableFormat" : "TABLE" ,
2308+ }
2309+
2310+ first = self ._make_one (_properties = resource )
2311+ second = self ._make_one (_properties = copy .deepcopy (resource ))
2312+ # Exercise comparator overloads.
2313+ # first and second should be equivalent.
2314+ self .assertNotEqual (first , resource )
2315+ self .assertEqual (first , second )
2316+ self .assertEqual (hash (first ), hash (second ))
2317+
2318+ # Update second to ensure that first and second are no longer equivalent.
2319+ second .connection_id = "foo"
2320+ self .assertNotEqual (first , second )
2321+ self .assertNotEqual (hash (first ), hash (second ))
2322+
2323+ # Update first with the same change, restoring equivalence.
2324+ first .connection_id = "foo"
2325+ self .assertEqual (first , second )
2326+ self .assertEqual (hash (first ), hash (second ))
2327+
2328+
21692329class TestCloneDefinition :
21702330 @staticmethod
21712331 def _get_target_class ():
0 commit comments