使用AWS CDK创建数据湖时,如果您在指定数据表的数据单元格过滤器时未指定列名或列通配符,则会出现该错误。解决此问题的方法是在数据单元格过滤器中指定列名或列通配符。
以下是一个使用AWS CDK创建数据湖并指定数据单元格过滤器和列名的示例代码:
from aws_cdk import (
core,
aws_lakeformation as lakeformation,
aws_glue as glue
)
class DataLakeStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Create a database
database = glue.Database(self, "my-db",
database_name="my_database",
description="My database")
# Create a table
table = glue.Table(self, "my-table",
database=database,
table_name="my_table",
description="My table",
columns=[{'name': 'col1', 'type': glue.Schema.STRING},
{'name': 'col2', 'type': glue.Schema.STRING}],
partition_keys=[{'name': 'partition_key', 'type': glue.Schema.STRING}],
data_format=glue.DataFormat.PARQUET)
# Create a resource with the table name and permissions
resource_with_permissions = lakeformation.CfnResource(self, "my-resource",
resource_arn=table.table_arn,
role_arn="arn:aws:iam::123456789012:role/my-lf-role",
use_service_linked_role=False,
database_resource=lakeformation.CfnResource.DatabaseResourceProperty(name=database.database_name))
# Add a data cell filter with the column name
lakeformation.CfnPermissions(self, "my-permission",
permissions=lakeformation.CfnPermissions.DatabasePermissionsProperty(
permissions=["SELECT"],
data_location=lakeformation.CfnPermissions.DataLocationProperty(
resource_arn=resource_with_permissions.attr_arn,
s3_location=lakeformation.CfnPermissions.S