Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GoでBigQueryを操作する時にStructを使うか悩んでる話/go-bigquery-struct-worries

 GoでBigQueryを操作する時にStructを使うか悩んでる話/go-bigquery-struct-worries

【HRBrain x コネヒト合同開催】Let's Go Talk #10 でLTした資料です。
https://connehito.connpass.com/event/290692/

Shoichiro Nagai(shnagai)

August 22, 2023
Tweet

More Decks by Shoichiro Nagai(shnagai)

Other Decks in Technology

Transcript

  1. (PͰ#JH2VFSZΛૢ࡞͢Δ࣌ʹ
    4USVDUΛ࢖͏͔೰ΜͰΔ࿩
    ʲ)3#SBJOYίωώτ߹ಉ։࠵ʳ-FUT(P5BML
    ӬҪউҰ࿠

    View full-size slide

  2. ࣗݾ঺հ
    ओͳ׆ಈ

    ίωώτΤϯδχΞϒϩάIUUQTUFDIDPOOFIJUPDPNBSDIJWFBVUIPSOBHBJT
    աڈͷొஃࢿྉɹɹɹɹɹIUUQTTQFBLFSEFDLDPNTIPJDIJSPO
    ίωώτגࣜձࣾ


    ։ൃ෦௕/EM


    @shnagai
    ӬҪউҰ࿠

    View full-size slide

  3. (PͰ$-*πʔϧΛ࡞Δͱ͖ʹ
    4USVDUΛ࢖͏΂͖͔೰ΜͩͷͰ
    ࠓճ͸ΧδϡΞϧʹޠΓ·͢

    View full-size slide

  4. ࡞ͬͨ$-*πʔϧͷཁ݅
    w #JH2VFSZʹ͋ΔσʔλΛ4ʹΞοϓϩʔυ͢Δ
    w #JH2VFSZʹ42-ൃߦͯ݁͠Ռऔಘ
    w ݁ՌΛϑΝΠϧʹग़ྗ
    w ϑΝΠϧΛ4ͷಛఆόέοτʹΞοϓϩʔυ

    View full-size slide

  5. 1ZUIPOͰQBOEBT࢖͏ͱ͜Μͳ؆୯ʹ

    View full-size slide

  6. 8IZ(P
    w -FU`T(Pͱ͍͏ઓུΛςοΫϏδϣϯͰܝ͓͛ͯΓɺ

    ձࣾͱͯ͠(Pͷར༻Λਪਐ͍ͯ͠Δ
    w Ұൠతͳ(Pͷར఺
    w ϫϯόΠφϦϙϯͷັྗ
    w Ұൠతʹ͸ΫϩεϓϥοτϑΥʔϜରԠ

    View full-size slide

  7. ࢖͏ύοέʔδ
    w DMPVEHPPHMFDPNHPCJHRVFSZΛ࢖͑͹#2ૢ࡞͸༰қ
    w ϑΝΠϧૢ࡞΍$47ॻ͖ࠐΈ͸ඪ४ύοέʔδͰ

    View full-size slide

  8. ࠓճͷςʔϚͱͳΔ΋͏Ұͭͷ৚݅
    w ύλʔϯͷҟͳΔσʔλΛѻ͏ඞཁ͕͋Δ
    w ΧϥϜ͕ͦΕͧΕҟͳΔ ઃܭʜ

    w σʔλϚʔτͱͯ͠#JH2VFSZͷϏϡʔʹϩδοΫ͸࣮૷
    w ݩʑखಈͰσʔλऔಘ͍ͯͨ͠ͷͰϏϡʔʹϩδοΫΛ͍࣋ͨͤͯͨ
    w ෳࡶͳ42-͸ෆཁͰɺϏϡʔͷσʔλΛ͢΂ͯ࣋ͬͯ͘Ε͹0,

    TFMFDUͰ0,
    w 42-ͷ݁ՌΛ4USVDUʹ٧ΊࠐΉ͔೰Μͩ

    View full-size slide

  9. ࣮૷ύλʔϯ

    View full-size slide

  10. <>CJHRVFSZ7BMVFΛ࢖͏
    w ͭͷߦͷ֤ྻͷ஋Λॱ൪ʹ֨ೲ͢ΔͨΊͷεϥΠε
    w ֤஋͸ɺ#JH2VFSZͷσʔλܕʹԠͯ͡ద੾ͳ(PͷجຊܕʢJOUɺGMPBUɺTUSJOHͳ
    Ͳʣʹม׵͞ΕΔɻ
    εϥΠεͷi൪໨ͷཁૉʹ


    ߦͷi൪໨ͷྻΛૠೖ
    ΫΤϦ݁ՌΛߦ୯ҐͰऔಘ͢Δ


    ϙΠϯλܕ
    https://pkg.go.dev/cloud.google.com/go/bigquery#Value


    https://pkg.go.dev/cloud.google.com/go/bigquery#RowIterator

    View full-size slide

  11. 4USVDUͰಠࣗσʔλܕΛఆٛ
    BigQueryͷΧϥϜ໊ʹ


    ରԠ͢ΔܗͰϑΟʔϧυ໊Λఆٛ
    εΩʔϚͷ֤ྻ͸ɺେจࣈখจࣈΛແࢹ͠
    ͯɺಉ໊͡લΛ࣋ͭߏ଄ମͷΤΫεϙʔτ
    ͞ΕͨϑΟʔϧυͱর߹͞ΕΔ

    View full-size slide

  12. ͲͪΒ͕͍͍ͷ͔ॻ͖ͳ͕Β໎ͬͨ
    w ίʔυͷՄಡੑ͸4USVDU࢖͏ύλʔϯ͕ѹ౗తʹߴ͍
    w ͨͩ͠ύλʔϯఆٛͯ͠ࠓޙ૿͍͑ͯ͘͜ͱߟ͑ΔͱͦΕͰ͍͍ͷ͔
    w ൚༻తͳπʔϧͱͯ͠࡞ΔͳΒ<>CJHRVFSZ7BMVFͰܕม׵͢Δܗ͕
    ศརͦ͏
    w 42-ΛҾ਺Ͱ౉͢ͱTʹΞοϓϩʔυͯ͘͠ΕΔπʔϧతͳΠϝʔδ
    w ѻͬͯΔσʔλͷਖ਼͠͞͸ίʔυ্͔Β͸Θ͔Βͳ͍͕ɺͦͷ੹຿͸#JH2VFSZͷ
    Ϗϡʔʹ͋Δ͔Β໰୊ͳ͍ͷͰ͸
    w $-*πʔϧͱͯ͠͸ͬͪ͜ͷ࡞Γͷ΄͏͕͍͚ͯΔΑͶ

    View full-size slide

  13. ͲͪΒ͕͍͍ͷ͔ॻ͖ͳ͕Β໎ͬͨ
    w ੩తܕ෇͚ݴޠͷಛੑ׆͔͢ͳΒ4USVDU࢖͏ͷ͕CFUUFS
    ͔
    w 4USVDUΛ࢖͍ෳ਺ͷϝιουΛ࡞Δͱ͔Ͱ͋Ε͹Ըܙ͋
    Δ͕ɺࠓճ͸DTWग़ྗͷΈ͕ٻΊΒΕΔ͔ΒΦʔόʔ͔΋

    View full-size slide

  14. ࠓͷͱ͜Ζͷࣗ෼ͷ݁࿦
    w ࠓճͷέʔεͰ͸4USVDU͸࢖Θͳ͍൑அΛͨ͠
    w σʔλૢ࡞͕ܾ·͍ͬͯΔɺ͔ͭ$-*πʔϧͱͯ͠ͷ֦ு
    ੑ͕ͳ͘ͳΔ఺͕ܾΊख
    w อकੑ΍Մಡੑ͸4USVDU࢖͏ύλʔϯͷ΄͏͕ߴ͍ͱײ
    ͍ͯ͡ΔͷͰຖ౓೰·͞Εͦ͏Ͱ͸͋Δ

    View full-size slide

  15. ͲͪΒ͕ਖ਼ղ͔
    ΋ͬͱ͍͍ํ๏͋Δͷ͔͸
    ·ͩ౴͕͑ग़ͣͳͷͰ
    ͥͻ࠙਌ձͰ͓࿩͠·͠ΐ͏

    View full-size slide