Skip to Content
Apache Spark によるストリーム処理
book

Apache Spark によるストリーム処理

by Gerard Maas, Francois Garillot
May 2025
Intermediate to advanced
452 pages
6h 3m
Japanese
O'Reilly Media, Inc.
Content preview from Apache Spark によるストリーム処理

第23章. Spark SQLを使う

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

これまでのところ、 、Spark Streamingがスタンドアローンのフレームワークとしてどのように機能し、多くのソースのストリームを処理し、さらに消費するために送信または保存できる結果を生成できるかを見てきた。

データセット単体では価値が限定的であるため、データセットを組み合わせて、異なるソースのデータを統合することで初めて明らかになる関係性を探りたい場合が多い。

ストリーミング・データの場合、各バッチ・インターバルで目にするデータは、無限に存在する可能性のあるデータセットのサンプルにすぎない。 したがって、ある時点で観測されたデータの価値を高めるには、すでに持っている知識と組み合わせる手段が不可欠だ。それは、ファイルやデータベースにある過去のデータかもしれないし、前日のデータに基づいて作成したモデルかもしれないし、それ以前のストリーミングデータかもしれない。

Spark Streamingの重要な価値提案の1つは、他のSparkフレームワークとのシームレスな相互運用性である。 Sparkモジュール間のこの相乗効果は、作成可能なデータ指向アプリケーションの範囲を拡大し、その結果、任意の、そしてしばしば互換性のないライブラリを独自に組み合わせるよりも複雑性の低いアプリケーションを実現する。 これは開発効率の向上につながり、アプリケーションによって提供されるビジネス価値を向上させる。

この章では、Spark StreamingアプリケーションをSpark SQLと組み合わせる方法を探る。

第II部で見たように、Structured Streamingは、Spark SQLの抽象化をストリーミングに使用するためのSparkのネイティブなアプローチである。 この章で説明するテクニックは、特定の目的のためにSpark SQL関数で補完したいSpark Streamingジョブがある場合に適用される。

ストリーム処理に対する純粋なSpark SQLのアプローチについては、まずStructured Streamingを検討してほしい。

Spark SQL

Spark SQLは構造化データを扱うSparkモジュールであり、クエリアナライザ、オプティマイザ、実行プランナなど、従来データベースの領域で発見されてきた関数や抽象化を実装し、Sparkエンジン上で任意の構造化データソースをテーブルのように操作できるようにする。

Spark SQLは3つの重要な機能を導入している:

  • SQLクエリ言語を使用してデータ演算子を表現する。

  • データセットは、SQLに似た、 型安全なデータ処理ドメイン固有言語(DSL)である。

  • DataFramesは、データセットに対応する動的型付けされたものである。

本章では、読者がSpark SQL、データセット、およびDataFramesに精通していることを前提とする。 Spark SQLに関するより詳細な議論については、[Karau2015]を参照されたい。

Spark StreamingとSpark SQLの組み合わせにより、Spark StreamingジョブのコンテキストからSpark SQLの重要なデータ処理機能にアクセスできるようになる。 DataFramesを通じてデータベースからロードされた参照データを使用して、入力ストリームを効率的にリッチ化したり、利用可能なSQL関数を使用して高度なサマリー計算を適用したりできる。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Apache Flinkによるストリーム処理

Apache Flinkによるストリーム処理

Fabian Hueske, Vasiliki Kalavri

Publisher Resources

ISBN: 9798341650602