即使我使用了join,BigQuery也不会加入

时间:2014-12-09 22:15:26

标签: google-bigquery

我在Big Query中运行以下查询。我已经更改了所有联接,以加入我的每个组和每个组。我还检查了所有底层视图。我仍然收到以下错误:

“表格对于JOIN而言太大。请考虑使用JOIN EACH。有关详细信息,请参阅https://developers.google.com/bigquery/docs/query-reference#joins

SELECT users, amount_25, amount_50, amount_75, machines as machine, ios_cv, ds, note
FROM
  (
  SELECT count(mobileID) OVER(PARTITION BY machines, ios_cv, ds, note) as users
    , percentile_cont(0.25) OVER(PARTITION BY machines, ios_cv, ds, note ORDER BY daily_amount) as amount_25 
    , percentile_cont(0.50) OVER(PARTITION BY machines, ios_cv, ds, note ORDER BY daily_amount) as amount_50 
    , percentile_cont(0.75) OVER(PARTITION BY machines, ios_cv, ds, note ORDER BY daily_amount) as amount_75 
    , machines, ios_cv, ds, note
  FROM
    (
    SELECT notes.mobileID as mobileID, notes.machines as machines, notes.ios_cv as ios_cv, notes.ds as ds, notes.note as note, nvl(amounts.total, 0) as daily_amount
    FROM
      (
      SELECT users.mobileID as mobileID, users.machines as machines, users.ios_cv as ios_cv, users.ds as ds, slots.note as note
      FROM
        (
        SELECT a.mobileID as mobileID, a.machines as machines, a.ios_cv as ios_cv, a.ds as ds
        FROM
          (
          SELECT idfa, mobileID, ios_cv, ds
            , case when machine = 'SlotMachine.SlotMachine0' then "Joker's Wild"
              when machine = 'SlotMachine.SlotMachine1' then 'Cactus Cowboy'
              when machine = 'SlotMachine.SlotMachine2' then 'Fashionista'
              when machine = 'SlotMachine.SlotMachine5' then 'The Syndicate'
              when machine = 'SlotMachine.SlotMachine6' then "Pharoah's Treasure"
              when machine = 'SlotMachine.SlotMachine7' then 'Ice Cream Shop'
              when machine = 'SlotMachine.SlotMachine8' then 'Under the Sea'
              when machine = 'SlotMachine.SlotMachine9' then 'Mystery Mansion'
              when machine = 'SlotMachine.SlotMachine10' then 'Faeries'
              when machine = 'SlotMachine.SlotMachine11' then 'Excalibur'
              when machine = 'SlotMachine.SlotMachine12' then 'Lucky Farm'
              when machine = 'SlotMachine.SlotMachine13' then 'Treasure Cove'
              when machine = 'SlotMachine.SlotMachine14' then 'Spooky Slots'
              when machine = "Sorcerer's School" then 'Spooky Slots'
              when machine = 'SlotMachine.SlotMachine15' then 'Harvest Feast'
              when machine = 'Harvest Festival' then 'Harvest Feast'
              when machine = 'SlotMachine.SlotMachine16' then "Santa's Workshop"
              when machine = 'SlotMachine.SlotMachine17' then 'Gold Rush'
              when machine = 'SlotMachine.SlotMachine18' then 'Secret Valentine'
              when machine = 'SlotMachine.SlotMachine19' then 'Pot O Gold'
              when machine = 'SlotMachine.SlotMachine20' then 'Bunny Lane'
              when machine = 'SlotMachine.SlotMachine21' then 'Mayan Treasures'
              when machine = 'SlotMachine.SlotMachine22' then 'Cosmic Gems'
              when machine = 'SlotMachine.SlotMachine23' then 'Candy Craze'
              when machine = 'SlotMachine.SlotMachine24' then "Lucky 7's"
              when machine = 'SlotMachine.SlotMachine25' then 'Atlantis'
              when machine = 'SlotMachine.SlotMachine26' then 'Juicy Fruits'
              when machine = 'SlotMachine.SlotMachine27' then 'Seashell Seashore'
              when machine = 'SlotMachine.SlotMachine28' then 'Kitty Riches'
              when machine = 'SlotMachine.SlotMachine29' then "Spike's Lounge"
              when machine = 'SlotMachineG2.SlotMachine30' then 'Spirit Canyon'
              when machine = 'Buffalo Canyon' then 'Spirit Canyon'
              when machine = 'SlotMachineG2.SlotMachine31' then 'The Enchanted Mirror'
              when machine = 'SlotMachineG2.SlotMachine33' then 'Queen of Egypt'
              when machine = 'SlotMachineG2.SlotMachine34' then 'Battle of Olympus'
              when machine = 'SlotMachineG2.SlotMachine35' then "Gladiator's Gold"
              when machine = 'SlotMachineG2.SlotMachine36' then 'Mysterious Woods'
              when machine = 'SlotMachineG2.SlotMachine37' then 'Outlaw Riches'
              when machine = 'SlotMachineG2.SlotMachine39' then 'Geisha'  
              when machine = 'SlotMachineG2.SlotMachine40' then 'King of the Wild'
              when machine = 'SlotMachineG2.SlotMachine41' then 'Diamond Wins' 
              when machine = 'SlotMachineG2.SlotMachine42' then 'Twin Wins' 
              when machine = 'SlotMachineG2.SlotMachine43' then 'Lager Lodge' 
              when machine = 'SlotMachineG2.SlotMachine45' then 'Miss Kitty' 
              when machine = 'SlotMachineG2.SlotMachine46' then 'Hollywood Land' 
              else machine end as machines
          FROM islot.ledger2, islothd.ledger2
          WHERE ds >= '2014-06-01'
            and note = 'slot_machine_bet'
            and mobileID != ''
            and machine != ''
            and machine != 'N/A'
          GROUP EACH BY idfa, mobileID, machines, ios_cv, ds
          ) a
        LEFT OUTER JOIN EACH views.internal_devices b
        ON a.idfa = b.ios_idfa
        WHERE b.ios_idfa is null 
        ) users
      CROSS JOIN EACH
        (
        SELECT ds, note, ios_cv
          , case when machine = 'SlotMachine.SlotMachine0' then "Joker's Wild"
            when machine = 'SlotMachine.SlotMachine1' then 'Cactus Cowboy'
            when machine = 'SlotMachine.SlotMachine2' then 'Fashionista'
            when machine = 'SlotMachine.SlotMachine5' then 'The Syndicate'
            when machine = 'SlotMachine.SlotMachine6' then "Pharoah's Treasure"
            when machine = 'SlotMachine.SlotMachine7' then 'Ice Cream Shop'
            when machine = 'SlotMachine.SlotMachine8' then 'Under the Sea'
            when machine = 'SlotMachine.SlotMachine9' then 'Mystery Mansion'
            when machine = 'SlotMachine.SlotMachine10' then 'Faeries'
            when machine = 'SlotMachine.SlotMachine11' then 'Excalibur'
            when machine = 'SlotMachine.SlotMachine12' then 'Lucky Farm'
            when machine = 'SlotMachine.SlotMachine13' then 'Treasure Cove'
            when machine = 'SlotMachine.SlotMachine14' then 'Spooky Slots'
            when machine = "Sorcerer's School" then 'Spooky Slots'
            when machine = 'SlotMachine.SlotMachine15' then 'Harvest Feast'
            when machine = 'Harvest Festival' then 'Harvest Feast'
            when machine = 'SlotMachine.SlotMachine16' then "Santa's Workshop"
            when machine = 'SlotMachine.SlotMachine17' then 'Gold Rush'
            when machine = 'SlotMachine.SlotMachine18' then 'Secret Valentine'
            when machine = 'SlotMachine.SlotMachine19' then 'Pot O Gold'
            when machine = 'SlotMachine.SlotMachine20' then 'Bunny Lane'
            when machine = 'SlotMachine.SlotMachine21' then 'Mayan Treasures'
            when machine = 'SlotMachine.SlotMachine22' then 'Cosmic Gems'
            when machine = 'SlotMachine.SlotMachine23' then 'Candy Craze'
            when machine = 'SlotMachine.SlotMachine24' then "Lucky 7's"
            when machine = 'SlotMachine.SlotMachine25' then 'Atlantis'
            when machine = 'SlotMachine.SlotMachine26' then 'Juicy Fruits'
            when machine = 'SlotMachine.SlotMachine27' then 'Seashell Seashore'
            when machine = 'SlotMachine.SlotMachine28' then 'Kitty Riches'
            when machine = 'SlotMachine.SlotMachine29' then "Spike's Lounge"
            when machine = 'SlotMachineG2.SlotMachine30' then 'Spirit Canyon'
            when machine = 'Buffalo Canyon' then 'Spirit Canyon'
            when machine = 'SlotMachineG2.SlotMachine31' then 'The Enchanted Mirror'
            when machine = 'SlotMachineG2.SlotMachine33' then 'Queen of Egypt'
            when machine = 'SlotMachineG2.SlotMachine34' then 'Battle of Olympus'
            when machine = 'SlotMachineG2.SlotMachine35' then "Gladiator's Gold"
            when machine = 'SlotMachineG2.SlotMachine36' then 'Mysterious Woods'
            when machine = 'SlotMachineG2.SlotMachine37' then 'Outlaw Riches'
            when machine = 'SlotMachineG2.SlotMachine39' then 'Geisha'  
            when machine = 'SlotMachineG2.SlotMachine40' then 'King of the Wild'
            when machine = 'SlotMachineG2.SlotMachine41' then 'Diamond Wins' 
            when machine = 'SlotMachineG2.SlotMachine42' then 'Twin Wins' 
            when machine = 'SlotMachineG2.SlotMachine43' then 'Lager Lodge' 
            when machine = 'SlotMachineG2.SlotMachine45' then 'Miss Kitty' 
            when machine = 'SlotMachineG2.SlotMachine46' then 'Hollywood Land' 
            else machine end as machines
        FROM islot.ledger2, islothd.ledger2
        WHERE ds >= '2014-06-01'
          and mobileID != ''
          and machine != ''
          and machine != 'N/A'
        GROUP EACH BY machines, ds, note, ios_cv
        ) slots
      WHERE users.machines = slots.machines
        and users.ds = slots.ds
        and users.ios_cv = slots.ios_cv
      GROUP EACH BY mobileID, machines, ios_cv, ds, note
      ) notes
    LEFT OUTER JOIN EACH
      (
      SELECT mobileID, note, ds, ios_cv, sum(amount) as total
        , case when machine = 'SlotMachine.SlotMachine0' then "Joker's Wild"
          when machine = 'SlotMachine.SlotMachine1' then 'Cactus Cowboy'
          when machine = 'SlotMachine.SlotMachine2' then 'Fashionista'
          when machine = 'SlotMachine.SlotMachine5' then 'The Syndicate'
          when machine = 'SlotMachine.SlotMachine6' then "Pharoah's Treasure"
          when machine = 'SlotMachine.SlotMachine7' then 'Ice Cream Shop'
          when machine = 'SlotMachine.SlotMachine8' then 'Under the Sea'
          when machine = 'SlotMachine.SlotMachine9' then 'Mystery Mansion'
          when machine = 'SlotMachine.SlotMachine10' then 'Faeries'
          when machine = 'SlotMachine.SlotMachine11' then 'Excalibur'
          when machine = 'SlotMachine.SlotMachine12' then 'Lucky Farm'
          when machine = 'SlotMachine.SlotMachine13' then 'Treasure Cove'
          when machine = 'SlotMachine.SlotMachine14' then 'Spooky Slots'
          when machine = "Sorcerer's School" then 'Spooky Slots'
          when machine = 'SlotMachine.SlotMachine15' then 'Harvest Feast'
          when machine = 'Harvest Festival' then 'Harvest Feast'
          when machine = 'SlotMachine.SlotMachine16' then "Santa's Workshop"
          when machine = 'SlotMachine.SlotMachine17' then 'Gold Rush'
          when machine = 'SlotMachine.SlotMachine18' then 'Secret Valentine'
          when machine = 'SlotMachine.SlotMachine19' then 'Pot O Gold'
          when machine = 'SlotMachine.SlotMachine20' then 'Bunny Lane'
          when machine = 'SlotMachine.SlotMachine21' then 'Mayan Treasures'
          when machine = 'SlotMachine.SlotMachine22' then 'Cosmic Gems'
          when machine = 'SlotMachine.SlotMachine23' then 'Candy Craze'
          when machine = 'SlotMachine.SlotMachine24' then "Lucky 7's"
          when machine = 'SlotMachine.SlotMachine25' then 'Atlantis'
          when machine = 'SlotMachine.SlotMachine26' then 'Juicy Fruits'
          when machine = 'SlotMachine.SlotMachine27' then 'Seashell Seashore'
          when machine = 'SlotMachine.SlotMachine28' then 'Kitty Riches'
          when machine = 'SlotMachine.SlotMachine29' then "Spike's Lounge"
          when machine = 'SlotMachineG2.SlotMachine30' then 'Spirit Canyon'
          when machine = 'Buffalo Canyon' then 'Spirit Canyon'
          when machine = 'SlotMachineG2.SlotMachine31' then 'The Enchanted Mirror'
          when machine = 'SlotMachineG2.SlotMachine33' then 'Queen of Egypt'
          when machine = 'SlotMachineG2.SlotMachine34' then 'Battle of Olympus'
          when machine = 'SlotMachineG2.SlotMachine35' then "Gladiator's Gold"
          when machine = 'SlotMachineG2.SlotMachine36' then 'Mysterious Woods'
          when machine = 'SlotMachineG2.SlotMachine37' then 'Outlaw Riches'
          when machine = 'SlotMachineG2.SlotMachine39' then 'Geisha'  
          when machine = 'SlotMachineG2.SlotMachine40' then 'King of the Wild'
          when machine = 'SlotMachineG2.SlotMachine41' then 'Diamond Wins' 
          when machine = 'SlotMachineG2.SlotMachine42' then 'Twin Wins' 
          when machine = 'SlotMachineG2.SlotMachine43' then 'Lager Lodge' 
          when machine = 'SlotMachineG2.SlotMachine45' then 'Miss Kitty' 
          when machine = 'SlotMachineG2.SlotMachine46' then 'Hollywood Land' 
          else machine end as machines
      FROM islot.ledger2, islothd.ledger2
      WHERE ds >= '2014-06-01'
        and mobileID != ''
        and machine != ''
        and machine != 'N/A'
      GROUP EACH BY mobileID, note, machines, ds, ios_cv
      ) amounts
    ON notes.mobileID = amounts.mobileID
      and notes.note = amounts.note
      and notes.machines = amounts.machines
      and notes.ds = amounts.ds
      and notes.ios_cv = amounts.ios_cv
    )
  )
GROUP EACH BY users, amount_25, amount_50, amount_75, machine, ios_cv, ds, note

1 个答案:

答案 0 :(得分:1)

CROSS JOIN EACH不受支持。我将其更改为CROSS JOIN并且它有效。不幸的是,错误信息并不具备信息。