by shigemk2

当面は技術的なことしか書かない

redash memo

雑メモ

  • サービスアカウント作成から秘密鍵JSONを作成する
  • スプレッドシートをclient_mailとで共有する(共有しなくても良いかも)
  • クエリ作成→ URLのスプレッドシートID|シート番号(0から採番) で実行→保存
  • 保存したクエリは以後 データセット query result で参照できる
  • Query Result同士をJOINして、複数データセットの結合を実現する

Querying a Google Spreadsheet - Redash Knowledge Base

Querying Existing Query Results - Redash Knowledge Base

presto with

presto with

withよくわかんなかったけど、サブクエリの簡素化だね、やっていることは。

WITH dataset AS (
    SELECT *
    FROM (
        VALUES
            (1, 'A'), (2, 'B'), (3, 'C'), (4, 'D'),
            (5, 'A'), (6, 'B'), (7, 'C'),
            (9, 'A'), (10, 'B'),(11, 'C'),
            (13, 'A'),(14, 'B'),(15, 'C'),
            (17, 'A'),(18, 'B'),(19, 'C'),
            (21, 'A'),(22, 'B'),(23, 'C'),
            (25, 'A'),(26, 'B')
    ) AS t
)
SELECT * 
-- assuming we want to sample 25% of records
FROM dataset TABLESAMPLE BERNOULLI(25)

Data Sampling In Presto

The WITH clause defines named relations for use within a query. It allows flattening nested queries or simplifying subqueries. For example, the following queries are equivalent:

https://prestodb.io/docs/current/sql/select.html