Format Table#
Table#
-
class FormatTable#
A table that is a directory of data files of one format, laid out like a standard Hive table.
It carries no snapshots and no manifests: the files under its location are the table, and a partitioned table’s partitions are the
key=valuedirectories below that location, or the bare-value ones underformat-table.partition-path-only-value. A table is a format table when itstypeoption isformat-table;file.formatthen names the format of every file in it, defaulting toparquet.Writes only insert - there is nowhere to record an update or a delete - so a read fills
_VALUE_KINDwith inserts throughout.Reading and writing go through the entry points every other table uses:
TableScan,TableRead,FileStoreWriteandFileStoreCommit. Each recognises a format table from the schema under the table path, or takes one already loaded through theFormatTableconstructor every context builder has, which is how a table whose schema lives in a metastore is reached.See
docs/source/user_guide/format_table.rstfor what is not supported yet.Public Types
Public Functions
-
~FormatTable()#
-
inline const std::string &Location() const#
Directory the data files live in.
-
const std::vector<std::string> &PartitionKeys() const#
Fields the table is partitioned by, in the order their directories nest.
-
inline const std::string &FileCompression() const#
Compression new data files are written with.
It is resolved from
file.compression, thenformat-table.file.compression, then the barecompressionkey an engine’s own writer reads, then what the table’s format writes by default.
-
inline const std::string &PartitionDefaultName() const#
Directory name standing for a null partition value, from
partition.default-name.
-
inline bool PartitionOnlyValueInPath() const#
Whether a partition directory is named by its value alone (
2025/01/) instead ofkey=value(year=2025/month=01/), fromformat-table.partition-path-only-value.The value-only layout carries no field names, so the nesting order of the table’s partition keys alone says which key a directory belongs to.
-
inline const std::map<std::string, std::string> &Options() const#
Table options: the ones stored in the schema, with any given at the call on top.
-
inline std::string Name() const#
A name to identify this table.
-
std::string FullName() const#
Full name of the table, database.tableName.
-
inline std::shared_ptr<DataSchema> LatestSchema() const#
Schema of the table, including its partition fields.
-
Result<std::unique_ptr<::ArrowSchema>> GetArrowSchema() const#
Schema of the table as an arrow schema, including its partition fields.
-
inline std::shared_ptr<FileSystem> GetFileSystem() const#
File system holding the table directory.
-
inline bool LocationCarriesPaimonMetadata() const#
Whether this table’s own metadata lives under its location, as told by whoever loaded it.
Only then are the
schemaandbranchdirectories below the location table metadata rather than table content. For a table whose schema lives in a metastore they are data, and are read and written like any other directory.
Public Static Functions
-
static Result<Format> ParseFormat(const std::string &file_format)#
Parses the
file.formatoption, case-insensitively.A format this library has no reader for is rejected by name, instead of failing later with a missing-format-factory error.
-
static std::string FormatToString(Format format)#
The identifier of a format, as it appears in
file.formatand as a file extension.
Loads a format table from its directory, reading the schema stored under it.
This needs a schema file under the table directory, which a table created through
SchemaManageror a file system catalog has. A table whose schema lives in a metastore has none, and is loaded throughCatalog::GetFormatTable()instead.- Parameters:
file_system – File system holding the table directory.
table_path – Root path of the table, which is also its data location.
identifier – Logical table identifier, used for naming and error messages.
dynamic_options – Options given at the call, which win over the ones stored in the schema. Empty when the caller has none.
- Returns:
A result containing the format table, or an error status.
Builds a format table from a schema that is already loaded, for a caller that has one in hand, such as a catalog that just created the table.
- Parameters:
location – Directory the data files live in. It may not be empty: every path this table reads or writes is checked against it, and an empty one is a prefix of nothing. A trailing separator names the same directory as none.
location_carries_paimon_metadata – See
LocationCarriesPaimonMetadata(). Only the caller knows: a file system catalog puts metadata there, a REST or Hive catalog keeps it in the metastore.dynamic_options – Options given at the call, which win over the ones stored in the schema. Empty when the caller has none.
- Returns:
A result containing the format table, or an error status.
Copies
tablewithdynamic_optionson top of the options it already carries, which is the precedence every context builder promises for a table it was handed rather than loaded itself.tablecomes back as it is when there is nothing to add.typeis not overridable: it is structural and is read from the schema alone.- Parameters:
table – The table to copy.
dynamic_options – Options given at the call.
- Returns:
A result containing the copied table, or an error status.
-
~FormatTable()#
Reading and writing a format table go through the generic entry points every other table uses:
paimon::TableScan, paimon::TableRead, paimon::FileStoreWrite
and paimon::FileStoreCommit. See Format Table.
Contexts#
Each of those entry points builds its context from a table path, and the schema under that path
says what kind of table it is. A caller that already holds a FormatTable hands it over instead,
through the constructor each context builder has for one:
paimon::ScanContextBuilder(const std::shared_ptr<FormatTable>&)paimon::ReadContextBuilder(const std::shared_ptr<FormatTable>&)paimon::WriteContextBuilder(const std::shared_ptr<FormatTable>&)paimon::CommitContextBuilder(const std::shared_ptr<FormatTable>&)
This is the only way to reach a format table whose schema does not live under its own location,
such as one a REST catalog serves: nothing under the location says that it is a format table, nor
that what sits below it is data rather than metadata. The table knows both, so a setting that would
answer either question again - SetTableSchema(), WithFileSystem() and a branch among them -
is refused by these builders rather than quietly ignored. Options given at the call still win over
the ones the table carries, as they do everywhere else.