Slide 1

Slide 1 text

SnowflakeʹMySQLͱJOIN͢ΔػೳΛ
 ࣮૷͢Δ גࣜձࣾαΠόʔΤʔδΣϯτ AIࣄۀຊ෦
 ࠇ࡚ ༏ଠ (@kuro_m88)

Slide 2

Slide 2 text

ࠇ࡚ ༏ଠ • גࣜձࣾαΠόʔΤʔδΣϯτ
 Dynalyst ։ൃ੹೚ऀ • ޿ࠂ഑৴γεςϜͷόοΫΤϯυΛ࡞͍ͬͯ·͢ • ීஈ͸AWS x Scalaͷ࢓ࣄ͕ଟ͍Ͱ͢ @kuro_m88 @kurochan

Slide 3

Slide 3 text

Federated QueryΛ࡞Γ͍ͨ

Slide 4

Slide 4 text

Federated Query • Redshiftʹ౥ࡌ͞Ε͍ͯΔ΍ͭ • Redshift͔ΒPostgreSQLʹΫΤϦΛ౤͛Δ͜ͱ͕Ͱ͖Δ • ͜Ε͕Ͱ͖Δͱɺ
 ϩάσʔλͱϑΝΫτσʔλͷ
 ݁߹͕Ͱ͖ͨΓͯ͠خ͍͠ • MySQL͸·ͩbeta

Slide 5

Slide 5 text

ཁ͢Δʹ͜Ε͕΍Γ͍ͨ

Slide 6

Slide 6 text

SnowflakeͰ΋΍Γ͍ͨ • Snowflakeʹຬ଍͸͍ͯ͠Δ͕ɺRedshift͕ત·͍͠ͱࢥ͏ػೳΛͻͱ্ͭ͛ Δͱ͢Ε͹Federated Query • ݱঢ়ͦͷΑ͏ͳػೳ͸ͳ͍͠ɺಉҰVPC಺ʹSnowflakeͱRDS͕ଘࡏ͠ͳ͍ͨ Ί௨৴͢Δͷ͸೉ͦ͠͏… • ત·͍͠ͷͰͳΜͱ͔ͦΕͬΆ͍΋ͷΛࣗ࡞͍ͨ͠ • ࣮૷ͯ͠Έ·ͨ͠ • CyberAgent / snowflake-aws-mysql-connector • https://github.com/CyberAgent/snowflake-aws-mysql-connector

Slide 7

Slide 7 text

Federated QueryΛ
 ࣮૷͢Δ

Slide 8

Slide 8 text

Snowflakeͱ֎෦αʔϏεͷ࿈ܞ • Snowflakeʹ͸External Functionͱ͍͏ػೳ͕͋ΓɺSQLͷؔ਺ͱͯ͠AWS Lambdaͷؔ਺Λݺͼग़͢͜ͱ͕Մೳ • Lambda FunctionͰRDSʹΞΫηεͯ͠ɺͦͷ݁ՌΛProxy͢Ε͹Snowflake ͔ΒಈతʹΫΤϦ͕౤͛ΒΕΔͷͰ͸ͳ͍͔…ʁ • ͱΓ͋͑ͣLambda Function + API Gateway

Slide 9

Slide 9 text

Lambda Function • ΄΄proxyͯ͠Δ͚ͩ • Lambda FunctionͷҾ਺͔ΒSQLͷจࣈྻΛऔΓग़͢ • DBʹΫΤϦ͢Δ • ϨεϙϯεΛ੔ܗ͢Δ

Slide 10

Slide 10 text

LambdaͷϨεϙϯεαΠζ੍ݶ • Lambda FunctionͷϨεϙϯε͸6MB·Ͱ • ༗ݶͳͷͰϨεϙϯεΛѹॖͯ͠΋Αͦ͞͏ • Ϩεϙϯε͕େ͖ͦ͏ͩͬͨΒѹॖ͢Δ͜ͱʹ
 (Ϩεϙϯεʹѹॖ͔ͨ͠Ͳ͏͔ͷϑϥά΋ೖΕ͓ͯ͘)

Slide 11

Slide 11 text

SnowflakeͷUDF • UDF = User Defined Function • UDF͸SQLͷଞʹJavascript͕ॻ͚Δ • UDF͸ʮߦʯΛฦؔ͢਺ • External Function΋ʮߦʯΛฦؔ͢਺ • ࠓճ͸SnowflakeͷςʔϒϧͱRDSͷςʔϒϧΛJOIN͍ͨ͠…

Slide 12

Slide 12 text

UDTF • User Defined Table Function • ʮςʔϒϧʯΛฦؔ͢਺ • UDF: select my_function(); • UDTF: select * from table(my_table_function()); • ͋ͱ͸ؔ਺Λςʔϒϧؔ਺ʹม׵͢Δؔ਺͕͋Ε͹ɺ
 External FunctionΛUDTFͰϥοϓ͢Ε͹͍͍͸ͣ…ʂ

Slide 13

Slide 13 text

ؔ਺Λςʔϒϧؔ਺ʹม׵͢Δؔ਺: flattenؔ਺

Slide 14

Slide 14 text

ؔ਺Λςʔϒϧؔ਺ʹม׵͢Δؔ਺: flattenؔ਺

Slide 15

Slide 15 text

API IntegrationΛઃఆ͢Δ • API Gateway(Lambda)Λݺͼग़͢ํ๏Λఆٛ͢Δ

Slide 16

Slide 16 text

External FunctionΛఆٛ͢Δ • Snowflake͔ΒAPI GateawyΛݺͼग़͢

Slide 17

Slide 17 text

UDTFΛఆٛ͢Δ • UDTFͷதͰExternal FunctionΛݺΜͰɺ݁ՌΛflatten͢Δ

Slide 18

Slide 18 text

UDTFͷத਎ͷSQL • ΫΤϦ݁Ռ͕gzipѹॖ͞Ε͍ͯͨΒల։͠ɺ
 ૉͷJSONͰ͋Ε͹ͦͷ··ύʔε͢Δ

Slide 19

Slide 19 text

࢖͍ํͷΠϝʔδ

Slide 20

Slide 20 text

࢖͍ํͷΠϝʔδ

Slide 21

Slide 21 text

No content