Examples of registerTempTable()


Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

  @Test
  public void testBasicRead() throws Exception {
    JavaSchemaRDD schemaRDD = artistsAsSchemaRDD();
    assertTrue(schemaRDD.count() > 300);
    schemaRDD.registerTempTable("datfile");
    System.out.println(schemaRDD.schemaString());
    assertEquals(5, schemaRDD.take(5).size());
    JavaSchemaRDD results = sqc
        .sql("SELECT name FROM datfile WHERE id >=1 AND id <=10");
    assertEquals(10, schemaRDD.take(10).size());
View Full Code Here

Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

    assertTrue(schema.contains("time: long"));
    assertTrue(schema.contains("url: string"));

    // schemaRDD.take(5).foreach(println)

    schemaRDD.registerTempTable("basicRead");
    JavaSchemaRDD nameRDD = sqc.sql("SELECT name FROM basicRead WHERE id >= 1 AND id <=10");
    assertEquals(10, nameRDD.count());

  }
View Full Code Here

Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

        }
      });

    // Apply a schema to an RDD of Java Beans and register it as a table.
    JavaSchemaRDD schemaPeople = sqlCtx.applySchema(people, Person.class);
    schemaPeople.registerTempTable("people");

    // SQL can be run over RDDs that have been registered as tables.
    JavaSchemaRDD teenagers = sqlCtx.sql("SELECT name FROM people WHERE age >= 13 AND age <= 19");

    // The results of SQL queries are SchemaRDDs and support all the normal RDD operations.
View Full Code Here

Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

    // Parquet files are self-describing so the schema is preserved.
    // The result of loading a parquet file is also a JavaSchemaRDD.
    JavaSchemaRDD parquetFile = sqlCtx.parquetFile("people.parquet");

    //Parquet files can also be registered as tables and then used in SQL statements.
    parquetFile.registerTempTable("parquetFile");
    JavaSchemaRDD teenagers2 =
      sqlCtx.sql("SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19");
    teenagerNames = teenagers2.map(new Function<Row, String>() {
      @Override
      public String call(Row row) {
View Full Code Here

Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

    // root
    //  |-- age: IntegerType
    //  |-- name: StringType

    // Register this JavaSchemaRDD as a table.
    peopleFromJsonFile.registerTempTable("people");

    // SQL statements can be run by using the sql methods provided by sqlCtx.
    JavaSchemaRDD teenagers3 = sqlCtx.sql("SELECT name FROM people WHERE age >= 13 AND age <= 19");

    // The results of SQL queries are JavaSchemaRDDs and support all the normal RDD operations.
View Full Code Here

Examples of org.apache.spark.sql.api.java.JavaSchemaRDD.registerTempTable()

    //  |-- address: StructType
    //  |    |-- city: StringType
    //  |    |-- state: StringType
    //  |-- name: StringType

    peopleFromJsonRDD.registerTempTable("people2");

    JavaSchemaRDD peopleWithCity = sqlCtx.sql("SELECT name, address.city FROM people2");
    List<String> nameAndCity = peopleWithCity.map(new Function<Row, String>() {
      @Override
      public String call(Row row) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.