Jackie-Jiang commented on a change in pull request #5175:
URL: https://github.com/apache/incubator-pinot/pull/5175#discussion_r413222162
##########
File path:
pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java
##########
@@ -367,4 +381,12 @@ private void checkFieldConfig(TableConfig tableConfig) {
assertNull(secondFieldConfig.getIndexType());
assertNull(secondFieldConfig.getProperties());
}
+
+ private void checkTableConfigWithUpsertConfig(TableConfig tableConfig,
TableConfig tableConfigToCompare) {
Review comment:
Can you make this similar to other config check? Pass in a table config
and check the actual value inside the config. Then serialize and deserialize
(both string and ZNRecord) and check again
##########
File path:
pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -116,8 +117,16 @@ public static TableConfig fromZNRecord(ZNRecord znRecord)
});
}
+ UpsertConfig upsertConfig = null;
+ String upsertConfigString =
simpleFields.get(TableConfig.UPSERT_CONFIG_KEY);
+ if (upsertConfigString != null) {
+ upsertConfig = JsonUtils.stringToObject(upsertConfigString,
UpsertConfig.class);
+ }
+
Review comment:
(nit) extra empty line
##########
File path:
pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigSerDeTest.java
##########
@@ -231,6 +234,17 @@ public void testSerDe()
assertEquals(tableConfigToCompare, tableConfig);
checkFieldConfig(tableConfigToCompare);
}
+ {
+ // with upsert config
+ UpsertConfig upsertConfig = new UpsertConfig(ImmutableList.of("pk"),
"offset",
Review comment:
Prefer using `Collections.singletonList()`
##########
File path:
pinot-spi/src/test/java/org/apache/pinot/spi/config/UpsertConfigTest.java
##########
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.config;
+
+import com.google.common.collect.ImmutableList;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+public class UpsertConfigTest {
+
+ @Test
+ public void testUpsertConfig() {
+ UpsertConfig upsertConfig;
+
+ // test regular upsert table
+ upsertConfig = new UpsertConfig(ImmutableList.of("primaryKey"), "offset",
"validFrom",
+ "validUntil");
+ assertEquals(1, upsertConfig.getPrimaryKeyColumns().size());
+ assertEquals("primaryKey", upsertConfig.getPrimaryKeyColumns().get(0));
+ assertEquals("offset", upsertConfig.getOffsetColumn());
+ assertEquals("validFrom", upsertConfig.getValidFromColumn());
+ assertEquals("validUntil", upsertConfig.getValidUntilColumn());
+
+ // test sanity check
+ try {
+ upsertConfig = new UpsertConfig(null,
+ "offset", "validFrom", "validUntil");
+ fail();
+ } catch (RuntimeException ex) {}
+
+ try {
+ upsertConfig = new UpsertConfig(ImmutableList.of("pk1", "pk2"),
+ "offset", "validFrom", "validUntil");
+ fail();
+ } catch (RuntimeException ex) {}
+
+ try {
+ upsertConfig = new UpsertConfig(ImmutableList.of("pk1"),
+ null, "validFrom", "validUntil");
+ fail();
+ } catch (RuntimeException ex) {}
+
+ try {
+ upsertConfig = new UpsertConfig(ImmutableList.of("pk1"),
+ "offset", null, "validUntil");
+ fail();
+ } catch (RuntimeException ex) {}
+
+ try {
+ upsertConfig = new UpsertConfig(ImmutableList.of("pk1"),
+ "offset", "validFrom", null);
+ fail();
+ } catch (RuntimeException ex) {}
+ }
+}
Review comment:
(nit) empty line
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]