BigQuery
èªåããªãã¨ãªãBigQueryã®ã¯ã¨ãªãæ¸ãã¦ãã¦ããã£ãç½ ã«ã¤ãã¦åæãã¦ããã¾ãã ããã¥ã¡ã³ããã¡ããã¨èªãã°æ¸ãã¦ãã£ããããã®ã§ãããæ®æ®µã¯ããã¾ã§ç´°ããè¦ã¦ãªãã£ãããããã§ãããâ¦â¦ã BigQueryã®ã«ã¬ã³ãã¼ | Advent Calendar 2023 - Qiiâ¦
BigQueryã§ã¯STRUCT(æ§é ä½)åãARRAY(é å)åã使ãã¾ã ãã¼ã¿å | BigQuery | Google CloudSTRUCTåã®ã«ã©ã ã§GROUP BYãããã¨ããã¨Grouping by expressions of type STRUCT is not allowed atã®ãããªã¨ã©ã¼ãåºã¦ãã¦å®è¡ãããã¨ãã§ãã¾ãã åæ§ã«â¦
BigQueryã«BigQuery MLã¨ããæ©æ¢°å¦ç¿ã®æ©è½ã追å ããã¾ãããä»ã¯ãã¸ã¹ãã£ãã¯å帰ã«ããåé¡ã¨ç·å½¢å帰ã«ããå帰åé¡ã«ã¤ãã¦å¦ç¿ãã§ããããã§ãå¦ç¿æã«å¤æ°ã«å¯¾ãã¦ã©ã®ãããªåå¦çãè¡ãããã®ãæ°ã«ãªã£ãã®ã§èª¿ã¹ã¦ã¿ã¾ãã 誤ããªã©ããã£ãâ¦
æ´æ°(INT64å)ãæµ®åå°æ°ç¹æ°(FLOAT64å)ãBYTESåã«ãããã£ãã®ã§èªåã§å¦çãUDFã¨ãã¦æ¸ãã¾ãã BigQueryã®CASTé¢æ°ã§BYTESåã«ãã£ã¹ãã§ã§ããã®ã¯BYTESåèªèº«ã¨STRINGåã«éããã¦ããã®ã§ãä»ã®åãå¤æãããã¨ãã«ã¯èªåã§å¦çãæ¸ãå¿ è¦ãããã¾â¦
BigQueryã®ã¯ã¨ãªã§ãã¼ãã«åã®æ«å°¾ã«æ¥ä»ãªã©ãå ¥ãã¦ãã㦠_TABLE_SUFFIX ã®ã«ã©ã ã®æ¡ä»¶ã§å©ç¨ãããã¼ãã«ãçµãè¾¼ã¿ããæã«ã_TABLE_SUFFIXã®æ¡ä»¶ããã¥ã¼ãWITHå¥ã®å¤å´ããæ¸ãã¦ã¿ã話ã§ã
æ®å¿µãªãã¨ã«DBã«JSONãªã©ã§ã¯ãªãPHPã§ã·ãªã¢ã©ã¤ãºãããå½¢å¼ã§ãã¼ã¿ãä¿åããã¦ãããã¨ãããã¾ã ãã®ä¸èº«ãBigQueryå´ããåç §ãããã£ãã®ã§èª¿ã¹ã¦ã¿ã¾ãã軽ãæ¤ç´¢ããã¨ããJavaScriptã§PHPã®ã·ãªã¢ã©ã¤ãºããããã¼ã¿ããã¨ã«æ»ããã©ã¤ãã©ãªã¯â¦
GENERATE_ARRAY(start_expression, end_expression[, step_expression])é¢æ°ã使ãã¨é£çªã®æ°å¤(çå·®æ°å)ãä½ããã¨ãã§ãã¾ã ãªãã¡ã¬ã³ã¹ ãããä¸åº¦ã«ä½ãåæ°ãå¤ãã¨Error: GENERATE_ARRAY(1, 10000000, 1) produced too many elementsã®ããã«ã¨ã©ã¼â¦
ç¯å²ãé¸æãã¦Ctrl + /ãæ¼ãã°ããã¿ããã§ã(Macã®å ´åã¯â Cmd + /) BigQueryã®ãã¼ãã¼ãã·ã§ã¼ãã«ãã 以ä¸ã®ç¯å²é¸æããç¶æ ã§Ctrl + /ãæ¼ã㨠æåãæ¸ããã¦ããé¨åã ãã³ã¡ã³ãã¢ã¦ãããã¾ã éã«ãã®å½¢å¼(å é ã«-- )ã§ã³ã¡ã³ãã¢ã¦ãããã¦ãâ¦
GENERATE_ARRAY()é¢æ°ã使ãã¨çå·®æ°åãä½ããã®ã§å¾ã¯JOINãã¦ããã°ãã ãåã«ä»¥ä¸ã®è¨äºã§ã¨ã©ãã¹ããã¹ã®ãµãããªã©ã調ã¹ãããSQLã§ã¯è©¦ãå²ãã«ããæ¹æ³ãããããæ¸ãããã«ãªãã£ã sucrose.hatenablog.com 試ãå²ã ããæ°ããã®æ°ãããå°ããª1â¦
BigQueryã§ã¯ã¨ãªãæ¸ãæã«ãã¯ã¨ãªã®æ¸ãæ¹ã«ãã£ã¦å®è¡æéãé«éåã§ãããå¦çãããã¤ãæ°ãç¯ç´ãããã§ãã¾ã Googleãå ¬å¼ã§BigQueryã®ãã¹ããã©ã¯ãã£ã¹é(ä»ã¯ã¾ã æªç¿»è¨³)ãå ¬éãã¦ããã¦ããã®ã§ããã®ãã¡ã®ã¯ã¨ãªãæ¸ãæå¨ãã®ãã¦ãã¦ãç°¡â¦
BigQueryã§ã¯ã¨ãªãæ¸ãã¨ãã«ãåãæ¥ä»ãåçãåå¨çãªã©ã®å®æ°ãã¯ã¨ãªã®è¤æ°ç®æã§ä½¿ãããæãããã¾ã åç´ã«è¤æ°ç®æã«æ¸ãã¨ä¿®æ£ããã¨ãã«å¤§å¤ãªã®ã§ãå ±éã®ãã®ãè¤æ°ç®æã§ä½¿ãã¾ããæ¹æ³ã調ã¹ã¦ã¿ã¾ãã UDF(ã¦ã¼ã¶ã¼å®ç¾©é¢æ°)ã«ããæ¹æ³ å®â¦
BigQueryã®Standard SQLã使ã£ã¦ãã¦é åããä½ç½®ãæå®ãã¦è¦ç´ ãåãåºããã¨ã¯ã§ããã®ã§ãããUNNEST()ã使ã£ã¦ããããã®è¦ç´ ãåãåºããæã«ããè¦ç´ ãä½çªç®ãã¨ããæ å ±ãä¸ç·ã«å¾ãæ¹æ³ãããããªãã£ãã®ã§ããæ¹ãèãã¾ãã(ããããããç°¡åã«â¦