Class DataFrame

java.lang.Object
com.snowflake.snowpark_java.DataFrame

public class DataFrame extends Object
A Snowpark DataFrame: a PLAN, not a result.

session.sql(...) submits nothing — the statement runs when an action asks for its rows, and runs AGAIN for each further action. Measured on live: a handler that calls collect() twice on session.sql("INSERT INTO sink VALUES (1)") leaves two rows, and count() counts as an action alongside collect(). A handler that never calls an action submits nothing at all, which is why the same body that appears to create a temporary table under owner's rights is silently a no-op there. Executing inside sql() — as this stub used to — made every such handler do real work here and nothing on Snowflake, a divergence that hides rather than fails.

  • Constructor Details

    • DataFrame

      public DataFrame(ResultSet resultSet)
      A frame over rows that have already been produced.
  • Method Details

    • select

      public DataFrame select(Column... columns)
      Project the given columns — a PLAN operation, so nothing runs until an action asks for rows. This and filter(com.snowflake.snowpark_java.Column) are the paths a handler uses a Column through; the real API has no way to ask a Column for its SQL, so building one is only ever a means to one of these.
    • filter

      public DataFrame filter(Column condition)
      Keep the rows the condition holds for. A plan operation, like select(com.snowflake.snowpark_java.Column...).
    • where

      public DataFrame where(Column condition)
      Snowpark's spelling of filter(com.snowflake.snowpark_java.Column); both exist on the real DataFrame.
    • sort

      public DataFrame sort(Column... columns)
      ORDER BY, taking the ordering columns as asc() / desc_nulls_last() etc.
    • limit

      public DataFrame limit(int count)
    • distinct

      public DataFrame distinct()
    • drop

      public DataFrame drop(String... columnNames)
      Snowflake's SELECT * EXCLUDE (…) carries this one directly.
    • union

      public DataFrame union(DataFrame other)
    • unionAll

      public DataFrame unionAll(DataFrame other)
    • except

      public DataFrame except(DataFrame other)
    • intersect

      public DataFrame intersect(DataFrame other)
    • crossJoin

      public DataFrame crossJoin(DataFrame other)
    • withColumn

      public DataFrame withColumn(String columnName, Column value)
      Append a computed column, keeping the ones already there.
    • rename

      public DataFrame rename(String newName, Column column)
      Rename one column, leaving the rest and their order alone — SELECT * RENAME (…).
    • agg

      public DataFrame agg(Column... aggregates)
      Aggregate the whole frame, with no grouping.
    • col

      public Column col(String columnName)
      A column of this frame, by name.
    • first

      public Optional<Row> first()
      The first row, or empty when the frame has none. An ACTION: it runs the plan.
    • first

      public Row[] first(int count)
      The first count rows. An ACTION.
    • collect

      public Row[] collect()
      The rows, as Snowpark's Row rather than the engine's own — a handler calls rows[0].getString(0), which the engine's row has no method for.
    • schema

      public StructType schema()
      The column names and types, as Snowpark describes them.
    • count

      public long count()
    • getResultSet

      public ResultSet getResultSet()
      The engine's own result, for Frostlake's plumbing rather than for a handler. Its return type does not exist on Snowflake, so — unlike a method returning only JDK types — no portable handler can be written against it by accident.