forked from bellwether/minerva
properly handles no results being returned
This commit is contained in:
parent
8c498ba5dd
commit
ac657f671d
2 changed files with 10 additions and 2 deletions
|
|
@ -66,6 +66,7 @@ class Query:
|
||||||
# Because we're using `UNLOAD`, we get a manifest of the files
|
# Because we're using `UNLOAD`, we get a manifest of the files
|
||||||
# that make up our data.
|
# that make up our data.
|
||||||
files = self.manifest(tiedot).strip().split("\n")
|
files = self.manifest(tiedot).strip().split("\n")
|
||||||
|
files = [f.strip() for f in files if f.strip()] # filter empty
|
||||||
|
|
||||||
# TODO parallelize this
|
# TODO parallelize this
|
||||||
local = [self.handler.download(f) for f in files]
|
local = [self.handler.download(f) for f in files]
|
||||||
|
|
|
||||||
11
test.py
11
test.py
|
|
@ -4,12 +4,19 @@ import pprint
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
|
||||||
athena = m.Athena("hay", "s3://haystac-pmo-athena/")
|
athena = m.Athena("hay", "s3://haystac-pmo-athena/")
|
||||||
query = athena.query('select * from "trajectories"."kitware" limit 10')
|
query = athena.query(
|
||||||
|
"""SELECT *
|
||||||
|
FROM trajectories.kitware
|
||||||
|
WHERE ST_Disjoint(
|
||||||
|
ST_GeometryFromText('POLYGON((103.6 1.2151693, 103.6 1.5151693, 104.14797 1.5151693, 104.14797 1.2151693, 103.6 1.2151693))'),
|
||||||
|
ST_Point(longitude, latitude)
|
||||||
|
)
|
||||||
|
""")
|
||||||
data = query.results()
|
data = query.results()
|
||||||
print(data.head(10))
|
print(data.head(10))
|
||||||
|
|
||||||
# Everything *needs* to have a column in order for parquet to work, so scalar
|
# Everything *needs* to have a column in order for parquet to work, so scalar
|
||||||
# values have to be assigned something, so here we use `as count` to create
|
# values have to be assigned something, so here we use `as count` to create
|
||||||
# a temporary column called `count`
|
# a temporary column called `count`
|
||||||
print(athena.query("select count(*) as count from trajectories.kitware").results().head(1))
|
#print(athena.query("select count(*) as count from trajectories.kitware").results().head(1))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue