forked from bellwether/minerva
tidying up examples and readme
This commit is contained in:
parent
819bf7abf3
commit
e3c11fb1aa
5 changed files with 138 additions and 66 deletions
|
|
@ -3,37 +3,31 @@ import pprint
|
|||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
# Create the Minerva object which gives you access to the account under the
|
||||
# profile `hay`
|
||||
m = minerva.Minerva("hay")
|
||||
|
||||
# Get the Athena object
|
||||
athena = m.athena("s3://haystac-pmo-athena/")
|
||||
|
||||
#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)
|
||||
#)
|
||||
#""")
|
||||
|
||||
# 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
|
||||
# a temporary column called `count`
|
||||
#print(athena.query("select count(*) as count from trajectories.kitware").results().head(1))
|
||||
|
||||
# Everything *needs* to have a column in order for unloading to parquet to work,
|
||||
# so scalar values have to be assigned something, so here we use `as count` to
|
||||
# create a temporary column called `count`
|
||||
query = athena.query(
|
||||
"""
|
||||
select round(longitude, 3) as lon, count(*) as count
|
||||
from trajectories.kitware
|
||||
from trajectories.baseline
|
||||
where agent = 4
|
||||
group by round(longitude, 3)
|
||||
order by count(*) desc
|
||||
"""
|
||||
)
|
||||
data = query.results()
|
||||
|
||||
pp.pprint(data.head(10))
|
||||
|
||||
# We also get important statistics
|
||||
print(query.runtime)
|
||||
|
||||
#import IPython
|
||||
#IPython.embed()
|
||||
print(query.cost)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue