更新时间:2026-07-14 GMT+08:00
分享

SparkJob-SQL鉴权

Hive和DataSource

  • 除了表格内的权限,IAM侧还需要配置lakeformation:policy:describe。
  • 由于Spark集群启动时默认会校验default数据库,所以在执行任何SQL前,需要在LakeFormation控制台上先为目标Catalog下的default数据库授予DESCRIBE权限,授权操作请参考配置LakeFormation元数据权限
  • 建议不要给lakeformation:policy:create权限,给了会被视为管理员,跳过SQL鉴权。

类型

SQL语句

LakeFormation SQL资源鉴权权限

IAM权限

DDL语句

ALTER DATABASE

database:DESCRIBE

database:ALTER

"lakeformation:database:describe",

"lakeformation:database:alter"

ALTER TABLE

database:DESCRIBE

table:DESCRIBE

table:ALTER

database:CREATE_TABLE

column:SELECT或table:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter",

"lakeformation:table:create"

ALTER VIEW

database:DESCRIBE

table:DESCRIBE

table:ALTER

table:CREATE_TABLE

column:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

CREATE DATABASE

database:DESCRIBE

catalog:CREATE_DATABASE

"lakeformation:database:describe",

"lakeformation:database:create"

CREATE OR REPLACE FUNCTION (CREATE)

database:DESCRIBE

database:CREATE_FUNC

"lakeformation:database:describe",

"lakeformation:function:describe",

"lakeformation:function:create"

CREATE OR REPLACE FUNCTION (REPLACE)

database:CREATE_FUNC

database:DESCRIBE

function:DESCRIBE

function:DROP

"lakeformation:database:create",

"lakeformation:database:describe",

"lakeformation:function:describe",

"lakeformation:function:create",

"lakeformation:function:drop"

CREATE TABLE

database:DESCRIBE

database:CREATE_TABLE

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create"

CREATE VIEW

database:DESCRIBE

database:CREATE_TABLE

table:DESCRIBE(source\target)

table:DROP(target)

column:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create",

"lakeformation:table:drop"

DROP DATABASE

database:DESCRIBE

database:DROP

"lakeformation:database:describe",

"lakeformation:database:drop"

DROP FUNCTION

database:DESCRIBE

function:DESCRIBE

function:DROP

"lakeformation:database:describe",

"lakeformation:function:describe",

"lakeformation:function:drop"

DROP TABLE

database:DESCRIBE

table:DESCRIBE

table:DROP

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:drop"

DROP VIEW

database:DESCRIBE

table:DESCRIBE(target\source)

table:DROP(target)

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:drop"

REPAIR TABLE

database:DESCRIBE

table:DESCRIBE

table:ALTER

table:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

TRUNCATE TABLE

database:DESCRIBE

table:DESCRIBE

table:SELECT

table:UPDATE

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

DML语句

INSERT TABLE

database:DESCRIBE

table:DESCRIBE

table:ALTER

table:INSERT

column:SELECT或table:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

LOAD DATA

database:DESCRIBE

table:DESCRIBE

table:UPDATE

table:ALTER

table:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

DR语句

SELECT

database:DESCRIBE

table:DESCRIBE

column:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe"

EXPLAIN

取决于执行sql

-

Auxiliary 语句

ANALYZE TABLE

database:DESCRIBE

table:DESCRIBE

table:SELECT

table:ALTER

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:alter"

DESCRIBE DATABASE

database:DESCRIBE

"lakeformation:database:describe"

DESCRIBE FUNCTION

database:DESCRIBE

function:DESCRIBE

"lakeformation:database:describe",

"lakeformation:function:describe"

DESCRIBE QUERY

database:DESCRIBE

table:DESCRIBE

table:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe"

DESCRIBE TABLE

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

REFRESH TABLE

database:DESCRIBE

table:DESCRIBE

column:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe"

REFRESH FUNCTION

database:DESCRIBE

function:DESCRIBE

"lakeformation:database:describe",

"lakeformation:function:describe"

SHOW COLUMNS

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW CREATE TABLE

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW DATABASES

catalog:LIST_DATABASE

database:DESCRIBE

"lakeformation:database:describe"

SHOW FUNCTIONS

database:DESCRIBE

"lakeformation:database:describe",

"lakeformation:function:describe"

SHOW PARTITIONS

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW TABLE EXTENDED

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW TABLES

database:LIST_TABLE

database:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW TBLPROPERTIES

database:DESCRIBE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

SHOW VIEWS

catalog:LIST_DATABASE

database:LIST_TABLE

database:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

iceberg

Iceberg表除了支持以下表上的命令外,也支持在Hive和DataSource表上的命令。

命令

SQL

LakeFormation SQL资源鉴权权限

IAM权限

展示库

show databases

catalog:LIST_DATABASE

database:DESCRIBE

"lakeformation:database:describe"

创建库

create database

database:DESCRIBE

catalog:CREATE_DATABASE

"lakeformation:database:describe",

"lakeformation:database:create"

删除库

drop database

database:DESCRIBE

database:DROP

"lakeformation:database:describe",

"lakeformation:database:drop"

修改库

alter database

database:DESCRIBE

database:ALTER

"lakeformation:database:describe",

"lakeformation:database:alter"

展示所有表

show tables

database:LIST_TABLE

database:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe"

创建表

CREATE TABLE Test_Iceberg USING iceberg

database:DESCRIBE

database:CREATE_TABLE

table:DESCRIBE

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create"

从查询创建表

CREATE TABLE Test_Iceberg AS SELECT xx From xx Where

table:DESCRIBE

table:ALTER

table:DROP

table:INSERT

database:CREATE_TABLE

database:DESCRIBE

column:SELECT

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create",

