Skip to main content

Hologres catalog

The Hologres catalog connects Gravitino to an Alibaba Cloud Hologres instance over the PostgreSQL protocol, exposing the schemas of one Hologres database as schemas and their tables as tables. Schemas and tables are both read-write. The database is named in the catalog properties, so reaching a second database means creating a second catalog.

The catalog uses the PostgreSQL JDBC driver, which ships in the image, so there is no driver to supply.

Gravitino records its own identifier in the comment of each schema and table it creates, as text of the form (From Gravitino, DO NOT EDIT: gravitino.v1.uid{id}), and uses it to recognize the object on later loads. Leave that text in place when you edit a comment in Hologres directly.

Quick start​

The example connects the Hologres database {database} as the catalog hologres_sales and lists its schemas.

  1. Start the catalog. Open Connect → Catalogs and click + Catalog. Enter hologres_sales as the Catalog name, keep Relational as the Catalog type, and choose Hologres under Databases and warehouses in Select provider.

  2. Enter the connection. Under Connection, enter jdbc:postgresql://{hologres_endpoint}:80/{database} as the URL and the same database name as the Database. Enter the AccessKey ID or database user as the User and its AccessKey Secret or password as the Password. Advanced holds Cloud / region and a Properties list for any other catalog property. The UI fills in jdbc-driver itself.

  3. Test and create it. Click Test connection, then Create catalog.

  4. List the schemas. In Explore, open hologres_sales. The schemas listed are read from the database, with the system schemas filtered out.

Catalog properties​

The Hologres catalog defines no catalog properties of its own; it takes the connection, pool, and driver properties every JDBC catalog shares, listed in Shared properties.

jdbc-database is required here, although it is optional in the shared set, and catalog creation fails without it. Set it to the database named in jdbc-url. jdbc-driver is org.postgresql.Driver, and jdbc-user and jdbc-password take either an Alibaba Cloud AccessKey pair or a database user and password.

Schemas​

A schema in this catalog is a Hologres schema in the database named by jdbc-database. Create, list, load, and drop are supported; alter is not.

Creation issues CREATE SCHEMA followed by COMMENT ON SCHEMA when a comment is given. Schema properties are rejected. The names pg_catalog, information_schema, and hologres are reserved, in any case, and cannot be used for a new schema.

Listing filters out the PostgreSQL system schemas pg_toast, pg_catalog, and information_schema, and the Hologres internal schemas hologres, hg_internal, hg_recyclebin, hologres_object_table, hologres_sample, hologres_streaming_mv, and hologres_statistic.

A cascading drop issues DROP SCHEMA ... CASCADE, which drops every table in the schema. Without cascade, dropping a schema that still holds objects fails with the Hologres error.

Tables​

Table create, load, list, rename, alter, and drop are supported. Purge is not, and a purge request is rejected rather than being treated as a drop.

Listing returns ordinary tables, partitioned parent tables, and partition child tables. Views and foreign tables are not listed.

Table and column comments are written with COMMENT ON TABLE and COMMENT ON COLUMN after the CREATE TABLE statement.

Properties​

Hologres table properties are written to the WITH clause of CREATE TABLE. A property key must be a plain identifier, matching [a-zA-Z_][a-zA-Z0-9_]*, and its value is written as a quoted string. Three keys are not written to WITH: distribution_key and primary_key, which come from the table's distribution and indexes, and is_logical_partitioned_table, which selects logical partitioning as described in Partitioning and distribution.

A load reads properties from hologres.hg_table_properties and returns only these keys, when they have a value:

PropertyDescription
orientationStorage orientation, such as column, row, or row,column
clustering_keyClustering key columns
segment_keyEvent time column
bitmap_columnsBitmap index columns
dictionary_encoding_columnsDictionary encoding columns
time_to_live_in_secondsData time to live
table_groupTable group name
storage_formatInternal storage format
binlog_levelBinlog level
binlog_ttlBinlog time to live
is_logical_partitioned_tableWhether the table is a logical partitioned table
partition_expiration_timeLogical partition expiration
partition_keep_hot_windowLogical partition hot window
partition_require_filterWhether queries must filter on the partition key
partition_generate_binlog_windowLogical partition binlog window

Hologres stores the binlog properties as binlog.level and binlog.ttl; Gravitino returns them as binlog_level and binlog_ttl, the names CREATE TABLE accepts.

Table properties cannot be set or removed after creation.

Indexes​

PRIMARY_KEY is the only supported index type, and only at table creation. It can cover several columns, each a top-level column. Any other index type is rejected, and adding or deleting an index through an alter is rejected.

