KsqlExecutionContext¶
KsqlExecutionContext
is an abstraction of execution contexts.
Contract (Subset)¶
Creating Stream Pull Query¶
StreamPullQueryMetadata createStreamPullQuery(
ServiceContext serviceContext,
ImmutableAnalysis analysis,
ConfiguredStatement<Query> statementOrig,
boolean excludeTombstones)
See KsqlEngine
Used when:
QueryExecutor
is requested to handle a stream pull query
Creating Sandboxed Execution Context (createSandbox)¶
KsqlExecutionContext createSandbox(
ServiceContext serviceContext)
Used when:
KsqlContext
is requested to execute a SQL textDefaultSchemaInjector
is requested toforCreateAsStatement
SchemaRegisterInjector
is requested to registerForCreateAsStandaloneExecutor
is requested to validateStatementsDistributingExecutor
is requested to executeExplainExecutor
is requested toexplainStatement
KsqlResource
is requested to configure
Statement Execution (execute)¶
ExecuteResult execute(
ServiceContext serviceContext,
ConfiguredKsqlPlan plan)
ExecuteResult execute(
ServiceContext serviceContext,
ConfiguredStatement<?> statement)
Executes a KsqlPlan or a Statement
Used when:
InteractiveStatementExecutor
is requested to execute a KsqlPlanKsqlContext
is requested to execute a statementStandaloneExecutor.StatementExecutor
is requested to handleExecutableDdl and handlePersistentQueryExplainExecutor
is requested to explain a StatementKsqlRestApplication
is requested to registerCommandTopicValidatedCommandFactory
is requested to createForPlannedQuery
Executing Scalable Push Query¶
ScalablePushQueryMetadata executeScalablePushQuery(
ImmutableAnalysis analysis,
ServiceContext serviceContext,
ConfiguredStatement<Query> statement,
PushRouting pushRouting,
PushRoutingOptions pushRoutingOptions,
QueryPlannerOptions queryPlannerOptions,
Context context,
Optional<ScalablePushQueryMetrics> scalablePushQueryMetrics)
Used when:
QueryExecutor
is requested to handle a scalable push query
Executing Table Pull Query¶
PullQueryResult executeTablePullQuery(
ImmutableAnalysis analysis,
ServiceContext serviceContext,
ConfiguredStatement<Query> statement,
HARouting routing,
RoutingOptions routingOptions,
QueryPlannerOptions queryPlannerOptions,
Optional<PullQueryExecutorMetrics> pullQueryMetrics,
boolean startImmediately,
Optional<ConsistencyOffsetVector> consistencyOffsetVector)
Used when:
QueryExecutor
is requested to handleTablePullQuery
Executing Transient Query¶
TransientQueryMetadata executeTransientQuery(
ServiceContext serviceContext,
ConfiguredStatement<Query> statement,
boolean excludeTombstones)
Used when:
CustomExecutors
is requested to handle a QUERY statementExplainExecutor
is requested to explain a QUERY statementQueryExecutor
is requested to handlePushQuery
getAllLiveQueries¶
List<QueryMetadata> getAllLiveQueries()
Used when:
ListQueriesExecutor
is requested togetLocalSimple
,getLocalExtended
QueryCapacityUtil
utility is used togetNumLivePushQueries
getPersistentQueries¶
List<PersistentQueryMetadata> getPersistentQueries()
Used when:
KsqlContext
is requested to getPersistentQueriesKsqlEngineMetrics
is requested toconfigureNumPersistentQueries
andconfigureGaugeForState
PersistentQuerySaturationMetrics
is requested torun
DiscoverClusterService
is requested torunOneIteration
SendLagService
is requested torunOneIteration
StandaloneExecutor
is requested to processesQueryFileCommandRunner
is requested to processPriorCommands- others
Parsing SQL Text¶
List<ParsedStatement> parse(
String sql)
Used when:
KsqlContext
is requested to sqlSqlFormatInjector
is requested toinject
QueryEndpoint
is requested to createStatementKsqlRestApplication
is requested to registerCommandTopicStandaloneExecutor
is requested to processesQueryFileStatementParser
is requested toparseSingleStatement
KsqlResource
is requested to handleKsqlStatements
Statement Planning (plan)¶
KsqlPlan plan(
ServiceContext serviceContext,
ConfiguredStatement<?> statement)
Plans a given DDL/DML statement (in the ServiceContext) and creates a KsqlPlan
See KsqlEngine or SandboxedExecutionContext
Used when:
KsqlEngine
is requested to execute a statementSandboxedExecutionContext
is requested to execute a statementDefaultSchemaInjector
is requested toforCreateAsStatement
SchemaRegisterInjector
is requested to registerForCreateAsValidatedCommandFactory
is requested to createForPlannedQuery
Preparing Statement for Execution¶
PreparedStatement<?> prepare(
ParsedStatement stmt,
Map<String, String> variablesMap)
PreparedStatement<?> prepare(
ParsedStatement stmt) // (1)!
- Uses an empty
Map
Used when:
KsqlContext
is requested to executeKsqlRestApplication
is requested to registerCommandTopicQueryEndpoint
is requested tocreateStatement
RequestHandler
is requested to executeRequestValidator
is requested to validateSqlFormatInjector
is requested toinject
StandaloneExecutor.StatementExecutor
is requested to prepare a statementStatementParser
is requested toparseSingleStatement
updateStreamsPropertiesAndRestartRuntime¶
void updateStreamsPropertiesAndRestartRuntime()
Used when:
InteractiveStatementExecutor
is requested to execute an ALTER SYSTEM command