-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Geospatial queries * add geospatial queries * add homes table to imdb_extended.yml * fix formatting * Geoff's comments * add geospatial query that touches ticket_orders * minor * Functionality catalog, initial * Add transations to functionality catalog * move eyword crawling script to tools * minor merge main * add session to engine_for tree_based router * determine is query transaction in query rep, not routers * minor fixes * fixing tests * fixing tests * session in routing not query rep * checks
- Loading branch information
Showing
10 changed files
with
534 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
database_engines: | ||
- name: Aurora | ||
functionalities: | ||
- geospatial | ||
- transactions | ||
|
||
- name: Athena | ||
functionalities: | ||
- geospatial | ||
|
||
- name: Redshift | ||
functionalities: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import List | ||
import operator | ||
import yaml | ||
from functools import reduce | ||
from typing import Dict | ||
from importlib.resources import files, as_file | ||
import brad.routing as routing | ||
|
||
|
||
class Functionality: | ||
Geospatial = "geospatial" | ||
Transaction = "transactions" | ||
|
||
def __init__(self): | ||
# Read the YAML file | ||
functionality_yaml = files(routing).joinpath("engine_functionality.yml") | ||
with as_file(functionality_yaml) as file: | ||
with open(file, "r", encoding="utf8") as yaml_file: | ||
data = yaml.load(yaml_file, Loader=yaml.FullLoader) | ||
|
||
# Initialize lists for each database engine's functionalities | ||
aurora_functionalities = [] | ||
athena_functionalities = [] | ||
redshift_functionalities = [] | ||
|
||
# Parse the data into the respective lists | ||
for engine in data["database_engines"]: | ||
if engine["name"] == "Aurora": | ||
aurora_functionalities = engine["functionalities"] | ||
elif engine["name"] == "Athena": | ||
athena_functionalities = engine["functionalities"] | ||
elif engine["name"] == "Redshift": | ||
redshift_functionalities = engine["functionalities"] | ||
|
||
# Convert to bitmaps | ||
engine_functionality_strings = [ | ||
athena_functionalities, | ||
aurora_functionalities, | ||
redshift_functionalities, | ||
] | ||
self.engine_functionalities = [ | ||
Functionality.to_bitmap(f) for f in engine_functionality_strings | ||
] | ||
|
||
@staticmethod | ||
def to_bitmap(functionalities: List[str]) -> int: | ||
if len(functionalities) == 0: | ||
return 0 | ||
return reduce( | ||
# Bitwise OR | ||
operator.or_, | ||
map(lambda f: FunctionalityBitmapValues[f], functionalities), | ||
0, | ||
) | ||
|
||
def get_engine_functionalities(self) -> List[int]: | ||
""" | ||
Return a bitmap for each engine that states what functionalities the | ||
engine supports | ||
""" | ||
return self.engine_functionalities | ||
|
||
|
||
FunctionalityBitmapValues: Dict[str, int] = {} | ||
FunctionalityBitmapValues[Functionality.Geospatial] = 0b01 | ||
FunctionalityBitmapValues[Functionality.Transaction] = 0b10 |
Oops, something went wrong.