Define a primary key
{
"indexes": [
{"indexType": "PRIMARY_KEY", "name": "pk_id", "fieldNames": [["id"]]}
]
}

Partitioning and distribution​

A table takes at most one partitioning transform, and it must be list.

Table kindHow it is chosenClauseColumns
Physical partitionDefaultPARTITION BY LIST({column})Exactly 1
Logical partitionTable property is_logical_partitioned_table set to trueLOGICAL PARTITION BY LIST({columns})1 or 2

A load reads logical partitioning from hologres.hg_table_properties and physical partitioning from pg_partitioned_table. Partition child tables are not created through Gravitino.

Set list partitioning
{
"partitioning": [
{"strategy": "list", "fieldNames": [["ds"]]}
]
}

The distribution is optional and must be hash with at least one column, each a plain column reference. It is written as the distribution_key table property. The bucket number is not used, and a load returns the distribution with a bucket number of 0.

Set hash distribution
{
"distribution": {
"strategy": "hash",
"number": 0,
"funcArgs": [{"type": "field", "fieldName": ["id"]}]
}
}

Sort orders are not supported.

Auto increment​

Auto-increment columns are not supported, and a create or alter that sets one is rejected.

Supported changes​

ChangeSupported
Rename tableYes, alone in its request
Update table commentYes
Add columnYes, nullable, without a default, at the default position, with a comment
Delete columnYes
Rename columnYes
Update column commentYes
Update column typeNo
Update column positionNo
Update column nullableNo
Update column defaultNo
Update column auto incrementNo
Add or delete indexNo
Set or remove propertyNo

Deleting a column first issues SET hg_experimental_enable_drop_column = on, which Hologres requires before DROP COLUMN. Nested column names are rejected by every column change.

Identifier case and quoting​

Names are case-sensitive in Gravitino and are passed to Hologres exactly as given, never folded. Schema, table, and column names must match ^[_a-zA-Z\p{L}/][\w\p{L}-$/=]{0,62}$: 1 to 63 characters, starting with a letter in any script, an underscore, or /, and continuing with letters, digits, underscore, -, $, /, and =.

Gravitino quotes identifiers with double quotes in generated SQL, which keeps their case in Hologres, and doubles any " inside a table or column name. Names returned by a list operation come back exactly as Hologres stores them.

Type mapping​

Gravitino reads each Hologres type as the Gravitino type in its row, and creates each Gravitino type as the Hologres type in its row, except where the list under the table says otherwise.

Hologres typeGravitino type
boolBoolean
int2Short
int4Integer
int8Long
float4Float
float8Double
numeric(p,s)Decimal(p, s)
dateDate
time(p)Time, precision p
timestamp(p)Timestamp without time zone, precision p
timestamptz(p)Timestamp with time zone, precision p
varchar(n)Varchar(n)
varchar with no length, textString
bpchar(n)Char(n)
byteaBinary
An array of a type, such as int4[]List of that type, with non-nullable elements
Any other typeExternal type carrying the Hologres type name

Types such as json, jsonb, uuid, inet, money, and roaringbitmap come back as external types.

When Gravitino creates a column:

  • Time without a precision becomes time.
  • Both timestamp types become timestamp and timestamptz with no precision, because Hologres does not accept one.
  • String becomes text.
  • A list must have non-nullable elements and one dimension; a nullable element type or a list of lists is rejected.
  • An external type becomes the Hologres type it carries.
  • Any other Gravitino type is rejected, including Byte, Fixed, UUID, the interval types, and map, struct, and union types.

Column default values​

On load, a literal default written with a cast, such as '2021-10-01 00:00:00'::timestamp, has the cast removed, and NULL::{type} is read as null. Literals on boolean, integer, float, numeric, date, time, timestamp, varchar, bpchar, and text columns are parsed into typed literals. A default that fails to parse is read as the current timestamp when it is CURRENT_TIMESTAMP and as an unparsed expression otherwise, and an expression default is preserved as an unparsed expression.

On create, an unparsed expression is written exactly as given. A function default is written inside parentheses, except CURRENT_TIMESTAMP.

Error mapping​

Hologres reports PostgreSQL SQLSTATE codes, which Gravitino translates into Gravitino exceptions so a caller sees the same failure types it would from any other catalog.

SQLSTATEGravitino exception
42P04 duplicate database, 42P06 duplicate schemaSchema already exists
42P07 duplicate tableTable already exists
3D000 invalid catalog name, 3F000 invalid schema nameNo such schema
42P01 undefined tableNo such table
Any code in class 08, connection exceptionConnection failed
No SQLSTATE, with "password authentication failed" in the messageConnection failed

Any other error produces a generic runtime exception carrying the Hologres message.