Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different formats as outputs and integrate with Explorer #40

Merged
merged 20 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,49 @@ LOCATION 's3://osm-pds/planet/';
"""

Req.post!(req, athena: query).body
#=>
# %ReqAthena.Result{
# columns: [],
# output_location: "s3://my-bucket/a034610b-daaf-4c8d-aa61-d1a706231062.txt",
# query_execution_id: "a034610b-daaf-4c8d-aa61-d1a706231062",
# rows: [],
# statement_name: nil
# =>
# %{
# "Output" => "",
# "ResultSet" => %{
# "ColumnInfos" => [],
# "ResultRows" => [],
# "ResultSetMetadata" => %{"ColumnInfo" => []},
# "Rows" => []
# }
# }

# With plain string query
query = "SELECT id, type, tags, members, timestamp, visible FROM planet WHERE id = 470454 and type = 'relation'"

Req.post!(req, athena: query).body
#=>
# %ReqAthena.Result{
# columns: ["id", "type", "tags", "members", "timestamp", "visible"],
# output_location: "s3://my-bucket/c594d5df-9879-4bf7-8796-780e0b87a673.csv",
# query_execution_id: "c594d5df-9879-4bf7-8796-780e0b87a673",
# rows: [
# [470454, "relation",
# "{ref=17229A, site=geodesic, name=Mérignac A, source=©IGN 2010 dans le cadre de la cartographie réglementaire, type=site, url=http://geodesie.ign.fr/fiches/index.php?module=e&action=fichepdf&source=carte&sit_no=17229A, network=NTF-5}",
# "[{type=node, ref=670007839, role=}, {type=node, ref=670007840, role=}]",
# ~N[2017-01-21 12:51:34.000], true]
# ],
# statement_name: nil
# }
Req.post!(req, athena: query, format: :json).body
# =>
# [
# %{
# "id" => 470454,
# "members" => [
# %{"ref" => 670007839, "role" => "", "type" => "node"},
# %{"ref" => 670007840, "role" => "", "type" => "node"}
# ],
# "tags" => %{
# "name" => "Mérignac A",
# "network" => "NTF-5",
# "ref" => "17229A",
# "site" => "geodesic",
# "source" => "©IGN 2010 dans le cadre de la cartographie réglementaire",
# "type" => "site",
# "url" => "http://geodesie.ign.fr/fiches/index.php?module=e&action=fichepdf&source=carte&sit_no=17229A"
# },
# "timestamp" => "2017-01-21 12:51:34",
# "type" => "relation",
# "visible" => true
# }
# ]

# With parameterized query
query = "SELECT id, type FROM planet WHERE id = ? and type = ?"

Req.post!(req, athena: {query, [239_970_142, "node"]}).body
#=>
# %ReqAthena.Result{
# columns: ["id", "type"],
# output_location: "s3://my-bucket/dda41d66-1eea-4588-850a-945c9def9163.csv",
# query_execution_id: "dda41d66-1eea-4588-850a-945c9def9163",
# rows: [[239970142, "node"]],
# statement_name: "query_C71EF77B8B7B92D9846C6D7E70136448"
# }
#=> [%{"id" => 239970142, "type" => "node"}]
```

## License
Expand Down
Loading