Class ResultsSet


  • public class ResultsSet
    extends java.lang.Object
    A convenience wrapper for a Spark results set.
    Author:
    Anthony Bradley
    • Constructor Summary

      Constructors 
      Constructor Description
      ResultsSet​(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame, java.lang.String viewName)
      Construct a Dataset from a DatasetRow normally as a result of another query.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> getDataframe()  
      java.lang.String getTableName()  
      void setDataframe​(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataframe)  
      void setTableName​(java.lang.String tableName)  
      void show()
      Show the first 20 lines of the dataset.
      void show​(int numLines)
      Show the first N lines of the dataset.
      ResultsSet sql​(java.lang.String sql)
      Perform an SQL query on the dataset.
      ResultsSet sql​(java.lang.String sql, java.lang.String viewName)
      Perform an SQL query on the dataset.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResultsSet

        public ResultsSet​(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame,
                          java.lang.String viewName)
        Construct a Dataset from a DatasetRow normally as a result of another query.
        Parameters:
        dataFrame - the input (result from an SQL query)
        viewName - the name of the new view - to be used in queries
    • Method Detail

      • show

        public void show()
        Show the first 20 lines of the dataset.
      • show

        public void show​(int numLines)
        Show the first N lines of the dataset.
        Parameters:
        numLines - the number of lines to show
      • sql

        public ResultsSet sql​(java.lang.String sql)
        Perform an SQL query on the dataset. Resulting table will have name of temp.
        Parameters:
        sql - the SQL query to perform
        Returns:
        the ResultsSet of the queried data
      • sql

        public ResultsSet sql​(java.lang.String sql,
                              java.lang.String viewName)
        Perform an SQL query on the dataset. Resulting table will have name provided.
        Parameters:
        sql - the SQL query to perform
        viewName - the table name of the resulting table
        Returns:
        the ResultsSet of the queried data
      • getDataframe

        public org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> getDataframe()
        Returns:
        the dataframe
      • setDataframe

        public void setDataframe​(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataframe)
        Parameters:
        dataframe - the dataframe to set
      • getTableName

        public java.lang.String getTableName()
        Returns:
        the tableName
      • setTableName

        public void setTableName​(java.lang.String tableName)
        Parameters:
        tableName - the tableName to set