Package org.apache.drill.exec.store
Class AbstractSchema
java.lang.Object
org.apache.drill.exec.store.AbstractSchema
- All Implemented Interfaces:
AutoCloseable,org.apache.calcite.schema.Schema,SchemaPartitionExplorer
- Direct Known Subclasses:
CapitalizingJdbcSchema,CassandraDrillSchema,CassandraRootDrillSchema,ClickhouseCatalogSchema,DrillPluginSchema,DruidSchemaFactory.DruidDataSources,DynamicRootSchema.RootSchema,ElasticsearchDrillSchema,FileSystemSchemaFactory.FileSystemSchema,GoogleSheetsDrillSchema,GoogleSheetsRootSchema,HiveDatabaseSchema,HttpAPIConnectionSchema,HttpSchemaFactory.HttpSchema,KafkaMessageSchema,MongoDatabaseSchema,SplunkSchema,SubSchemaWrapper,WorkspaceSchemaFactory.WorkspaceSchema
public abstract class AbstractSchema
extends Object
implements org.apache.calcite.schema.Schema, SchemaPartitionExplorer, AutoCloseable
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
org.apache.calcite.schema.Schema.TableType -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendToStatsTable(String tableName) Create an append statistics table entry for given tableName.applyFunctionParameters(DrillTable drillTable, List<TableParamDef> paramDefs, List<Object> values) For the given list of parameters definitions executes action for the corresponding value.booleanIndicates if table names in schema are case sensitive.voidclose()createNewTable(String tableName, List<String> partitionColumns) Creates table entry using table name and list of partition columns if any.createNewTable(String tableName, List<String> partitionColumns, StorageStrategy storageStrategy) Creates table entry using table name, list of partition columns and storage strategy used to create table folder and filescreateStatsTable(String tableName) Create stats table entry for given tableName.booleancreateView(View view) Create a new view given definition.voidvoidDrop the view with given name.org.apache.calcite.schema.SchemaThe schema can be a top level schema which doesn't have its own tables, but refers to one of the default sub schemas for table look up.org.apache.calcite.linq4j.tree.ExpressiongetExpression(org.apache.calcite.schema.SchemaPlus parentSchema, String name) Returns of common table function parameters that can be used all Drill schema implementations.Collection<org.apache.calcite.schema.Function> getFunctions(String name) For the given table names returns list of acceptable table functions which are common for all Drill schemas.getName()org.apache.calcite.schema.TablegetStatsTable(String tableName) Get the statistics table for given tableNameGet a list of sub-partitions of a particular table and the partitions specified by partition columns and values.org.apache.calcite.schema.SchemagetSubSchema(String name) org.apache.calcite.schema.TableCollection<Map.Entry<String, org.apache.calcite.schema.Schema.TableType>> Used byInfoSchemaRecordGenerator.Tablesfor getting all table objects along with type for every requested schema.getTablesByNames(Set<String> tableNames) Get the collection ofTabletables specified in the tableNames.org.apache.calcite.rel.type.RelProtoDataTypeReturns a map of types in this schema by name.abstract StringReturns string describing schema type which shows where the schema came from.booleanmodifyTable(String tableName) Returns table entry using table name to insert records into the table.booleanDoes Drill needs to impersonate as user connected to Drill when reading data from DataSource?booleanReports whether to show items from this schema in INFORMATION_SCHEMA tables.org.apache.calcite.schema.Schemasnapshot(org.apache.calcite.schema.SchemaVersion version) final StringtoString()
-
Field Details
-
SCHEMA_SEPARATOR
- See Also:
-
schemaPath
-
name
-
-
Constructor Details
-
AbstractSchema
-
-
Method Details
-
getSubPartitions
public Iterable<String> getSubPartitions(String table, List<String> partitionColumns, List<String> partitionValues) throws PartitionNotFoundException Description copied from interface:SchemaPartitionExplorerGet a list of sub-partitions of a particular table and the partitions specified by partition columns and values. Individual storage plugins will assign specific meaning to the parameters and return values.For more info see docs in
PartitionExplorer.- Specified by:
getSubPartitionsin interfaceSchemaPartitionExplorer- Parameters:
partitionColumns- a list of partitions to matchpartitionValues- list of values of each partition (corresponding to the partition column list)- Returns:
- list of sub-partitions, will be empty if a there is no further level of sub-partitioning below, i.e. hit a leaf partition
- Throws:
PartitionNotFoundException- when the partition does not exist in the given workspace
-
getName
-
getSchemaPath
-
getFullSchemaName
-
toString
-
getTypeName
Returns string describing schema type which shows where the schema came from. Good practice here is to return json type name of storage plugin's config.- Returns:
- schema type name
-
getDefaultSchema
public org.apache.calcite.schema.Schema getDefaultSchema()The schema can be a top level schema which doesn't have its own tables, but refers to one of the default sub schemas for table look up.Default implementation returns itself.
Ex. "dfs" schema refers to the tables in "default" workspace when querying for tables in "dfs" schema.
- Returns:
- Return the default schema where tables are created or retrieved from.
-
createView
Create a new view given definition.- Parameters:
view- View info including name, definition etc.- Returns:
- Returns true if an existing view is replaced with the given view. False otherwise.
- Throws:
IOException- in case of error creating a view
-
dropView
Drop the view with given name.- Parameters:
viewName- view name- Throws:
IOException- in case of error dropping the view
-
createNewTable
public CreateTableEntry createNewTable(String tableName, List<String> partitionColumns, StorageStrategy storageStrategy) Creates table entry using table name, list of partition columns and storage strategy used to create table folder and files- Parameters:
tableName- : new table name.partitionColumns- : list of partition columns. Empty list if there is no partition columns.storageStrategy- : storage strategy used to create table folder and files- Returns:
- create table entry
-
modifyTable
Returns table entry using table name to insert records into the table.- Parameters:
tableName- : new table name.- Returns:
- insert table entry
-
createNewTable
Creates table entry using table name and list of partition columns if any. Table folder and files will be created using persistent storage strategy.- Parameters:
tableName- : new table name.partitionColumns- : list of partition columns. Empty list if there is no partition columns.- Returns:
- create table entry
-
createStatsTable
Create stats table entry for given tableName.- Parameters:
tableName- table name- Returns:
- instance of create table entry
-
appendToStatsTable
Create an append statistics table entry for given tableName. If there is not existing statistics table, a new one is created.- Parameters:
tableName- table name- Returns:
- instance of create table entry
-
getStatsTable
Get the statistics table for given tableName- Parameters:
tableName- table name- Returns:
- instance of statistics table
-
showInInformationSchema
public boolean showInInformationSchema()Reports whether to show items from this schema in INFORMATION_SCHEMA tables. (Controls ... TODO: Doc.: Mention what this typically controls or affects.)This base implementation returns
true. -
getFunctions
For the given table names returns list of acceptable table functions which are common for all Drill schemas. When overriding this method, parent functions must be included first to be evaluated first. If not included, parent functions won't be taken into account when creating table instance.- Specified by:
getFunctionsin interfaceorg.apache.calcite.schema.Schema- Parameters:
name- table name- Returns:
- list of table functions
-
getFunctionParameters
Returns of common table function parameters that can be used all Drill schema implementations.- Returns:
- list of table function parameters
-
applyFunctionParameters
public DrillTable applyFunctionParameters(DrillTable drillTable, List<TableParamDef> paramDefs, List<Object> values) For the given list of parameters definitions executes action for the corresponding value.- Parameters:
drillTable- Drill table instanceparamDefs- parameter definitionsvalues- parameter values- Returns:
- updated Drill table instance
-
getTypeMap
Returns a map of types in this schema by name.The implementations of
getTypeNames()andgetType(String)depend on this map. The default implementation of this method returns the empty map. Override this method to change their behavior.- Returns:
- Map of types in this schema by name
-
getTypeNames
- Specified by:
getTypeNamesin interfaceorg.apache.calcite.schema.Schema
-
getType
- Specified by:
getTypein interfaceorg.apache.calcite.schema.Schema
-
getFunctionNames
- Specified by:
getFunctionNamesin interfaceorg.apache.calcite.schema.Schema
-
getSubSchema
- Specified by:
getSubSchemain interfaceorg.apache.calcite.schema.Schema
-
getSubSchemaNames
- Specified by:
getSubSchemaNamesin interfaceorg.apache.calcite.schema.Schema
-
isMutable
public boolean isMutable()- Specified by:
isMutablein interfaceorg.apache.calcite.schema.Schema
-
getTable
- Specified by:
getTablein interfaceorg.apache.calcite.schema.Schema
-
getTableNames
- Specified by:
getTableNamesin interfaceorg.apache.calcite.schema.Schema
-
getExpression
public org.apache.calcite.linq4j.tree.Expression getExpression(org.apache.calcite.schema.SchemaPlus parentSchema, String name) - Specified by:
getExpressionin interfaceorg.apache.calcite.schema.Schema
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
snapshot
public org.apache.calcite.schema.Schema snapshot(org.apache.calcite.schema.SchemaVersion version) - Specified by:
snapshotin interfaceorg.apache.calcite.schema.Schema
-
dropTable
-
getTablesByNames
public List<org.apache.commons.lang3.tuple.Pair<String,? extends org.apache.calcite.schema.Table>> getTablesByNames(Set<String> tableNames) Get the collection ofTabletables specified in the tableNames.- Parameters:
tableNames- the requested tables, specified by the table names- Returns:
- the collection of requested tables
-
getTableNamesAndTypes
public Collection<Map.Entry<String,org.apache.calcite.schema.Schema.TableType>> getTableNamesAndTypes()Used byInfoSchemaRecordGenerator.Tablesfor getting all table objects along with type for every requested schema. It's desired for this method to work fast because it impacts SHOW TABLES query.- Returns:
- collection of table names and types
-
areTableNamesCaseSensitive
public boolean areTableNamesCaseSensitive()Indicates if table names in schema are case sensitive. By default they are. If schema implementation claims its table names are case insensitive, it is responsible for making case insensitive look up by table name.- Returns:
- true if table names are case sensitive
-
getUser
- Parameters:
impersonated- User whom to impersonate. UsuallySchemaConfig.getUserName()notImpersonated- Regular user (table owner for Views or Drillbit process user for Tables)- Returns:
- endUser
-
needToImpersonateReadingData
public boolean needToImpersonateReadingData()Does Drill needs to impersonate as user connected to Drill when reading data from DataSource?- Returns:
- True when both Drill impersonation and DataSource impersonation are enabled.
-