From 0db1eb7e33b9e0d48059bc9cb9f730eab527ffc3 Mon Sep 17 00:00:00 2001 From: Pablo Arteaga Date: Fri, 22 Dec 2023 11:49:37 +0100 Subject: [PATCH] Code review: add JavaDoc to TrinoColumn and enable decision logging for OPA --- .../io/trino/plugin/opa/schema/TrinoColumn.java | 17 +++++++++++++++++ .../java/io/trino/plugin/opa/OpaContainer.java | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugin/trino-opa/src/main/java/io/trino/plugin/opa/schema/TrinoColumn.java b/plugin/trino-opa/src/main/java/io/trino/plugin/opa/schema/TrinoColumn.java index 4f21cb04a20b6..1070f02558dc7 100644 --- a/plugin/trino-opa/src/main/java/io/trino/plugin/opa/schema/TrinoColumn.java +++ b/plugin/trino-opa/src/main/java/io/trino/plugin/opa/schema/TrinoColumn.java @@ -19,6 +19,23 @@ import static java.util.Objects.requireNonNull; +/** + * This class is used to represent information about a column for the purposes of column masking. + * It is (perhaps counterintuitively) only used for column masking and not for operations like + * FilterColumns. This is for 3 reasons: + * - API stability between the batch & non-batch modes: sending an array of TrinoColumn objects would be wasteful for + * the batch authorizer mode (as it would repeat the catalog, schema and table names once per column). As such, this + * object is not used for FilterColumns even if batch mode is disabled + * - This object contains in-depth information about the column (e.g. its type), and it may be modified to include + * additional fields in the future. This level of information is not provided to operations like FilterColumns + * - Backwards compatibility + * + * @param catalogName The name of the catalog this column's table belongs to + * @param schemaName The name of the schema this column's table belongs to + * @param tableName The name of the table this column is in + * @param columnName Column name + * @param columnType String representation of the column type + */ public record TrinoColumn( @NotNull String catalogName, @NotNull String schemaName, diff --git a/plugin/trino-opa/src/test/java/io/trino/plugin/opa/OpaContainer.java b/plugin/trino-opa/src/test/java/io/trino/plugin/opa/OpaContainer.java index ddb8c4aaf6fce..673fafcaf4f14 100644 --- a/plugin/trino-opa/src/test/java/io/trino/plugin/opa/OpaContainer.java +++ b/plugin/trino-opa/src/test/java/io/trino/plugin/opa/OpaContainer.java @@ -37,7 +37,7 @@ public class OpaContainer public OpaContainer() { this.container = new GenericContainer<>(DockerImageName.parse("openpolicyagent/opa:latest-rootless")) - .withCommand("run", "--server", "--addr", ":%d".formatted(OPA_PORT)) + .withCommand("run", "--server", "--addr", ":%d".formatted(OPA_PORT), "--set", "decision_logs.console=true") .withExposedPorts(OPA_PORT) .waitingFor(Wait.forListeningPort()); }