All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.table.client.gateway.Executor Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.table.client.gateway;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.table.api.TableSchema;
import org.apache.flink.table.client.gateway.local.ExecutionContext;
import org.apache.flink.table.client.gateway.local.result.DynamicResult;
import org.apache.flink.types.Row;

import java.util.List;
import java.util.Map;

/**
 * A gateway for communicating with Flink and other external systems.
 */
public interface Executor {

	/**
	 * Starts the executor and ensures that its is ready for commands to be executed.
	 */
	void start() throws SqlExecutionException;

	/**
	 * Lists all session properties that are defined by the executor and the session.
	 */
	Map getSessionProperties(SessionContext session) throws SqlExecutionException;

	/**
	 * Lists all tables and views in the default database.
	 */
	List listTables(SessionContext session) throws SqlExecutionException;

	/**
	 * Lists all views in the default database.
	 */
	List listViews(SessionContext session) throws SqlExecutionException;

	/**
	 * Lists all user-defined functions known to the executor.
	 */
	List listUserDefinedFunctions(SessionContext session) throws SqlExecutionException;

	/**
	 * Lists all partitions in the specified table from ddl.
	 */
	List listPartitions(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Get the create table ddl.
	 */
	String showCreateTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Set the default database with a DDL.
	 * If a catalog is not specified, the database is resolved relative to the current catalog.
	 * Note! This method does not support setting default catalog only.
	 */
	void setDefaultDatabase(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Set the default catalog with a DDL.
	 */
	void setDefaultCatalog(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Lists all registered catalogs.
	 */
	List listCatalogs(SessionContext session) throws SqlExecutionException;

	/**
	 * Lists all databases in the default catalog.
	 */
	List listDatabases(SessionContext session) throws SqlExecutionException;

	/**
	 * Returns the schema of a table with a DDL. Throws an exception if the table could not be found.
	 * The schema might contain time attribute types for helping the user during debugging a query.
	 */
	TableSchema getTableSchema(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Describes a table with a DDL.
	 */
	TableDesc describeTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Returns a string-based explanation about AST and execution plan of the given statement.
	 */
	String explainStatement(SessionContext session, String statement) throws SqlExecutionException;

	/**
	 * Returns a list of completion hints for the given statement at the given position.
	 */
	List completeStatement(SessionContext session, String statement, int position);

	/**
	 * Submits a Flink SQL query job (detached) and returns the result descriptor.
	 */
	ResultDescriptor executeQuery(SessionContext session, String query) throws SqlExecutionException;

	/**
	 * Asks for the next changelog results (non-blocking).
	 */
	TypedResult>> retrieveResultChanges(SessionContext session, String resultId, String query) throws SqlExecutionException;

	/**
	 * Creates an immutable result snapshot of the running Flink job. Throws an exception if no Flink job can be found.
	 * Returns the number of pages.
	 */
	TypedResult snapshotResult(SessionContext session, String resultId, String query, int pageSize) throws SqlExecutionException;

	/**
	 * Returns the rows that are part of the current page or throws an exception if the snapshot has been expired.
	 */
	List retrieveResultPage(String resultId, String query, int page) throws SqlExecutionException;

	TypedResult> retrieveResults(String resultId, String query) throws SqlExecutionException;

	/**
	 * Cancels a table program and stops the result retrieval. Blocking until cancellation command has
	 * been sent to cluster.
	 */
	void cancelQuery(SessionContext session, String resultId, String query) throws SqlExecutionException;

	/**
	 * Submits a Flink SQL update statement such as INSERT INTO and DELETE FROM.
	 *
	 * @param session   context in with the statement is executed
	 * @param statement SQL update statement (currently INSERT INTO and DELETE FROM are supported)
	 * @return information about the target of the submitted Flink job
	 */
	ProgramTargetDescriptor executeUpdate(SessionContext session, String statement) throws SqlExecutionException;

	/**
	 * Validates the current session. For example, it checks whether all views are still valid.
	 */
	void validateSession(SessionContext session) throws SqlExecutionException;

	/**
	 * Create a database with a DDL.
	 */
	void createDatabase(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Create a table with a DDL.
	 */
	void createTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Alter table ddl.
	 */
	void alterTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Drop a table with a DDL.
	 */
	void dropTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Create a view with a DDL.
	 */
	void createView(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Drop a view with a DDL.
	 */
	void dropView(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Create a function with a DDL.
	 */
	void createFunction(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Drop a database with a DDL.
	 */
	void dropDatabase(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Drop a function with a DDL.
	 */
	void dropFunction(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Stops the executor.
	 */
	void stop(SessionContext session);

	/**
	 * Describe database with DDL.
	 */
	DatabaseDesc describeDatabase(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Alters a database with DDL.
	 */
	void alterDatabase(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Applies the given SQL query statement to current TableEnvironment and returns the result.
	 */
	DynamicResult applyBondQuery(SessionContext session, String query) throws SqlExecutionException;

	/**
	 * Applies the given SQL update statement to current TableEnvironment.
	 */
	void applyBondUpdate(SessionContext session, String update) throws SqlExecutionException;

	/**
	 * Submits a Bond SQL query job (detached).
	 */
	List executeBondQuery(SessionContext session, List> results, String name) throws SqlExecutionException;

	/**
	 * Analyze table and update table's stats.
	 */
	void analyzeTable(SessionContext session, String ddl) throws SqlExecutionException;

	/**
	 * Generate analyze SQL.
	 */
	String generateAnalyzeSQL(SessionContext session, String tableName) throws SqlExecutionException;

	/**
	 * apply TableStats.
	 */
	void applyTableStats(SessionContext session, String tableName, Row stats) throws SqlExecutionException;

	ExecutionContext getOrCreateExecutionContext(SessionContext session) throws SqlExecutionException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy