skatsuta / athenai

Have fun with Amazon Athena from command line! 🕊
Apache License 2.0
36 stars 0 forks source link

Add `--order` flag to arrange query results in the order of given SQL statements #21

Closed skatsuta closed 7 years ago

skatsuta commented 7 years ago

See 7ee9eac543251a75e32485e44b7e185c69593e90

skatsuta commented 7 years ago

Done.

skatsuta commented 7 years ago

Create result pipeliner to abstract channels regardless of whether or not --order flag is given, and have Athenai hold it.

skatsuta commented 7 years ago

I struggle to design it, pending to implement. feature/add-order-flag branch holds WIP code.

skatsuta commented 7 years ago

Number each query execution and call send(num, resultContainer) to return a query result. At receipt part, in case rc := <-a.pipe.ResultContainer(): check rc.Err() and rc.Result() to get the result or error.

Must create resultChs and errChs every time doing RunQuery.

skatsuta commented 7 years ago

There is a bug where query executions of fewer statements are stuck after several statements are executed when --order flag is given.

$ time go run main.go run --order
athenai> SELECT date, time, bytes, requestip, method, status FROM cloudfront_logs LIMIT 5; SHOW TABLES; SHOW DATABASES; SELECT timestamp, requestip, backendip FROM elb_logs LIMIT 5;
â ž Running query...
(snip)
Run time: 2.05 seconds | Data scanned: 101.27 KB
athenai> SHOW TABLES;
(snip)
Run time: 0.34 seconds | Data scanned: 0 B
â ´ Running query... ^C^C^C (Stuck and ^C does not work)
skatsuta commented 7 years ago

I finally decided I remove --order and always show all query results in the same order as queries.