Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Last active Apr 8, 2020
Embed
What would you like to do?
テーブル名と同じカラム名のカラムがあるテーブルに対する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