|
54 | 54 | def test_generate_bq_schema(dataframe, expected_schema): |
55 | 55 | schema = pandas_gbq.schema.generate_bq_schema(dataframe) |
56 | 56 | assert schema == expected_schema |
| 57 | + |
| 58 | + |
| 59 | +@pytest.mark.parametrize( |
| 60 | + "schema_old,schema_new,expected_output", |
| 61 | + [ |
| 62 | + ( |
| 63 | + {"fields": [{"name": "col1", "type": "INTEGER"}]}, |
| 64 | + {"fields": [{"name": "col2", "type": "TIMESTAMP"}]}, |
| 65 | + { |
| 66 | + "fields": [ |
| 67 | + {"name": "col1", "type": "INTEGER"}, |
| 68 | + {"name": "col2", "type": "TIMESTAMP"}, |
| 69 | + ] |
| 70 | + }, |
| 71 | + ), |
| 72 | + ( |
| 73 | + {"fields": [{"name": "col1", "type": "INTEGER"}]}, |
| 74 | + {"fields": [{"name": "col1", "type": "BOOLEAN"}]}, |
| 75 | + {"fields": [{"name": "col1", "type": "BOOLEAN"}]}, |
| 76 | + ), |
| 77 | + ( |
| 78 | + { |
| 79 | + "fields": [ |
| 80 | + {"name": "col1", "type": "INTEGER"}, |
| 81 | + {"name": "col2", "type": "INTEGER"}, |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "fields": [ |
| 86 | + {"name": "col2", "type": "BOOLEAN"}, |
| 87 | + {"name": "col3", "type": "FLOAT"}, |
| 88 | + ] |
| 89 | + }, |
| 90 | + { |
| 91 | + "fields": [ |
| 92 | + {"name": "col1", "type": "INTEGER"}, |
| 93 | + {"name": "col2", "type": "BOOLEAN"}, |
| 94 | + {"name": "col3", "type": "FLOAT"}, |
| 95 | + ] |
| 96 | + }, |
| 97 | + ), |
| 98 | + ], |
| 99 | +) |
| 100 | +def test_update_schema(schema_old, schema_new, expected_output): |
| 101 | + output = pandas_gbq.schema.update_schema(schema_old, schema_new) |
| 102 | + assert output == expected_output |
0 commit comments