Query reference
Base query helpers
Source code in beacon_api/query/__init__.py
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 79 80 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 129 130 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 169 170 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 236 237 238 239 240 241 242 243 | |
compile_query()
Compile the query to a JSON string
Source code in beacon_api/query/__init__.py
execute(stream=False)
Run the query and return the response
Source code in beacon_api/query/__init__.py
execute_streaming(force=False)
Run the query and return the response as a streaming response
Source code in beacon_api/query/__init__.py
explain()
Get the query plan
Source code in beacon_api/query/__init__.py
output()
set_output(output_format)
to_arrow(file_path, streaming_chunk_size=1024 * 1024)
Execute the query and save the results as an Arrow file
Source code in beacon_api/query/__init__.py
to_csv(file_path, streaming_chunk_size=1024 * 1024)
Execute the query and save the results as a CSV file
Source code in beacon_api/query/__init__.py
to_geo_pandas_dataframe(longitude_column, latitude_column, crs='EPSG:4326')
Converts the query results to a GeoPandas GeoDataFrame.
Args: longitude_column (str): The name of the column representing longitude. latitude_column (str): The name of the column representing latitude. crs (str, optional): The coordinate reference system to use. Defaults to "EPSG:4326".
Returns: gpd.GeoDataFrame: The query results as a GeoPandas GeoDataFrame.
Source code in beacon_api/query/__init__.py
to_geoparquet(file_path, longitude_column, latitude_column, streaming_chunk_size=1024 * 1024)
Execute the query and save the results as a GeoParquet file
Source code in beacon_api/query/__init__.py
to_nd_netcdf(file_path, dimension_columns, streaming_chunk_size=1024 * 1024, force=False)
Execute the query and save the results as an NdNetCDF file
Source code in beacon_api/query/__init__.py
to_netcdf(file_path, build_nc_local=True, streaming_chunk_size=1024 * 1024)
Execute the query and save the results as an NetCDF file
Source code in beacon_api/query/__init__.py
to_odv(odv_output, file_path)
Exports the query results to an ODV file.
Args: odv_output (Odv): The ODV output format to use. file_path (str): The path to the file where the ODV data will be saved.
Source code in beacon_api/query/__init__.py
to_pandas_dataframe()
Execute the query and return the results as a pandas DataFrame
Source code in beacon_api/query/__init__.py
to_parquet(file_path, streaming_chunk_size=1024 * 1024)
Execute the query and save the results as a Parquet file
Source code in beacon_api/query/__init__.py
to_xarray_dataset(dimension_columns, chunks=None, auto_cleanup=True, force=False)
Converts the query results to an xarray Dataset with n-dimensional structure.
Args: dimension_columns (list[str]): The list of columns to use as dimensions in the xarray Dataset.
Returns: xarray.Dataset: The query results as an xarray Dataset.
Source code in beacon_api/query/__init__.py
JSON query builder
Bases: BaseQuery
Source code in beacon_api/query/__init__.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
add_bbox_filter(longitude_column, latitude_column, bbox)
Adds a bounding box filter to the query.
Args: longitude_column (str): The name of the column for longitude. latitude_column (str): The name of the column for latitude. bbox (tuple[float, float, float, float]): The bounding box coordinates (min_lon, min_lat, max_lon, max_lat).
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_equals_filter(column, eq)
Adds an EQUALS filter to the query.
Args: column (str): The name of the column to filter. eq (str | int | float | bool | datetime): The value to compare against.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_filter(filter)
Adds a filter to the query.
Args: filter (Filter): The filter to add.
Returns: Self: The query builder instance.
add_is_not_null_filter(column)
Adds an IS NOT NULL filter to the query.
Args: column (str): The name of the column to filter.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_is_null_filter(column)
Adds an IS NULL filter to the query.
Args: column (str): The name of the column to filter.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_not_equals_filter(column, neq)
Adds a NOT EQUALS filter to the query.
Args: column (str): The name of the column to filter. neq (str | int | float | bool | datetime): The value to compare against.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_polygon_filter(longitude_column, latitude_column, polygon)
Adds a POLYGON filter to the query.
Args: longitude_column (str): The name of the column for longitude. latitude_column (str): The name of the column for latitude. polygon (list[tuple[float, float]]): A list of (longitude, latitude) tuples defining the polygon.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_range_filter(column, gt_eq=None, lt_eq=None, gt=None, lt=None)
Adds a RANGE filter to the query.
Args: column (str): The name of the column to filter. gt_eq (str | int | float | datetime | None, optional): The lower bound for the range filter. Defaults to None. lt_eq (str | int | float | datetime | None, optional): The upper bound for the range filter. Defaults to None. gt (str | int | float | datetime | None, optional): The exclusive lower bound for the range filter. Defaults to None. lt (str | int | float | datetime | None, optional): The exclusive upper bound for the range filter. Defaults to None. Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_select_coalesced(mergeable_columns, alias)
Adds a coalesced select to the query.
Args: mergeable_columns (list[str]): The columns to merge. alias (str): The alias for the merged column.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_select_column(column, alias=None)
Adds a select column to the query.
Args: column (str): The name of the column to select. alias (str | None, optional): An optional alias for the column. Defaults to None.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_select_columns(columns)
Adds multiple select columns to the query.
Args: columns (List[Tuple[str, Optional[str]]]): A list of tuples containing column names and their aliases.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_selects(selects)
Adds multiple select statements to the query.
Args: selects (list[Select]): The select statements to add.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
add_sort(column, ascending=True)
Adds a SORT clause to the query.
Args: column (str): The name of the column to sort by. ascending (bool, optional): Whether to sort in ascending order. Defaults to True.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
filter(filters)
Adds filters to the query.
Args: filters (list[Filter]): The filters to add.
Returns: Self: The query builder instance.
set_distinct(columns)
Adds a DISTINCT clause to the query.
Args: columns (list[str]): The list of columns to apply DISTINCT on.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
set_limit(limit)
Adds a LIMIT clause to the query.
Args: limit (int): The maximum number of records to return.
Returns: Self: The query builder instance.
Source code in beacon_api/query/__init__.py
set_offset(offset)
Adds an OFFSET clause to the query.
Args: offset (int): The number of records to skip.
Returns: Self: The query builder instance.