sql_query
SQL query algorithm.
Classes
SqlQuery
class SqlQuery(*, query: str, table: Optional[str] = None):
Simple algorithm for running a SQL query on a table.
The default table for single-table datasources is the pod identifier without the
username, in between backticks(``). Please ensure your SQL query operates on
that table. The table name should be put inside backticks(``) in the query
statement, to make sure it is correctly parsed e.g. SELECT MAX(G) AS MAX_OF_G FROM `df`
. This is the standard quoting mechanism used by MySQL (and also
included in SQLite).
If you are using a multi-table datasource, ensure that your SQL query syntax matches the syntax required by the Pod database backend.
Arguments
query
: The SQL query to execute.table
: The target table name. For single table pod datasources, this will default to the pod name.
Attributes
class_name
: The name of the algorithm class.fields_dict
: A dictionary mapping all attributes that will be serialized in the class to their marshamllow field type. (e.g. fields_dict ={"class_name": fields.Str()}
).nested_fields
: A dictionary mapping all nested attributes to a registry that contains class names mapped to the respective classes. (e.g. nested_fields ={"datastructure": datastructure.registry}
)query
: The SQL query to execute.table
: The target table name. For single table pod datasources, this will default to the pod name.
Ancestors
- BaseAlgorithmFactory
- bitfount.federated.mixins._ModellessAlgorithmMixIn
- abc.ABC
- bitfount.federated.roles._RolesMixIn
- bitfount.types._BaseSerializableObjectMixIn
- bitfount.federated.types._DataLessAlgorithm
Variables
- static
fields_dict : ClassVar[dict[str, marshmallow.fields.Field]]
Methods
create
def create(self, role: Union[str, Role], **kwargs: Any) ‑> Any:
Create an instance representing the role specified.
execute
def execute( self, pod_identifiers: list[str], username: Optional[str] = None, bitfounthub: Optional[BitfountHub] = None, ms_config: Optional[MessageServiceConfig] = None, message_service: Optional[_MessageService] = None, pod_public_key_paths: Optional[Mapping[str, Path]] = None, identity_verification_method: IdentityVerificationMethod = IdentityVerificationMethod.OIDC_DEVICE_CODE, private_key_or_file: Optional[Union[RSAPrivateKey, Path]] = None, idp_url: Optional[str] = None, require_all_pods: bool = False, aggregator: Optional[_BaseAggregatorFactory] = None, project_id: Optional[str] = None,) ‑> list[pd.DataFrame]:
Execute ResultsOnly compatible algorithm.
Syntactic sugar to allow the modeller to call .execute(...)
on
ResultsOnly compatible algorithms.
modeller
def modeller( self, **kwargs: Any,) ‑> ResultsOnlyModellerAlgorithm:
Returns the modeller side of the SqlQuery algorithm.
worker
def worker(self, **kwargs: Any) ‑> bitfount.federated.algorithms.sql_query._WorkerSide:
Returns the worker side of the SqlQuery algorithm.