CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-flink--flink-table-api-java-uber

Comprehensive uber JAR that consolidates all Java APIs for Apache Flink's Table/SQL ecosystem, enabling developers to write table programs and integrate with other Flink APIs through a single dependency.

Pending
Overview
Eval results
Files

table-operations.mddocs/

Table Operations

Core table manipulation and query capabilities for creating, transforming, aggregating, and joining tables in Apache Flink's Table API.

Capabilities

TableEnvironment

Primary entry point for all Table API programs providing table registration, SQL execution, and environment configuration.

/**
 * Creates a new TableEnvironment with specified settings
 * @param settings Configuration for the table environment
 * @return New TableEnvironment instance
 */
public static TableEnvironment create(EnvironmentSettings settings);

/**
 * Create a table from a registered path in the catalog
 * @param path Catalog path to the table (e.g., "database.table" or "table")
 * @return Table instance for further operations
 */
public Table from(String path);

/**
 * Execute a SQL statement (DDL, DML, or query)
 * @param statement SQL statement to execute
 * @return TableResult containing execution results or metadata
 */
public TableResult executeSql(String statement);

/**
 * Create a table from a SQL query without executing it
 * @param query SQL SELECT query
 * @return Table instance representing the query results
 */
public Table sqlQuery(String query);

/**
 * Register a table as a temporary view
 * @param path Name/path for the temporary view
 * @param view Table to register
 */
public void createTemporaryView(String path, Table view);

/**
 * Switch to a different catalog
 * @param catalogName Name of the catalog to use
 */
public void useCatalog(String catalogName);

/**
 * Switch to a different database within the current catalog
 * @param databaseName Name of the database to use
 */
public void useDatabase(String databaseName);

Usage Example:

// Create environment
EnvironmentSettings settings = EnvironmentSettings.newInstance()
    .inStreamingMode()
    .build();
TableEnvironment tEnv = TableEnvironment.create(settings);

// Register source table
tEnv.executeSql("CREATE TABLE orders (" +
    "id BIGINT, product STRING, amount DECIMAL(10,2)" +
    ") WITH ('connector' = 'kafka', ...)");

// Create table reference
Table orders = tEnv.from("orders");

EnvironmentSettings

Configuration builder for TableEnvironment initialization specifying execution mode and planner settings.

/**
 * Create a new environment settings builder
 * @return Builder instance for configuration
 */
public static Builder newInstance();

public static class Builder {
    /**
     * Configure for streaming execution mode
     * @return Builder instance for method chaining
     */
    public Builder inStreamingMode();
    
    /**
     * Configure for batch execution mode
     * @return Builder instance for method chaining
     */
    public Builder inBatchMode();
    
    /**
     * Set the name of the built-in catalog
     * @param catalogName Name for the default catalog
     * @return Builder instance for method chaining
     */
    public Builder withBuiltInCatalogName(String catalogName);
    
    /**
     * Set the name of the built-in database
     * @param databaseName Name for the default database
     * @return Builder instance for method chaining
     */
    public Builder withBuiltInDatabaseName(String databaseName);
    
    /**
     * Build the environment settings
     * @return Configured EnvironmentSettings instance
     */
    public EnvironmentSettings build();
}

Table Interface

Core interface representing a table and providing all transformation operations.

/**
 * Project specific columns from the table
 * @param fields Expressions representing the columns to select
 * @return New Table with selected columns
 */
public Table select(Expression... fields);

/**
 * Filter rows based on a predicate
 * @param predicate Boolean expression for filtering
 * @return New Table with filtered rows
 */
public Table filter(Expression predicate);

/**
 * Group rows by specified fields for aggregation
 * @param fields Expressions representing grouping columns
 * @return GroupedTable instance for aggregation operations
 */
public GroupedTable groupBy(Expression... fields);

/**
 * Apply window function for time-based operations
 * @param window Window specification (tumbling, sliding, or session)
 * @return WindowedTable instance for windowed operations
 */
public WindowedTable window(GroupWindow window);

