Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Last active April 8, 2020 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laclefyoshi/d41d06ce669178285ff5c61d24054e37 to your computer and use it in GitHub Desktop.
Save laclefyoshi/d41d06ce669178285ff5c61d24054e37 to your computer and use it in GitHub Desktop.
テーブル名と同じカラム名のカラムがあるテーブルに対するPostgresqlとBigQueryの結果の差異
WITH a AS ( SELECT 1 AS a, 2 AS b )
SELECT a FROM a ;
-- result::
-- | Row | a.a | a.b |
-- | 1 | 1 | 2 |
-- result (json)::
-- [
-- {
-- "a": {
-- "a": "1",
-- "b": "2"
-- }
-- }
-- ]
WITH a AS ( SELECT 1 AS a, 2 AS b )
SELECT a FROM a ;
-- result::
-- a
-- ---
-- 1
-- (1 row)
-- https://github.com/apstndb/zetasql-sandbox
-- $ echo "WITH a AS ( SELECT 1 AS a, 2 AS b ) SELECT a FROM a ;"| docker run -i --rm zetasql-sandbox analyze-print
WITH
a AS (
SELECT
1 AS a_1,
2 AS a_2
)
SELECT
STRUCT< a INT64, b INT64 > (withrefscan_3.a_1, withrefscan_3.a_2) AS a
FROM
a AS withrefscan_3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment