Skip to content

Commit 4aba080

Browse files
authored
Fix for Sorting and Upserts (#153)
* fix issue with upserts * fix sorting issue #152 * bump version * add tests for sorting by a property * small change to kick ci * add stac_extensions table * make queryables aggregate enum, min, max, add tooling to get extensions into queryables * update changelog * reformat for black update * add check_pgstac_settings function * update settings function * add procedures to validate constraints and analyze items partitions * prep migration * update docs * add tests for paging without using fields extension
1 parent da8d693 commit 4aba080

26 files changed

+4391
-79
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [v0.6.12]
8+
9+
### Added
10+
- Add ability to merge enum, min, and max from queryables where collections have different values.
11+
- Add tooling in pypgstac and pgstac to add stac_extension definitions to the database.
12+
- Modify missing_queryables function to try to use stac_extension definitions to populate queryable definitions from the stac_extension schemas.
13+
- Add validate_constraints procedure
14+
- Add analyze_items procedure
15+
- Add check_pgstac_settings function to check system and pgstac settings.
16+
17+
### Fixed
18+
- Fix issue with upserts in the trigger for using the items_staging tables
19+
- Fix for generating token query for sorting. [152] (https://github.com/stac-utils/pgstac/pull/152)
20+
721
## [v0.6.11]
822

923
### Fixed

docs/src/pgstac.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ ALTER ROLE <username> SET pgstac.context_estimated_cost TO '<estimated query cos
7272
ALTER ROLE <username> SET pgstac.context_stats_ttl TO '<an interval string ie "1 day" after which pgstac search will force recalculation of it's estimates>>';
7373
```
7474
75+
The check_pgstac_settings function can be used to check what pgstac settings are being used and to check recomendations for system settings. It takes a single parameter which should be the amount of memory available on the database system.
76+
```sql
77+
SELECT check_pgstac_settings('16GB');
78+
```
79+
7580
#### Runtime Configurations
7681
7782
Runtime configuration of variables can be made with search by passing in configuration in the search json "conf" item.
@@ -104,3 +109,10 @@ VALUES (<property name>, <property wrapper>, <index type>);
104109
Property wrapper should be one of to_int, to_float, to_tstz, or to_text. The index type should almost always be 'BTREE', but can be any PostgreSQL index type valid for the data type.
105110
106111
**More indexes is note necessarily better.** You should only index the primary fields that are actively being used to search. Adding too many indexes can be very detrimental to performance and ingest speed. If your primary use case is delivering items sorted by datetime and you do not use the context extension, you likely will not need any further indexes.
112+
113+
### Maintenance Procedures
114+
These are procedures that should be run periodically to make sure that statistics and constraints are kept up-to-date and validated. These can be made to run regularly using the pg_cron extension if available.
115+
```sql
116+
SELECT cron.schedule('0 * * * *', 'CALL validate_constraints();');
117+
SELECT cron.schedule('10, * * * *', 'CALL analyze_items();');
118+
```

pypgstac/pypgstac/db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,13 @@ def query(
174174
with conn.cursor(row_factory=row_factory) as cursor:
175175
if args is None:
176176
rows = cursor.execute(query, prepare=False)
177-
for row in rows:
178-
yield row
179177
else:
180178
rows = cursor.execute(query, args)
179+
if rows:
181180
for row in rows:
182181
yield row
182+
else:
183+
yield None
183184
except psycopg.errors.OperationalError as e:
184185
# If we get an operational error check the pool and retry
185186
logger.warning(f"OPERATIONAL ERROR: {e}")

pypgstac/pypgstac/hydration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def hydrate(base_item: Dict[str, Any], item: Dict[str, Any]) -> Dict[str, Any]:
1212
This will not perform a deep copy; values of the original item will be referenced
1313
in the return item.
1414
"""
15+
1516
# Merge will mutate i, but create deep copies of values in the base item
1617
# This will prevent the base item values from being mutated, e.g. by
1718
# filtering out fields in `filter_fields`.

0 commit comments

Comments
 (0)