/**
 * Perform inner join with another table
 * @param right Table to join with
 * @return New Table containing joined results
 */
public Table join(Table right);

/**
 * Perform inner join with join condition
 * @param right Table to join with
 * @param joinPredicate Join condition expression
 * @return New Table containing joined results
 */
public Table join(Table right, Expression joinPredicate);

/**
 * Perform left outer join with another table
 * @param right Table to join with
 * @param joinPredicate Join condition expression
 * @return New Table containing left outer join results
 */
public Table leftOuterJoin(Table right, Expression joinPredicate);

/**
 * Perform right outer join with another table
 * @param right Table to join with
 * @param joinPredicate Join condition expression
 * @return New Table containing right outer join results
 */
public Table rightOuterJoin(Table right, Expression joinPredicate);

/**
 * Perform full outer join with another table
 * @param right Table to join with
 * @param joinPredicate Join condition expression
 * @return New Table containing full outer join results
 */
public Table fullOuterJoin(Table right, Expression joinPredicate);

/**
 * Execute the table operation and collect results
 * @return TableResult containing the execution results
 */
public TableResult execute();

/**
 * Insert table contents into a registered sink table
 * @param tablePath Path to the target table
 * @return TableResult for the insert operation
 */
public TableResult executeInsert(String tablePath);

/**
 * Get the resolved schema of this table
 * @return ResolvedSchema containing column information and constraints
 */
public ResolvedSchema getResolvedSchema();

/**
 * Add or replace columns in the table
 * @param fields Column expressions with aliases
 * @return New Table with added/replaced columns
 */
public Table addColumns(Expression... fields);

/**
 * Drop columns from the table
 * @param fieldNames Names of columns to drop
 * @return New Table without the specified columns
 */
public Table dropColumns(String... fieldNames);

/**
 * Rename columns in the table
 * @param fields Rename expressions (oldName as newName)
 * @return New Table with renamed columns
 */
public Table renameColumns(Expression... fields);

/**
 * Union with another table (duplicate elimination)
 * @param right Table to union with
 * @return New Table containing union results
 */
public Table union(Table right);

/**
 * Union all with another table (no duplicate elimination)
 * @param right Table to union with
 * @return New Table containing union all results
 */
public Table unionAll(Table right);

/**
 * Remove duplicate rows from the table
 * @return New Table with duplicates removed
 */
public Table distinct();

/**
 * Sort the table by specified columns
 * @param fields Expressions for sorting (use .asc() or .desc())
 * @return New Table with sorted rows
 */
public Table orderBy(Expression... fields);

/**
 * Limit the number of rows returned
 * @param fetch Maximum number of rows to return
 * @return New Table with limited rows
 */
public Table limit(int fetch);

/**
 * Limit with offset support
 * @param offset Number of rows to skip
 * @param fetch Maximum number of rows to return
 * @return New Table with offset and limit applied
 */
public Table limit(int offset, int fetch);

Usage Examples:

// Basic transformations
Table result = orders
    .select($("product"), $("amount"), $("order_date"))
    .filter($("amount").isGreater(lit(100)))
    .orderBy($("amount").desc())
    .limit(10);

// Joins
Table orderDetails = orders
    .join(products, $("orders.product_id").isEqual($("products.id")))
    .select($("orders.id"), $("products.name"), $("orders.amount"));

// Aggregations
Table summary = orders
    .groupBy($("product"))
    .select($("product"), 
            $("amount").sum().as("total_amount"),
            $("id").count().as("order_count"));

GroupedTable

Specialized table interface for grouped data that can be aggregated.

/**
 * Apply aggregation functions to grouped data
 * @param aggregateExpressions Aggregation expressions
 * @return AggregatedTable for further operations
 */
public AggregatedTable aggregate(Expression... aggregateExpressions);

/**
 * Select columns and aggregations from grouped data
 * @param fields Column and aggregation expressions
 * @return New Table with aggregated results
 */
public Table select(Expression... fields);

AggregatedTable

Specialized table interface representing aggregated data.

/**
 * Select final columns from aggregated data
 * @param fields Column expressions for final selection
 * @return New Table with selected aggregated results
 */