"lakeformation:table:alter",

"lakeformation:table:drop"

删除表

DROP TABLE Test_Iceberg

table:DESCRIBE

table:DROP

database:DESCRIBE

"lakeformation:table:describe",

"lakeformation:table:drop",

"lakeformation:database:describe"

写数据

INSERT INTO Test_Iceberg VALUES

table:DESCRIBE

table:ALTER

column:SELECT

database:DESCRIBE

"lakeformation:table:describe",

"lakeformation:table:alter",

"lakeformation:database:describe"

更新数据

UPDATE Test_Iceberg SET col = value WHERE

table:DESCRIBE

table:ALTER

column:SELECT

database:DESCRIBE

"lakeformation:table:describe",

"lakeformation:table:alter",

"lakeformation:database:describe"

覆写

INSERT OVERWRITE Test_Iceberg VALUES

table:DESCRIBE

table:ALTER

table:UPDATE

database:DESCRIBE

"lakeformation:table:describe",

"lakeformation:table:alter",

"lakeformation:database:describe"

替换Iceberg数据

MERGE INTO Test_Iceberg USING xx

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

从Iceberg表删除

DELETE FROM Test_Iceberg WHERE

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

替换已有字段结构

REPLACE TABLE Test_Iceberg (col1..clo2..) USING iceberg

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

字段类型转换

ALTER TABLE Test_Iceberg ALTER COLUMN col TYPE BIGINT

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

添加分区字段

ALTER TABLE Test_Iceberg ADD PARTITION FIELD col

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

删除分区字段

ALTER TABLE Test_Iceberg DROP PARTITION FIELD col

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

替换分区字段

ALTER TABLE Test_Iceberg REPLACE PARTITION FIELD col

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

设置写入分布和排序

ALTER TABLE Test_Iceberg WRITE writeSpec

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

设置标识字段

ALTER TABLE Test_Iceberg SET IDENTIFIER_KW FIELDS fieldList

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

删除标识字段

ALTER TABLE Test_Iceberg DROP IDENTIFIER_KW FIELDS fieldList

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

设置表属性

ALTER TABLE Test_Iceberg SET TBLPROPERTIES

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

创建或替换分支

ALTER TABLE Test_Iceberg create/Replace BRANCH Test_branch

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

创建或替换标签

ALTER TABLE Test_Iceberg create/Replace Tag Test_tag

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

删除分支

ALTER TABLE Test_Iceberg DROP BRANCH Test_branch

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

删除标签

ALTER TABLE Test_Iceberg DROP TAG Test_tag

table:DESCRIBE

table:ALTER

"lakeformation:table:describe",

"lakeformation:table:alter"

分支写

SET xx.wap.branch = Test_branch

INSERT INTO Test_Iceberg VALUES

table:DESCRIBE

table:ALTER

table:INSERT

"lakeformation:table:describe",

"lakeformation:table:alter"

回滚到快照

CALL system.rollback_to_snapshot(Test_Iceberg, snapshot_id)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

回滚到时间戳

CALL system.rollback_to_timestamp(Test_Iceberg, timestamp)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

设置当前快照

CALL system.set_current_snapshot(Test_Iceberg, snapshot_id)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

挑选快照

CALL system.cherrypick_snapshot(Test_Iceberg, snapshot_id)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

快进分支

CALL system.fast_forward(Test_Iceberg, branch)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

过期快照

CALL system.expire_snapshots(Test_Iceberg, older_than)

table:DESCRIBE

table:ALTER

table:DELETE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

删除孤立文件

CALL system.remove_orphan_files(Test_Iceberg)

table:DESCRIBE

table:DELETE

table:SELECT

"lakeformation:table:describe"

重写数据文件

CALL system.rewrite_data_files(Test_Iceberg)

table:DESCRIBE

table:UPDATE

table:SELECT

"lakeformation:table:describe"

重写清单文件

CALL system.rewrite_manifests(Test_Iceberg)

table:DESCRIBE

table:ALTER

table:UPDATE

table:SELECT

"lakeformation:table:describe",

"lakeformation:table:alter"

重写位置删除文件

CALL system.rewrite_position_delete_files(Test_Iceberg)

table:DESCRIBE

table:UPDATE

table:SELECT

"lakeformation:table:describe"

执行表注册操作

CALL system.register_table(spark_catalog, Test_Iceberg)

table:DESCRIBE

database:DESCRIBE

database:CREATE_TABLE

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create"

追溯祖先链

CALL system.ancestors_of(Test_Iceberg)

table:DESCRIBE

table:SELECT

"lakeformation:table:describe"

添加内容到表

CALL system.add_files(Test_Iceberg, Table_1)

table:DESCRIBE

table:ALTER

table:SELECT

table:UPDATE

"lakeformation:table:describe",

"lakeformation:table:alter"

生成新快照

CALL system.publish_changes(Test_Iceberg, wap1)

table:DESCRIBE

table:ALTER

table:SELECT

table:UPDATE

"lakeformation:table:describe",

"lakeformation:table:alter"

创建快照表

CALL system.snapshot(Test_Parquet, Test_Copy)

table:DESCRIBE

database:CREATE_TABLE

"lakeformation:table:describe",

"lakeformation:table:create"

正式改造为iceberg表

CALL system.migrate(Test_Parquet)

table:DESCRIBE

database:DESCRIBE

database:CREATE_TABLE

table:ALTER

"lakeformation:database:describe",

"lakeformation:table:describe",

"lakeformation:table:create",

"lakeformation:table:alter"

查询快照之间的变更

CALL system.create_changelog_view(Test_Iceberg, '1', '4')

table:DESCRIBE

table:SELECT

"lakeformation:table:describe"

相关文档