Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ public void testSimpleMask()
assertThat(assertions.query("SELECT custkey FROM orders WHERE orderkey = 1")).matches("VALUES CAST(NULL AS BIGINT)");
}

@Test
public void testConditionalMask()
Comment thread
weiatwork marked this conversation as resolved.
{
accessControl.reset();
accessControl.columnMask(
new QualifiedObjectName(CATALOG, "tiny", "orders"),
"custkey",
USER,
new ViewExpression(USER, Optional.empty(), Optional.empty(), "IF (orderkey < 2, null, -custkey)"));
assertThat(assertions.query("SELECT custkey FROM orders LIMIT 2"))
.matches("VALUES (NULL), CAST('-781' AS BIGINT)");
}

@Test
public void testMultipleMasksOnSameColumn()
{
Expand Down
6 changes: 6 additions & 0 deletions docs/src/main/sphinx/security/file-system-access-control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ Filter and mask environment

These rules do not apply to ``information_schema``.

``mask`` can contain conditional expressions such as ``IF`` or ``CASE``, which achieves conditional masking.
Comment thread
weiatwork marked this conversation as resolved.

The example below defines the following table access policy:

* Role ``admin`` has all privileges across all tables and schemas
Expand Down Expand Up @@ -627,6 +629,10 @@ These rules apply to ``filter_environment`` and ``mask_environment``.

* ``user`` (optional): username for checking permission of subqueries in a mask.

.. note::

``mask`` can contain conditional expressions such as ``IF`` or ``CASE``, which achieves conditional masking.

Session property rules
^^^^^^^^^^^^^^^^^^^^^^

Expand Down