Skip to content

Commit 64983f0

Browse files
author
Xiaochong Wei
committed
Merge branch 'xwei/add-release-image-publish-workflow' of github.com:anlowee/presto into xwei/add-release-image-publish-workflow
2 parents 283b751 + 20a7054 commit 64983f0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpMetadataFilterProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public ClpMetadataFilterProvider(ClpConfig config)
8585
{
8686
requireNonNull(config, "config is null");
8787

88+
if (null == config.getMetadataFilterConfig()) {
89+
filterMap = ImmutableMap.of();
90+
return;
91+
}
8892
ObjectMapper mapper = new ObjectMapper();
8993
try {
9094
filterMap = mapper.readValue(

presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpMetadataFilterConfig.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import java.nio.file.Paths;
2727
import java.util.Set;
2828

29+
import static java.util.UUID.randomUUID;
2930
import static org.testng.Assert.assertEquals;
3031
import static org.testng.Assert.assertThrows;
32+
import static org.testng.Assert.assertTrue;
3133

3234
@Test(singleThreaded = true)
3335
public class TestClpMetadataFilterConfig
@@ -74,6 +76,22 @@ public void getFilterNames()
7476
assertEquals(ImmutableSet.of("level", "author", "msg.timestamp", "file_name"), tableFilterNames);
7577
}
7678

79+
@Test
80+
public void handleEmptyAndInvalidMetadataFilterConfig()
81+
{
82+
ClpConfig config = new ClpConfig();
83+
84+
// Empty config
85+
ClpMetadataFilterProvider filterProvider = new ClpMetadataFilterProvider(config);
86+
assertTrue(filterProvider.getColumnNames("clp").isEmpty());
87+
assertTrue(filterProvider.getColumnNames("abc.xyz").isEmpty());
88+
assertTrue(filterProvider.getColumnNames("abc.opq.xyz").isEmpty());
89+
90+
// Invalid config
91+
config.setMetadataFilterConfig(randomUUID().toString());
92+
assertThrows(PrestoException.class, () -> new ClpMetadataFilterProvider(config));
93+
}
94+
7795
@Test
7896
public void remapSql()
7997
{

presto-docs/src/main/sphinx/connector/clp.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ Property Name Description
6969
database name is not specified in the URL.
7070
``clp.metadata-db-password`` The password for the metadata database user. This option is required if
7171
``clp.metadata-provider-type`` is set to ``mysql``.
72-
``clp.metadata-filter-config`` The absolute path of the metadata filter config file.
72+
``clp.metadata-filter-config`` The absolute path to an optional metadata filter config file. See the
73+
:ref:`Metadata Filter Config File<metadata-filter-config-file>` section
74+
for details.
7375
``clp.metadata-table-prefix`` A string prefix prepended to all metadata table names when querying the
7476
database. Useful for namespacing or avoiding collisions. This option is
7577
required if ``clp.metadata-provider-type`` is set to ``mysql``.
@@ -96,6 +98,8 @@ If you prefer to use a different source--or the same source with a custom implem
9698
implementations of the ``ClpMetadataProvider`` and ``ClpSplitProvider`` interfaces, and configure the connector
9799
accordingly.
98100

101+
.. _metadata-filter-config-file:
102+
99103
Metadata Filter Config File
100104
----------------------------
101105

0 commit comments

Comments
 (0)