Class FactoryUtil.DefaultDynamicTableContext
- java.lang.Object
-
- org.apache.flink.table.factories.FactoryUtil.DefaultDynamicTableContext
-
- All Implemented Interfaces:
DynamicTableFactory.Context
- Enclosing class:
- FactoryUtil
@Internal public static class FactoryUtil.DefaultDynamicTableContext extends Object implements DynamicTableFactory.Context
Default implementation ofDynamicTableFactory.Context.
-
-
Constructor Summary
Constructors Constructor Description DefaultDynamicTableContext(ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String,String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResolvedCatalogTablegetCatalogTable()Returns the resolved table information received from theCatalogor persisted plan.ClassLoadergetClassLoader()Returns the class loader of the current session.org.apache.flink.configuration.ReadableConfiggetConfiguration()Gives read-only access to the configuration of the current session.Map<String,String>getEnrichmentOptions()Returns a map of options that can enrich the options of the originalDynamicTableFactory.Context.getCatalogTable()during a plan restore.ObjectIdentifiergetObjectIdentifier()Returns the identifier of the table in theCatalog.booleanisTemporary()Whether the table is temporary.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.table.factories.DynamicTableFactory.Context
getPhysicalRowDataType, getPrimaryKeyIndexes
-
-
-
-
Constructor Detail
-
DefaultDynamicTableContext
public DefaultDynamicTableContext(ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String,String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary)
-
-
Method Detail
-
getObjectIdentifier
public ObjectIdentifier getObjectIdentifier()
Description copied from interface:DynamicTableFactory.ContextReturns the identifier of the table in theCatalog.This identifier describes the relationship between the table instance and the associated
Catalog(if any). However, it doesn't uniquely identify this specific table configuration. The same table might be stored in different catalogs or, in case of anonymous tables, this identifier is auto-generated and non-deterministic. Because of that behaviour, we strongly suggest using this identifier only for printing and logging purposes, and rely on user input for uniquely identifying a "table instance".For example, when implementing a Kafka source using consumer groups, the user should provide the consumer group id manually rather than using this identifier as the consumer group id, so the offset tracking remains stable even if this table is anonymous, or it's moved to another
Catalog.Note that for anonymous tables
ObjectIdentifier.asSerializableString()will fail, so we suggest to useObjectIdentifier.asSummaryString()for generating strings.- Specified by:
getObjectIdentifierin interfaceDynamicTableFactory.Context
-
getCatalogTable
public ResolvedCatalogTable getCatalogTable()
Description copied from interface:DynamicTableFactory.ContextReturns the resolved table information received from theCatalogor persisted plan.The
ResolvedCatalogTableforwards the metadata from the catalog but offers a validatedResolvedSchema. The original metadata object is available viaResolvedCatalogTable.getOrigin().In most cases, a factory is interested in the following characteristics:
// get the physical data type to initialize the connector context.getCatalogTable().getResolvedSchema().toPhysicalRowDataType() // get primary key information if the connector supports upserts context.getCatalogTable().getResolvedSchema().getPrimaryKey() // get configuration options context.getCatalogTable().getOptions()Other characteristics such as metadata columns or watermarks will be pushed down into the created
DynamicTableSourceorDynamicTableSinkduring planning depending on the implemented ability interfaces.During a plan restore, usually the table information persisted in the plan is used to reconstruct the catalog table. If and only if
table.plan.restore.catalog-objectsis set toALL, there might be information from both the plan and a catalog lookup which requires consideringDynamicTableFactory.Context.getEnrichmentOptions(). It enables to enrich the plan information with frequently changing options (e.g. connection information or timeouts).- Specified by:
getCatalogTablein interfaceDynamicTableFactory.Context
-
getEnrichmentOptions
public Map<String,String> getEnrichmentOptions()
Description copied from interface:DynamicTableFactory.ContextReturns a map of options that can enrich the options of the originalDynamicTableFactory.Context.getCatalogTable()during a plan restore.If and only if
table.plan.restore.catalog-objectsis set toALL, this method may return a non-emptyMapof options retrieved from theCatalog.Because only the
DynamicTableFactoryis able to decide which options are safe to be forwarded without affecting the original topology, enrichment options are exposed through this method. In general, it's highly recommended using theFactoryUtil.createTableFactoryHelper(DynamicTableFactory, Context)to merge the options and then get the result withFactoryUtil.TableFactoryHelper.getOptions(). The helper considers bothDynamicTableFactory.forwardOptions()andFormatFactory.forwardOptions().Since a restored topology is static, an implementer has to ensure that the declared options don't affect fundamental abilities. The planner might not react to changed abilities anymore.
- Specified by:
getEnrichmentOptionsin interfaceDynamicTableFactory.Context- See Also:
FactoryUtil.TableFactoryHelper
-
getConfiguration
public org.apache.flink.configuration.ReadableConfig getConfiguration()
Description copied from interface:DynamicTableFactory.ContextGives read-only access to the configuration of the current session.- Specified by:
getConfigurationin interfaceDynamicTableFactory.Context
-
getClassLoader
public ClassLoader getClassLoader()
Description copied from interface:DynamicTableFactory.ContextReturns the class loader of the current session.The class loader is in particular useful for discovering further (nested) factories.
- Specified by:
getClassLoaderin interfaceDynamicTableFactory.Context
-
isTemporary
public boolean isTemporary()
Description copied from interface:DynamicTableFactory.ContextWhether the table is temporary.- Specified by:
isTemporaryin interfaceDynamicTableFactory.Context
-
-