public Table select(Expression... fields);

WindowedTable

Specialized table interface for windowed operations on streaming data.

/**
 * Group windowed data by specified fields
 * @param fields Expressions representing grouping columns
 * @return GroupedTable for windowed aggregation
 */
public GroupedTable groupBy(Expression... fields);

TableResult

Result of table operations providing access to data and metadata.

/**
 * Print the results to stdout (for development/debugging)
 */
public void print();

/**
 * Get the job client for the submitted job (async execution)
 * @return Optional JobClient if the operation was submitted as a job
 */
public Optional<JobClient> getJobClient();

/**
 * Get the result schema
 * @return ResolvedSchema of the result
 */
public ResolvedSchema getResolvedSchema();

/**
 * Get the result kind (success, success with content, etc.)
 * @return ResultKind indicating the type of result
 */
public ResultKind getResultKind();

/**
 * Collect all results as a list (for bounded results only)
 * @return CloseableIterator for accessing result rows
 */
public CloseableIterator<Row> collect();

Window Specifications

Factory classes for creating time-based windows.

// Tumble - Non-overlapping windows
public class Tumble {
    /**
     * Create a tumbling window with specified size
     * @param size Window size expression (e.g., lit(1).hours())
     * @return TumbleWithSize for further configuration
     */
    public static TumbleWithSize over(Expression size);
}

public class TumbleWithSize {
    /**
     * Specify the time field for the window
     * @param timeField Time attribute field
     * @return TumbleWithSizeOnTime for alias assignment
     */
    public TumbleWithSizeOnTime on(Expression timeField);
}

public class TumbleWithSizeOnTime {
    /**
     * Assign an alias to the window
     * @param alias Window alias for referencing in aggregations
     * @return GroupWindow specification
     */
    public GroupWindow as(String alias);
}

// Slide - Overlapping windows
public class Slide {
    /**
     * Create a sliding window with specified size
     * @param size Window size expression
     * @return SlideWithSize for further configuration
     */
    public static SlideWithSize over(Expression size);
}

public class SlideWithSize {
    /**
     * Specify the slide interval
     * @param slide Slide interval expression (must be less than size)
     * @return SlideWithSizeAndSlide for time field specification
     */
    public SlideWithSizeAndSlide every(Expression slide);
}

public class SlideWithSizeAndSlide {
    /**
     * Specify the time field for the window
     * @param timeField Time attribute field
     * @return SlideWithSizeAndSlideOnTime for alias assignment
     */
    public SlideWithSizeAndSlideOnTime on(Expression timeField);
}

// Session - Event-driven windows
public class Session {
    /**
     * Create a session window with specified gap
     * @param gap Session timeout gap expression
     * @return SessionWithGap for further configuration
     */
    public static SessionWithGap withGap(Expression gap);
}

Window Usage Example:

// Tumbling window - 1 hour non-overlapping windows
Table hourlyStats = events
    .window(Tumble.over(lit(1).hours()).on($("timestamp")).as("w"))
    .groupBy($("w"), $("category"))
    .select($("category"), 
            $("w").start().as("window_start"),
            $("w").end().as("window_end"),
            $("value").sum().as("total_value"));

// Sliding window - 1 hour windows every 15 minutes
Table slidingStats = events
    .window(Slide.over(lit(1).hours()).every(lit(15).minutes()).on($("timestamp")).as("w"))
    .groupBy($("w"), $("user_id"))
    .select($("user_id"), $("value").avg().as("avg_value"));

// Session window - Group by 30 minute inactivity gaps
Table sessionStats = events
    .window(Session.withGap(lit(30).minutes()).on($("timestamp")).as("w"))
    .groupBy($("w"), $("user_id"))
    .select($("user_id"), $("w").start().as("session_start"), $("event").count().as("event_count"));

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-flink--flink-table-api-java-uber

docs

connectors.md

data-types.md

datastream-bridge.md

expressions.md

functions.md

index.md

sql-gateway.md

table-operations.md

tile.json