Class AnalyticQuery

java.lang.Object
tech.tablesaw.analytic.AnalyticQuery

public final class AnalyticQuery extends Object
A class representing an analytic query similar to the Over or Window clause in SQL.
  • Method Details

    • query

      Entry point for the fluent analytic query builder. Order By and Partition By are optional.

      An AnalyticQuery performs a calculation across a set of table rows that are somehow related to the current row.

       Query includes steps for:
       FROM table_name
       [ PARTITION BY co1, col2... ]
       [ ORDER BY col1, col2...]
       window_frame_clause AnalyticQuerySteps.DefineWindowFame
       argument_list AnalyticQuerySteps.AnalyticFunctions
       
      Returns:
      a fluent analytic query builder.
    • numberingQuery

      @Beta public static AnalyticQuerySteps.NumberingQuerySteps.FromStep numberingQuery()
      Entry point for the fluent Numbering Query Builder.

      A numbering assigns integer values to each row based on their position within the specified partition. Numbering queries require Order By.

       Query includes steps for:
       FROM table_name
       [ PARTITION BY col1, col2...]
       ORDER BY
       argument_list AnalyticQuerySteps.NumberingFunctions
       
      Returns:
      a fluent numbering query builder.
    • quickQuery

      @Beta public static AnalyticQuerySteps.QuickQuerySteps.FromStep quickQuery()
      Entry point for the fluent Analytic Query Builder. Same as the query() but skips the ORDER BY and PARTITION BY steps.
       Query includes steps for:
       FROM table_name
       window_frame_clause AnalyticQuerySteps.DefineWindowFame
       argument_list AnalyticQuerySteps.AnalyticFunctions
       
      Returns:
      a fluent analytic query builder that will skip the PartitionBy and OrderBy steps.
    • getTable

      public Table getTable()
      The Table behind the query.
      Returns:
      the underlying Table behind this query.
    • toSqlLikeString

      public String toSqlLikeString()
      Creates a SQL like string for documentation purposes. The returned SQL is not meant be executed in SQL database.
      Returns:
      a SQL like string explaining the query.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • execute

      public Table execute()
      Executes the query adding all the calculated columns to a new table. The result columns will have the same order as the from table.
      Returns:
      a new table containing only the result columns.
    • executeInPlace

      public void executeInPlace()
      Executes the query and adds all the calculated columns directly to the source table.
      Throws:
      IllegalArgumentException - if any of the calculated columns have the same name as one of the columns in the FROM table.