Package org.apache.calcite.adapter.csv
Class CsvSchema
- java.lang.Object
-
- org.apache.calcite.schema.impl.AbstractSchema
-
- org.apache.calcite.adapter.csv.CsvSchema
-
- All Implemented Interfaces:
Schema
public class CsvSchema extends AbstractSchema
Schema mapped onto a directory of CSV files. Each table in the schema is a CSV file in that directory.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.calcite.schema.impl.AbstractSchema
AbstractSchema.Factory
-
Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
Schema.TableType
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
directoryFile
private CsvTable.Flavor
flavor
private java.util.Map<java.lang.String,Table>
tableMap
-
Constructor Summary
Constructors Constructor Description CsvSchema(java.io.File directoryFile, CsvTable.Flavor flavor)
Creates a CSV schema.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Table
createTable(Source source)
Creates different sub-type of table based on the "flavor" attribute.private java.util.Map<java.lang.String,Table>
createTableMap()
protected java.util.Map<java.lang.String,Table>
getTableMap()
Returns a map of tables in this schema by name.private static java.lang.String
trim(java.lang.String s, java.lang.String suffix)
Looks for a suffix on a string and returns either the string with the suffix removed or the original string.private static java.lang.String
trimOrNull(java.lang.String s, java.lang.String suffix)
Looks for a suffix on a string and returns either the string with the suffix removed or null.-
Methods inherited from class org.apache.calcite.schema.impl.AbstractSchema
getExpression, getFunctionMultimap, getFunctionNames, getFunctions, getSubSchema, getSubSchemaMap, getSubSchemaNames, getTable, getTableNames, getType, getTypeMap, getTypeNames, isMutable, snapshot
-
-
-
-
Field Detail
-
directoryFile
private final java.io.File directoryFile
-
flavor
private final CsvTable.Flavor flavor
-
tableMap
private java.util.Map<java.lang.String,Table> tableMap
-
-
Constructor Detail
-
CsvSchema
public CsvSchema(java.io.File directoryFile, CsvTable.Flavor flavor)
Creates a CSV schema.- Parameters:
directoryFile
- Directory that holds.csv
filesflavor
- Whether to instantiate flavor tables that undergo query optimization
-
-
Method Detail
-
trim
private static java.lang.String trim(java.lang.String s, java.lang.String suffix)
Looks for a suffix on a string and returns either the string with the suffix removed or the original string.
-
trimOrNull
private static java.lang.String trimOrNull(java.lang.String s, java.lang.String suffix)
Looks for a suffix on a string and returns either the string with the suffix removed or null.
-
getTableMap
protected java.util.Map<java.lang.String,Table> getTableMap()
Description copied from class:AbstractSchema
Returns a map of tables in this schema by name.The implementations of
AbstractSchema.getTableNames()
andAbstractSchema.getTable(String)
depend on this map. The default implementation of this method returns the empty map. Override this method to change their behavior.- Overrides:
getTableMap
in classAbstractSchema
- Returns:
- Map of tables in this schema by name
-
createTableMap
private java.util.Map<java.lang.String,Table> createTableMap()
-
-