Redash v3.0.0ã§è¿½å ãããQuery Resultsãã¼ã¿ã½ã¼ã¹ã«ã¤ãã¦
ãã®è¨äºã¯ Redash Advent Calendar 2017 1æ¥ç®ã®è¨äºã§ãã
Query Resultsãã¼ã¿ã½ã¼ã¹ã¨ã¯
v3.0.0 ã§è¿½å ããããã¼ã¿ã½ã¼ã¹ã§ãæåéããã¯ã¨ãªã®å®è¡çµæãããã¼ã¿ã½ã¼ã¹ã¨ãã¦æ±ããã¨ãã§ãããã®ã§ãã
ææçã§ã¯ãã§ã«åå¨ãã¦ãããã®ãv.3.0.0ã§OSSã«ãªã£ãããã§ãææçã§ã®ä½¿ç¨ä¾ã¯ãéå»ã«Gunosyããã®è¨äºã§ãç´¹ä»ããã¦ãã¾ãã
ãã®è¨äºã§ã¯ãQuery Resultsãã¼ã¿ã½ã¼ã¹ã®å©ç¨ä¾ãç°å¢æ§ç¯ããã¯ã¨ãªå®è¡ã¾ã§ã®æé ã¨ãããã¦ç´¹ä»ãã¾ãã
ç°å¢æ§ç¯
Redashã®ç°å¢æ§ç¯ã¯Dockerãå©ç¨ãããã¨ãæ¨å¥¨ããã¦ããã®ã§ãDockerã使ã£ã¦ç°å¢æ§ç¯ããã¾ãããQuery Resultsãã¼ã¿ã½ã¼ã¹ã®åä½ã確èªãããããRedashæ¨æºã®ã»ããã¢ããæé ã«å ãã¦ãMySQLãPostgreSQLãSQLiteããããã®ãã¼ã¿ã½ã¼ã¹ã使ããããã«ãã¾ãã
ãµã³ãã«ãã¼ã¿ã¨ãã¦ãMySQLã®SakilaããããPostgreSQLåãã«ããPagilaãããã«SQLiteåãã®sqlite-sakilaã使ç¨ãã¾ãã
ãã®3ã¤ã®ç°ãªããã¼ã¿ã½ã¼ã¹ã®Query Resultsãã¼ã¿ã½ã¼ã¹ã使ã£ã¦æ±ããããã«ãã¦ããã¾ãããã
æ¤è¨¼ã«ä½¿ç¨ãã docker-compose.yml
ã¯ä»¥ä¸ã®ãããªãã®ã«ãªãã¾ãã詳細ã¯å²æãã¾ãã®ã§ããäºæ¿ãã ããã
version: '2' services: server: image: redash/redash:3.0.0.b3147 command: server depends_on: - postgres - redis ports: - "5000:5000" environment: PYTHONUNBUFFERED: 0 REDASH_LOG_LEVEL: "INFO" REDASH_REDIS_URL: "redis://redis:6379/0" REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" REDASH_COOKIE_SECRET: veryverysecret REDASH_WEB_WORKERS: 2 volumes: - "sqlite_sakila:/sqlite:rw" restart: always worker: image: redash/redash:3.0.0.b3147 command: scheduler environment: PYTHONUNBUFFERED: 0 REDASH_LOG_LEVEL: "INFO" REDASH_REDIS_URL: "redis://redis:6379/0" REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" QUEUES: "queries,scheduled_queries,celery" WORKERS_COUNT: 4 volumes: - "sqlite_sakila:/sqlite:ro" restart: always redis: image: redis:3.0-alpine restart: always postgres: image: postgres:9.5.6-alpine restart: always nginx: image: redash/nginx:latest ports: - "80:80" depends_on: - server links: - server:redash restart: always sakila: image: rnoennig/sakiladb environment: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" restart: always pagila: image: mujz/pagila restart: always volumes: sqlite_sakila:
2017-12-27追è¨
server ãµã¼ãã¹ã§ä½¿ç¨ãã¦ãããã¼ã¸ã§ã³ã redash:latest
ã«ãªã£ã¦ããããã redash/redash:3.0.0.b3147
ã«ä¿®æ£ãã¾ããã
ã³ã¡ã³ãããã ããããã¨ããããã¾ããï¼
docker-compose.yaml
— nntsugu (@nntsugu) 2017å¹´12æ26æ¥
----
server:
image: redash/redash:latest
command: serverâ
----
ãã¡ãredash/redash:latestã®imageã ã¨Redashã®ãã¼ã¸ã§ã³ã2.0.1b3080ã¨ãªããããä¸è¨ã«ã¦resultsãã¼ã¿ã½ã¼ã¹ããµãã¼ããã¦ããªãæ¨ã®ã¨ã©ã¼ã¨ãªãã¾ããã
docker-compose.yml
ãæºåã§ããããRedashã®ãã¼ã¿ãã¼ã¹ãåæåããããã以ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
$ docker-compose run --rm server bash -c "sleep 15 && /app/bin/docker-entrypoint create_db" $ docker-compose up
å ¬å¼ããã¥ã¡ã³ãã§èª¬æããã¦ããã³ãã³ãã¨å°ãéã£ã¦ãã¾ãããPostgreSQLã®èµ·åãå¾ ããã«ãã¤ã°ã¬ã¼ã·ã§ã³ã¹ã¯ãªãããåãã¦ãã¾ããã¨ãããã®ã§ããã®å¯¾çã¨ãã¦sleepã15ç§æãã§ãã¾ãã
ã¡ãªã¿ã«ãã®åé¡ã¯PRãéã£ã¦ããã®ã§ãããããããä»å¾ã¯èµ·ãããªããªãããããã¾ããã
Redashãèµ·åãããhttp://localhost
ã«ã¢ã¯ã»ã¹ããadmin
ã¦ã¼ã¶ã¼ãä½æãã¾ãã
admin
ã¦ã¼ã¶ã¼ã®ä½æå¾ããã¼ã¿ã½ã¼ã¹ã追å ãããããdocker-compose
ãå®è¡ãã¦ãããã®ã¨ã¯å¥ã®ã¿ã¼ããã«ã§ã以ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
$ docker-compose exec -u root server chmod a+rw /sqlite $ docker-compose exec server wget -O /sqlite/sqlite-sakila.sq https://github.com/wallymathieu/sakila-sample-database-ports/raw/master/sqlite-sakila-db/sqlite-sakila.sq $ docker-compose exec server ./manage.py ds new --type mysql --options '{"db": "sakila", "host": "sakila", "user": "root"}' sakila $ docker-compose exec server ./manage.py ds new --type pg --options '{"dbname": "pagila", "host": "pagila", "password": "admin", "user": "root"}' pagila $ docker-compose exec server ./manage.py ds new --type sqlite --options '{"dbpath": "/sqlite/sqlite-sakila.sq"}' sqlite-sakila $ docker-compose exec server ./manage.py ds new --type results results
ãããã®ã³ãã³ãã¯Redashã®CLIã使ç¨ãã¦ãã¼ã¿ã½ã¼ã¹ã追å ãã¦ãã¾ãã
ã¯ã¨ãªã®ä½æ
Query Resultsãã¼ã¿ã½ã¼ã¹ã®åä½ç¢ºèªã«ä½¿ç¨ããã¯ã¨ãªãRedashã®ç»é¢ä¸ã§ä½æãã¾ãã
ã¯ã¨ãªIDãå¤ãã¦ãã¾ãã¨å¾è¿°ã®ãµã³ãã«ã¯ã¨ãªãåããªããªã£ã¦ãã¾ããã注æãã¦ãã ããã
ã¯ã¨ãªID1ã¨ãã¦sakilaãã¼ã¿ã½ã¼ã¹(MySQL)ã使ç¨ãã¦ä½æ
SELECT country_id, country FROM country WHERE country_id BETWEEN 100 AND 110 ;
ã¯ã¨ãªID2ã¨ãã¦pagilaãã¼ã¿ã½ã¼ã¹(PostgreSQL)ã使ç¨ãã¦ä½æ
SELECT country_id, COUNT(*) num_of_cities FROM city GROUP BY country_id ;
ã¯ã¨ãªID3ã¨ãã¦sqlite-sakilaãã¼ã¿ã½ã¼ã¹(SQLite)ã使ç¨ãã¦ä½æ
SELECT city.country_id, COUNT(*) num_of_addresses FROM address JOIN city ON address.city_id = city.city_id GROUP BY city.country_id ;
ããã¾ã§ã§ç°å¢æ§ç¯ã¯å®äºã§ãã
Query Resultsãã¼ã¿ã½ã¼ã¹ã使ç¨ããã¯ã¨ãªãå®è¡ãã
å
¬å¼ããã¥ã¡ã³ãã«ã説æãããã¨ãããQUERY_[ã¯ã¨ãªID]
(å°æåã§ãè¯ã)ã¨ããè¨æ³ã§å¯¾è±¡ã®ã¯ã¨ãªãæå®ãã¾ãã
以ä¸ã®ä¾ã¯ããã¼ã¿ã½ã¼ã¹ãç°ãªãã¯ã¨ãª1ã2ã3ããããã®çµæãJOINãã¦ãåãã¼ãã«ã®ã«ã©ã ãSELECTããä¾ã§ãã
SELECT mysql.country, pgsql.num_of_cities, sqlite.num_of_addresses FROM query_1 mysql JOIN query_2 pgsql ON mysql.country_id = pgsql.country_id JOIN query_3 sqlite ON pgsql.country_id = sqlite.country_id ;
å®è¡ããã¨ã以ä¸ã®ãããªçµæã表示ããã¾ãã
ç°ãªããã¼ã¿ã½ã¼ã¹ã使ç¨ããã¯ã¨ãªã®ãçµæãã«å¯¾ãã¦ã¯ã¨ãªãå®è¡ã§ãã¦ãããã¨ããããã¾ããã
å é¨çã«ã¯SQLiteãã¤ã³ã¡ã¢ãªã§ä½¿ç¨ãã¦ããã®ã§ãSQLiteã§ä½¿ããSQLããã®ã¾ã¾ä½¿ãã¾ãã
ãã¼ãã«åã®æ¸ãæ¹ã«ã¤ãã¦
ç¾æç¹ã§ã¯ãã¼ãã«åã®åã«æ¹è¡ãã¿ããªã©ãåè§ã¹ãã¼ã¹ä»¥å¤ã®ç©ºç½æåãå ¥ã£ã¦ãã¾ãã¨ã該å½ã®ã¯ã¨ãªãçºè¦ã§ããªãåé¡ãããã¾ãããPRããã¼ã¸ãã¦ããã ããã®ã§ã4.0.0ã§ä¿®æ£ãããã¨æãã¾ãã
注æç¹
ããã¥ã¡ã³ãã«è¨è¼ãããããã«ãç¾æç¹ã§ã¯ä»¥ä¸ã®æ³¨æç¹ãããã¾ãã
- Query Resultsãã¼ã¿ã½ã¼ã¹ã使ç¨ããã¯ã¨ãªã¯ãã¯ã¨ãªå ã§åç §ããä»ã®ã¯ã¨ãªã常ã«åå®è¡ãã
- ãªã³ã¡ã¢ãªã®SQLiteã«çµæãä¿æãããããã¡ã¢ãªä¸è¶³ãèµ·ããã¨å¤±æãã
- ã¯ã¨ãªå ã§åç §ããä»ã®ã¯ã¨ãªã使ç¨ãã¦ãããã¼ã¿ã½ã¼ã¹ãã¹ã¦ã«å¯¾ãã¦æ¨©éãæã£ã¦ããªãã¨å®è¡ã§ããªã
使ãæ
ãã¹ã¦ã®ã±ã¼ã¹ã§æç¨ãã¨ããã¨ããã§ããªãããããã¾ããããç°ãªããã¼ã¿ã½ã¼ã¹ã®çµæãçµåãã以å¤ã«ããè¤éãªéè¨ãããéã«ãä¸éãã¼ãã«ã®ä»£æ¿ã¨ãã¦ã±ã¼ã¹ã§æ´»ç¨ãããã¨ãã§ããã¨èãã¾ããã
ã¾ã¨ã
v3.0.0ã®æ©è½ã®ä¸ã§ã大ããªæ©è½ã®ã²ã¨ã¤ã ã¨è¨ããQuery Resultsãã¼ã¿ã½ã¼ã¹ã«ã¤ãã¦ãç°¡åã«ã¾ã¨ãã¾ãã
- v3.0.0ã§Query Resultsãã¼ã¿ã½ã¼ã¹ã使ããããã«ãªã
- ã¯ã¨ãªã®ãçµæãã«å¯¾ãã¦ã¯ã¨ãªãå®è¡ãããããåç §ããã¯ã¨ãªã®ãã¼ã¿ã½ã¼ã¹ããªãã§ãããã¨ä½¿ç¨ã§ãã
- è¤æ°ã®ãã¼ã¿ã½ã¼ã¹ãã¾ãããã¯ã¨ãªãæ¸ãå ´åããä¸éãã¼ãã«ã®ä»£æ¿ã¨ãã¦ã使ç¨ãããã¨ãã§ãã
- ã¾ã å®å®ãªãªã¼ã¹åãã¤ã使ç¨ä¸ã®æ³¨æç¹ããããããæ¬çªéç¨ãæ¤è¨ããå ´åã¯æ¤è¨¼ãå¿ è¦
2æ¥ç®ã®è¨äº
ææ¥ã¯ kyoshidajp ããããRedashãã©ã¡ã¼ã¿ä¸è¦§ãã«ã¤ãã¦è¨äºãæ¸ãã¦ãã ããããã§ããã楽ãã¿ã«ã