
92
5 章 データのロードとセーブ
5-31
Scala
HiveContext
ー
import org.apache.spark.sql.hive.HiveContext
val hiveCtx = new HiveContext(sc)
val rows = hiveCtx.sql("SELECT name, age FROM users")
val firstRow = rows.first()
println(firstRow.getString(0)) //
フィールド
0
は名前
5-32
Java
HiveContext
ー
import org.apache.spark.sql.hive.HiveContext;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SchemaRDD;
HiveContext hiveCtx = new HiveContext(sc);
SchemaRDD rows = hiveCtx.sql("SELECT name, age FROM users");
Row firstRow = rows.first();
System.out.println(firstRow.getString(0)); //
フィールド
0
は名前
Hive
からのデータのロードについては、「
9.3.1 Apache Hive
」で詳しく取り上げます。
5.4.2
JSON ...