Query
- materializationengine.blueprints.client.query.fix_columns_with_query(df, query, n_threads=None, fix_decimal=True, fix_wkb=True, wkb_data_start_ind=2)[source]
Use a query object to suggest how to convert columns imported from csv to correct types.
- materializationengine.blueprints.client.query.fix_wkb_column(df_col, wkb_data_start_ind=2, n_threads=None)[source]
Convert a column with 3-d point data stored as in WKB format to list of arrays of integer point locations. The series can not be mixed.
- Parameters:
df_col (pandas.Series) – N-length Series (representing a column of a dataframe) to convert. All elements should be either a hex-string or a geoalchemy2 WKBElement object.
wkb_data_start_ind (int, optional) – When the WKB data is represented as a hex string, sets the first character of the actual data. By default 2, since the current implementation has a prefix when the data is imported as text. Set to 0 if the data is just an exact hex string already. This value is ignored if the series data is in WKBElement object form.
n_threads (int or None, optional) – Sets number of threads. If None, uses as many threads as CPUs. If n_threads is set to 1, multiprocessing is not used. Optional, by default None.
- Returns:
N-length list of arrays of 3d points
- Return type:
list
- materializationengine.blueprints.client.query.make_spatial_filter(model, column_name, bounding_box) Query[source]
Generate spatial query that finds annotations within a bounding box.
- Parameters:
model (DeclarativeMeta) – sqlalchemy model
column_name (str) – name of column to query
bounding_box (List[List[int]]) – Bounding box in the form of [[min_x, min_y, min_z], [max_x, max_y, max_z]]
- Returns:
[description]
- Return type:
Query
- materializationengine.blueprints.client.query.render_query(statement, dialect=None)[source]
Based on https://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query#comment39255415_23835766 Generate an SQL expression string with bound parameters rendered inline for the given SQLAlchemy statement.
- materializationengine.blueprints.client.query.specific_query(sqlalchemy_session, engine, model_dict, tables, filter_in_dict=None, filter_notin_dict=None, filter_equal_dict=None, filter_spatial=None, select_columns=None, consolidate_positions=True, return_wkb=False, offset=None, limit=None, get_count=False, suffixes=None)[source]
- Allows a more narrow query without requiring knowledge about the
underlying data structures
- Parameters:
tables (list of lists) –
- standard: list of one entry: table_name of table that one wants to
query
- join: list of two lists: first entries are table names, second
entries are the columns used for the join
filter_in_dict (dict of dicts) – outer layer: keys are table names inner layer: keys are column names, values are entries to filter by
filter_notin_dict (dict of dicts) – inverse to filter_in_dict
filter_equal_dict (dict of dicts) – outer layer: keys are table names inner layer: keys are column names, values are entries to be equal
filter_spatial (dict of dicts) –
outer layer: keys are table_namess inner layer: keys are column names, values are [min,max] as list of lists
e.g. [[0,0,0], [1,1,1]]
select_columns (list of str) –
consolidate_positions (whether to make the position columns arrays of x,y,z) –
offset (int) –
limit (int or None) –
get_count (bool) –
suffixes (list of str or None) –
- Return type:
sqlalchemy query object