schema
Syntax
schema(table|dbHandle)
Arguments
table | dbHandle can be a table object or a database handle.
Details
Display information about the schema of a table or a database. The function returns an unordered dictionary containing the following information (in alphabetical order):
- atomic: the level at which the atomicity is guaranteed for a write transaction. It can be TRANS or CHUNK.
- chunkGranularity: the chunk granularity which determines whether to allow concurrent writes to different tables in the same chunk. It can be TABLE or DATABASE.
- clusterReplicationEnabled: whether asynchronous replication has been enabled.
- colDefs: information about each column in the table:
- name: column name
- typeString: column type
- typeInt: the type ID
- comment: comment on the column
- compressMethods: the compression methods used for specified columns of a DFS
table.
- name: Column names
- compressMethods: Compression algorithm applied, including "lz4", "delta", or "zstd".
- databaseDir: the directory where the database is stored.
- databaseOwner: the database creator.
- partitionColumnIndex: the index that indicates the positions of partitioning columns. It returns -1 for a dimension table.
- partitionColumnName: the partitioning column names.
- partitionColumnType: the data type ID (which can be checked at Data Types and Data Forms) of the partitioning column.
- partitionSchema: how the partitions are organized
- partitionSites (optional): If the parameter locations is specified for function
database
, it displays the ip:port information of the specified node. - partitionTypeName / partitionType: the partitioning scheme and the corresponding ID, including VALUE(1), RANGE(2), LIST(3), COMPO(4), HASH(5).
- tableComment: the comment for DFS tables.
- tableOwner: the table creator.
Examples
OLAP database:
n=1000000
ID=rand(10, n)
x=rand(1.0, n)
t=table(ID, x)
db=database("dfs://rangedb101", RANGE, 0 5 10)
pt = db.createPartitionedTable(t, `pt, `ID)
pt.append!(t)
pt=loadTable(db,`pt);
schema(db);
// output
databaseDir->dfs://rangedb101
partitionSchema->[0,5,10]
partitionSites->
atomic->TRANS
chunkGranularity->TABLE
partitionType->2
partitionTypeName->RANGE
partitionColumnType->4
clusterReplicationEnabled->1
databaseOwner->admin
OLAP table:
schema(pt);
// output
chunkGranularity->TABLE
tableOwner->admin
compressMethods->
name compressMethods
---- ---------------
ID lz4
x lz4
colDefs->
name typeString typeInt comment
---- ---------- ------- -------
ID INT 4
x DOUBLE 16
chunkPath->
partitionColumnIndex->0
partitionColumnName->ID
partitionColumnType->4
partitionType->2
partitionTypeName->RANGE
partitionSchema->[0,5,10]
partitionSites->