-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathpg_lake_iceberg--3.2--3.3.sql
More file actions
76 lines (70 loc) · 2.92 KB
/
pg_lake_iceberg--3.2--3.3.sql
File metadata and controls
76 lines (70 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-- Upgrade script for pg_lake_iceberg from 3.2 to 3.3
-- Set REPLICA IDENTITY FULL for catalog tables without primary keys
-- This is required for logical replication when using 'FOR ALL TABLES' publications
ALTER TABLE lake_iceberg.namespace_properties REPLICA IDENTITY FULL;
ALTER TABLE lake_iceberg.tables_internal REPLICA IDENTITY FULL;
ALTER TABLE lake_iceberg.tables_external REPLICA IDENTITY FULL;
GRANT SELECT ON lake_iceberg.tables TO public;
GRANT SELECT ON lake_iceberg.tables_internal TO public;
GRANT SELECT ON lake_iceberg.tables_external TO public;
CREATE OR REPLACE VIEW pg_catalog.iceberg_tables AS
SELECT catalog_name, table_namespace, table_name, metadata_location, previous_metadata_location
FROM lake_iceberg.tables
WHERE metadata_location IS NOT NULL;
/*
* iceberg_catalog foreign data wrapper: allows defining named catalog
* configurations via CREATE SERVER so that users are not limited to a
* single global catalog configured through GUC settings.
*
* Supported server types:
* TYPE 'rest' -- REST catalog (e.g. Polaris, Gravitino)
* TYPE 'object_store' -- Object store catalog (catalog.json in S3)
*
* Server options (all optional):
* rest_endpoint, rest_auth_type, oauth_endpoint, scope,
* enable_vended_credentials, location_prefix, catalog_name,
* read_only (boolean).
*
* User mapping options (credentials, TYPE 'rest' only):
* client_id, client_secret, scope.
*
* scope is accepted in both server and user mapping; user mapping wins.
* read_only on a server propagates to all tables unless overridden.
*
* Credential resolution order (TYPE 'rest'):
* 1. CREATE USER MAPPING for the current user
* 2. $PGDATA/catalogs.conf (platform-provided)
* 3. GUC variables (backward compatibility)
*
* REST catalog example:
* CREATE SERVER my_polaris TYPE 'rest'
* FOREIGN DATA WRAPPER iceberg_catalog
* OPTIONS (rest_endpoint 'https://polaris.example.com');
*
* CREATE USER MAPPING FOR user1 SERVER my_polaris
* OPTIONS (client_id '...', client_secret '...');
*
* CREATE TABLE t (a int) USING iceberg WITH (catalog = 'my_polaris');
*
* Object store catalog example (shared writer/reader):
* -- Writer instance:
* CREATE SERVER shared_catalog TYPE 'object_store'
* FOREIGN DATA WRAPPER iceberg_catalog
* OPTIONS (location_prefix 's3://bucket/shared');
*
* CREATE TABLE t (a int) USING iceberg
* WITH (catalog = 'shared_catalog');
*
* -- Reader instance (same S3 path, read-only):
* CREATE SERVER shared_catalog TYPE 'object_store'
* FOREIGN DATA WRAPPER iceberg_catalog
* OPTIONS (location_prefix 's3://bucket/shared', read_only 'true');
*/
CREATE FUNCTION lake_iceberg.iceberg_catalog_validator(text[], oid)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FOREIGN DATA WRAPPER iceberg_catalog
NO HANDLER
VALIDATOR lake_iceberg.iceberg_catalog_validator;
GRANT USAGE ON FOREIGN DATA WRAPPER iceberg_catalog TO lake_write;