Tables
Module for dealing with BigQueryTables
BQTable
Represents a BigQuery table.
Source code in bquest/tables.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
fq_test_table_id: str
property
Returns the table identifier used for testing (e.g. bquest.example_id)
original_table_id: str
property
Returns the original table identifier (e.g. bquest.example_id)
__init__(original_table_id, fq_test_table_id, bq_client)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original_table_id |
str
|
original table id |
required |
fq_test_table_id |
str
|
full qualified test table id |
required |
bq_client |
Client
|
BigQuery client used for interacting with BigQuery |
required |
Source code in bquest/tables.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
delete()
Deletes the table
Source code in bquest/tables.py
76 77 78 |
|
remove_require_partition_filter(table_id)
Method to drop table partition filter requirement Args: table_id: table id
Returns:
Type | Description |
---|---|
None
|
None - table settings updated in place |
Source code in bquest/tables.py
50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
to_df()
Loads the table into a dataframe
Returns:
Type | Description |
---|---|
DataFrame
|
Loaded table as pandas dataframe |
Source code in bquest/tables.py
64 65 66 67 68 69 70 71 72 73 74 |
|
BQTableDataframeDefinition
Bases: BQTableDefinition
Defines BigQuery tables based on a pandas dataframe.
Source code in bquest/tables.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
__init__(original_table_id, df, project, dataset, location)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original_table_id |
str
|
table name |
required |
df |
DataFrame
|
pandas DataFrame that is loaded |
required |
project |
str
|
Google Cloud project id |
required |
dataset |
str
|
dataset name e.g. bquest |
required |
location |
str
|
location of dataset e.g. EU |
required |
Source code in bquest/tables.py
136 137 138 139 140 141 142 143 144 145 146 147 |
|
load_to_bq(bq_client)
Loads this definition to a BigQuery table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bq_client |
Client
|
A BigQuery client |
required |
Returns:
Name | Type | Description |
---|---|---|
BQTable |
BQTable
|
A representative of the BigQuery table which was created. |
Source code in bquest/tables.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
BQTableDefinition
Base class for BigQuery table definitions.
Source code in bquest/tables.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
fq_table_id: str
property
Returns the fully qualified table name in the form {project_name}.{dataset}.{table_name}
__init__(original_table_id, project, dataset, location)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
table name |
required | |
project |
str
|
Google Cloud project id |
required |
dataset |
str
|
dataset name e.g. bquest |
required |
location |
str
|
location of dataset e.g. EU |
required |
Source code in bquest/tables.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
BQTableDefinitionBuilder
Helper class for building BQTableDefinitions
Source code in bquest/tables.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
__init__(project, dataset='bquest', location='EU')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
str
|
Google Cloud project |
required |
dataset |
str
|
BigQuery dataset e.g. bquest |
'bquest'
|
location |
str
|
location of dataset e.g. EU |
'EU'
|
Source code in bquest/tables.py
241 242 243 244 245 246 247 248 249 250 251 |
|
BQTableJsonDefinition
Bases: BQTableDefinition
Defines BigQuery tables based on a JSON format.
Source code in bquest/tables.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
__init__(original_table_id, rows, schema, project, dataset, location)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original_table_id |
str
|
table name |
required |
rows |
List[Dict[str, Any]]
|
json-like rows |
required |
schema |
Optional[List[SchemaField]]
|
schema of the data |
required |
project |
str
|
Google Cloud project |
required |
dataset |
str
|
dataset name e.g. bquest |
required |
location |
str
|
location of dataset e.g. EU |
required |
Source code in bquest/tables.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
load_to_bq(bq_client)
Loads this definition to a BigQuery table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bq_client |
Client
|
BigQuery client for interacting with BigQuery |
required |
Returns:
Name | Type | Description |
---|---|---|
BQTable |
BQTable
|
A representative of the BigQuery table which was created. |
Source code in bquest/tables.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|